Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,18 @@ import AnimeGANv3_src
|
|
6 |
|
7 |
os.makedirs('output', exist_ok=True)
|
8 |
|
|
|
|
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def inference(img_path, Style, if_face=None):
|
11 |
print(img_path, Style, if_face)
|
12 |
try:
|
|
|
6 |
|
7 |
os.makedirs('output', exist_ok=True)
|
8 |
|
9 |
+
def resize_image(img: np.ndarray, x32: bool = False) -> np.ndarray:
|
10 |
+
h, w = img.shape[:2]
|
11 |
+
ratio = h / w
|
12 |
+
if x32: # resize image to multiple of 32s
|
13 |
|
14 |
+
def to_32s(x):
|
15 |
+
return 256 if x < 256 else x - x % 32
|
16 |
+
|
17 |
+
new_h = to_32s(h)
|
18 |
+
new_w = int(new_h / ratio) - int(new_h / ratio) % 32
|
19 |
+
img = cv2.resize(img, (new_w, new_h))
|
20 |
+
return img
|
21 |
def inference(img_path, Style, if_face=None):
|
22 |
print(img_path, Style, if_face)
|
23 |
try:
|