Spaces:
Runtime error
Runtime error
jaekookang
commited on
Commit
β’
57064d0
1
Parent(s):
c31a89f
add resize option
Browse files
gradio_artist_classifier.py
CHANGED
@@ -13,7 +13,9 @@ import seaborn as sns
|
|
13 |
import io
|
14 |
import json
|
15 |
import numpy as np
|
|
|
16 |
import skimage.io
|
|
|
17 |
from loguru import logger
|
18 |
from huggingface_hub import from_pretrained_keras
|
19 |
import gradio as gr
|
@@ -49,14 +51,15 @@ def load_image_as_array(image_file):
|
|
49 |
img = img[..., :-1]
|
50 |
return img
|
51 |
|
52 |
-
def
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
56 |
|
57 |
def predict(input_image):
|
58 |
img_3d_array = load_image_as_array(input_image)
|
59 |
-
|
60 |
img_4d_array = img_3d_array[np.newaxis,...]
|
61 |
logger.info(f'--- {input_image} loaded')
|
62 |
|
|
|
13 |
import io
|
14 |
import json
|
15 |
import numpy as np
|
16 |
+
import skimage
|
17 |
import skimage.io
|
18 |
+
from skimage.transform import resize
|
19 |
from loguru import logger
|
20 |
from huggingface_hub import from_pretrained_keras
|
21 |
import gradio as gr
|
|
|
51 |
img = img[..., :-1]
|
52 |
return img
|
53 |
|
54 |
+
def resize_image(img_array, width, height):
|
55 |
+
img_resized = resize(img_array, (height, width),
|
56 |
+
anti_aliasing=True,
|
57 |
+
preserve_range=False)
|
58 |
+
return skimage.img_as_ubyte(img_resized)
|
59 |
|
60 |
def predict(input_image):
|
61 |
img_3d_array = load_image_as_array(input_image)
|
62 |
+
img_3d_array = resize_image(img_3d_array)
|
63 |
img_4d_array = img_3d_array[np.newaxis,...]
|
64 |
logger.info(f'--- {input_image} loaded')
|
65 |
|