Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,12 +8,12 @@ model_path = "pokemon_classifier_model.keras"
|
|
| 8 |
model = tf.keras.models.load_model(model_path)
|
| 9 |
|
| 10 |
# Define the Pokémon classes
|
| 11 |
-
classes = ['Doduo', 'Geodude', 'Zubat']
|
| 12 |
|
| 13 |
# Define the image classification function
|
| 14 |
def classify_image(image):
|
| 15 |
try:
|
| 16 |
-
# Ensure image is in RGB
|
| 17 |
if image.mode != 'RGB':
|
| 18 |
image = image.convert('RGB')
|
| 19 |
image = image.resize((150, 150)) # Resize to the input size your model expects
|
|
@@ -30,8 +30,8 @@ def classify_image(image):
|
|
| 30 |
return str(e) # Return the error message if something goes wrong
|
| 31 |
|
| 32 |
# Create Gradio interface
|
| 33 |
-
input_image = gr.Image(
|
| 34 |
-
output_label = gr.Label()
|
| 35 |
|
| 36 |
interface = gr.Interface(fn=classify_image,
|
| 37 |
inputs=input_image,
|
|
@@ -39,4 +39,4 @@ interface = gr.Interface(fn=classify_image,
|
|
| 39 |
examples=["path/to/example1.jpg", "path/to/example2.jpg"], # Optional: Add example images if available
|
| 40 |
description="Upload an image of a Pokémon to classify!")
|
| 41 |
|
| 42 |
-
interface.launch()
|
|
|
|
| 8 |
model = tf.keras.models.load_model(model_path)
|
| 9 |
|
| 10 |
# Define the Pokémon classes
|
| 11 |
+
classes = ['Doduo', 'Geodude', 'Zubat']
|
| 12 |
|
| 13 |
# Define the image classification function
|
| 14 |
def classify_image(image):
|
| 15 |
try:
|
| 16 |
+
# Ensure the image is in RGB
|
| 17 |
if image.mode != 'RGB':
|
| 18 |
image = image.convert('RGB')
|
| 19 |
image = image.resize((150, 150)) # Resize to the input size your model expects
|
|
|
|
| 30 |
return str(e) # Return the error message if something goes wrong
|
| 31 |
|
| 32 |
# Create Gradio interface
|
| 33 |
+
input_image = gr.Image() # Correct usage without shape parameter
|
| 34 |
+
output_label = gr.Label()
|
| 35 |
|
| 36 |
interface = gr.Interface(fn=classify_image,
|
| 37 |
inputs=input_image,
|
|
|
|
| 39 |
examples=["path/to/example1.jpg", "path/to/example2.jpg"], # Optional: Add example images if available
|
| 40 |
description="Upload an image of a Pokémon to classify!")
|
| 41 |
|
| 42 |
+
interface.launch()
|