Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
-
|
4 |
|
5 |
# Lade dein benutzerdefiniertes Regressionsmodell
|
6 |
model = tf.keras.models.load_model('Task_Pokemon.keras')
|
@@ -9,16 +9,17 @@ model = tf.keras.models.load_model('Task_Pokemon.keras')
|
|
9 |
class_names = ['Aerodactyl', 'Charizard', 'Victreebel']
|
10 |
|
11 |
def classify_image(image):
|
12 |
-
|
13 |
-
|
|
|
14 |
img_array = tf.expand_dims(img_array, 0) # Erstelle einen Batch
|
15 |
predictions = model.predict(img_array)
|
16 |
predicted_class = class_names[np.argmax(predictions[0])]
|
17 |
confidence = np.max(predictions[0])
|
18 |
return predicted_class, confidence
|
19 |
|
20 |
-
image_input = gr.Image()
|
21 |
-
label = gr.Label(num_top_classes=3)
|
22 |
|
23 |
iface = gr.Interface(
|
24 |
fn=classify_image,
|
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
|
5 |
# Lade dein benutzerdefiniertes Regressionsmodell
|
6 |
model = tf.keras.models.load_model('Task_Pokemon.keras')
|
|
|
9 |
class_names = ['Aerodactyl', 'Charizard', 'Victreebel']
|
10 |
|
11 |
def classify_image(image):
|
12 |
+
# Konvertiere das Bild in ein PIL-Bildobjekt
|
13 |
+
img_pil = image.resize((160, 160)) # Hier definieren wir die Größe der Bilder
|
14 |
+
img_array = tf.keras.preprocessing.image.img_to_array(img_pil)
|
15 |
img_array = tf.expand_dims(img_array, 0) # Erstelle einen Batch
|
16 |
predictions = model.predict(img_array)
|
17 |
predicted_class = class_names[np.argmax(predictions[0])]
|
18 |
confidence = np.max(predictions[0])
|
19 |
return predicted_class, confidence
|
20 |
|
21 |
+
image_input = gr.inputs.Image()
|
22 |
+
label = gr.outputs.Label(num_top_classes=3)
|
23 |
|
24 |
iface = gr.Interface(
|
25 |
fn=classify_image,
|