Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,10 @@ from tensorflow.keras.preprocessing.image import img_to_array, load_img
|
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
# Modell laden
|
| 7 |
-
model = load_model('
|
| 8 |
|
| 9 |
def classify_image(image):
|
| 10 |
-
image = image.resize((224, 224)) # passende Größe
|
| 11 |
image = img_to_array(image) # Bild in Array umwandeln
|
| 12 |
image = np.expand_dims(image, axis=0) # Dimension hinzufügen
|
| 13 |
image /= 255.0 # Normalisierung
|
|
@@ -17,9 +17,9 @@ def classify_image(image):
|
|
| 17 |
return {classes[i]: float(prediction[0][i]) for i in range(4)} # Wahrscheinlichkeiten zurückgeben
|
| 18 |
|
| 19 |
iface = gr.Interface(
|
| 20 |
-
classify_image,
|
| 21 |
-
gr.inputs.Image(shape=(224, 224)),
|
| 22 |
-
gr.outputs.Label(num_top_classes=4),
|
| 23 |
title="Pokémon Classifier",
|
| 24 |
description="Upload an image of a Pokémon and see the model classify it!"
|
| 25 |
)
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
# Modell laden
|
| 7 |
+
model = load_model('path/to/your/model.keras')
|
| 8 |
|
| 9 |
def classify_image(image):
|
| 10 |
+
image = image.resize((224, 224)) # Bild auf passende Größe bringen
|
| 11 |
image = img_to_array(image) # Bild in Array umwandeln
|
| 12 |
image = np.expand_dims(image, axis=0) # Dimension hinzufügen
|
| 13 |
image /= 255.0 # Normalisierung
|
|
|
|
| 17 |
return {classes[i]: float(prediction[0][i]) for i in range(4)} # Wahrscheinlichkeiten zurückgeben
|
| 18 |
|
| 19 |
iface = gr.Interface(
|
| 20 |
+
fn=classify_image,
|
| 21 |
+
inputs=gr.inputs.Image(shape=(224, 224)),
|
| 22 |
+
outputs=gr.outputs.Label(num_top_classes=4),
|
| 23 |
title="Pokémon Classifier",
|
| 24 |
description="Upload an image of a Pokémon and see the model classify it!"
|
| 25 |
)
|