Spaces:
Runtime error
Runtime error
Use tf load_img
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
| 3 |
-
|
| 4 |
|
| 5 |
from labels import CLASS_LABELS
|
| 6 |
|
|
@@ -8,11 +8,11 @@ from labels import CLASS_LABELS
|
|
| 8 |
model = from_pretrained_keras("jsolow/grubguesser")
|
| 9 |
|
| 10 |
|
| 11 |
-
def _preprocess(
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
return
|
| 16 |
|
| 17 |
|
| 18 |
def predict(image):
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
| 3 |
+
import tensorflow as tf
|
| 4 |
|
| 5 |
from labels import CLASS_LABELS
|
| 6 |
|
|
|
|
| 8 |
model = from_pretrained_keras("jsolow/grubguesser")
|
| 9 |
|
| 10 |
|
| 11 |
+
def _preprocess(image_path: str):
|
| 12 |
+
image = tf.keras.utils.load_img(image_path, target_size=(224, 224))
|
| 13 |
+
input_arr = tf.keras.utils.img_to_array(image)
|
| 14 |
+
input_arr = np.array([input_arr]) # Convert single image to a batch.
|
| 15 |
+
return input_arr
|
| 16 |
|
| 17 |
|
| 18 |
def predict(image):
|