Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,16 +12,17 @@ model = tf.keras.models.load_model('Task_Pokemon.keras')
|
|
12 |
class_names = ['Aerodactyl', 'Charizard', 'Victreebel']
|
13 |
|
14 |
def classify_image(image):
|
15 |
-
|
16 |
-
|
17 |
-
img_array = tf.
|
|
|
18 |
predictions = model.predict(img_array)
|
19 |
predicted_class = class_names[np.argmax(predictions[0])]
|
20 |
confidence = np.max(predictions[0])
|
21 |
-
return predicted_class
|
22 |
|
23 |
-
image_input = gr.
|
24 |
-
label = gr.
|
25 |
|
26 |
iface = gr.Interface(
|
27 |
fn=classify_image,
|
@@ -32,3 +33,5 @@ iface = gr.Interface(
|
|
32 |
)
|
33 |
|
34 |
iface.launch()
|
|
|
|
|
|
12 |
class_names = ['Aerodactyl', 'Charizard', 'Victreebel']
|
13 |
|
14 |
def classify_image(image):
|
15 |
+
image = Image.fromarray(image.astype('uint8'), 'RGB')
|
16 |
+
img = image.resize((150, 150))
|
17 |
+
img_array = tf.keras.preprocessing.image.img_to_array(img)
|
18 |
+
img_array = tf.expand_dims(img_array, 0) # Erstelle einen Batch
|
19 |
predictions = model.predict(img_array)
|
20 |
predicted_class = class_names[np.argmax(predictions[0])]
|
21 |
confidence = np.max(predictions[0])
|
22 |
+
return {predicted_class: float(confidence)}
|
23 |
|
24 |
+
image_input = gr.Image()
|
25 |
+
label = gr.Label(num_top_classes=3)
|
26 |
|
27 |
iface = gr.Interface(
|
28 |
fn=classify_image,
|
|
|
33 |
)
|
34 |
|
35 |
iface.launch()
|
36 |
+
|
37 |
+
|