Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
|
|
3 |
from tensorflow.keras.utils import CustomObjectScope
|
4 |
from tensorflow.keras.layers.experimental.preprocessing import RandomHeight
|
5 |
|
@@ -8,10 +9,11 @@ with CustomObjectScope({'RandomHeight': RandomHeight}):
|
|
8 |
|
9 |
def classify_image(inp):
|
10 |
# Convert to PIL Image if we have a numpy array
|
11 |
-
|
12 |
-
|
|
|
13 |
else:
|
14 |
-
image =
|
15 |
|
16 |
# Resize image to 224x224
|
17 |
image = image.resize((224, 224), Image.Resampling.LANCZOS)
|
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
from tensorflow.keras.utils import CustomObjectScope
|
5 |
from tensorflow.keras.layers.experimental.preprocessing import RandomHeight
|
6 |
|
|
|
9 |
|
10 |
def classify_image(inp):
|
11 |
# Convert to PIL Image if we have a numpy array
|
12 |
+
image = None
|
13 |
+
if isinstance(inp, np.ndarray):
|
14 |
+
image = Image.fromarray(inp)
|
15 |
else:
|
16 |
+
image = inp
|
17 |
|
18 |
# Resize image to 224x224
|
19 |
image = image.resize((224, 224), Image.Resampling.LANCZOS)
|