mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
mask upload
This commit is contained in:
@@ -3,6 +3,7 @@ import datetime
|
||||
import random
|
||||
import math
|
||||
import os
|
||||
import cv2
|
||||
|
||||
from PIL import Image
|
||||
|
||||
@@ -10,6 +11,15 @@ from PIL import Image
|
||||
LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS)
|
||||
|
||||
|
||||
def erode_or_dilate(x, k):
|
||||
k = int(k)
|
||||
if k > 0:
|
||||
return cv2.dilate(x, kernel=np.ones(shape=(3, 3), dtype=np.uint8), iterations=k)
|
||||
if k < 0:
|
||||
return cv2.erode(x, kernel=np.ones(shape=(3, 3), dtype=np.uint8), iterations=-k)
|
||||
return x
|
||||
|
||||
|
||||
def resample_image(im, width, height):
|
||||
im = Image.fromarray(im)
|
||||
im = im.resize((int(width), int(height)), resample=LANCZOS)
|
||||
|
||||
Reference in New Issue
Block a user