Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,19 +9,18 @@ model = tf.keras.models.load_model('pokemon_model.keras')
|
|
| 9 |
# Klassennamen, sollten deinem Dataset entsprechen
|
| 10 |
class_names = ['Jolteon', 'Kakuna', 'Mr. Mime']
|
| 11 |
|
| 12 |
-
|
| 13 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
| 14 |
img = image.resize((160, 160))
|
| 15 |
img_array = tf.keras.preprocessing.image.img_to_array(img)
|
| 16 |
-
img_array = tf.expand_dims(img_array, 0) # Erstelle einen Batch
|
| 17 |
predictions = model.predict(img_array)
|
| 18 |
predicted_class = class_names[np.argmax(predictions[0])]
|
| 19 |
confidence = np.max(predictions[0])
|
| 20 |
return predicted_class, confidence
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
label = gr.Label(num_top_classes=3)
|
| 25 |
|
| 26 |
iface = gr.Interface(
|
| 27 |
fn=classify_image,
|
|
|
|
| 9 |
# Klassennamen, sollten deinem Dataset entsprechen
|
| 10 |
class_names = ['Jolteon', 'Kakuna', 'Mr. Mime']
|
| 11 |
|
| 12 |
+
def classify_image(image):
|
| 13 |
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
| 14 |
img = image.resize((160, 160))
|
| 15 |
img_array = tf.keras.preprocessing.image.img_to_array(img)
|
| 16 |
+
img_array = tf.expand_dims(img_array, 0) # Erstelle einen Batch
|
| 17 |
predictions = model.predict(img_array)
|
| 18 |
predicted_class = class_names[np.argmax(predictions[0])]
|
| 19 |
confidence = np.max(predictions[0])
|
| 20 |
return predicted_class, confidence
|
| 21 |
|
| 22 |
+
image_input = gr.Image() # Entferne den `shape` Parameter
|
| 23 |
+
label = gr.Label(num_top_classes=3)
|
|
|
|
| 24 |
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=classify_image,
|