Spaces:
Sleeping
Sleeping
File size: 1,150 Bytes
e47be1b 1e2e085 6009c34 e47be1b 1e2e085 e47be1b 1e2e085 e47be1b b7eec1b e47be1b b7eec1b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import tensorflow as tf
from PIL import Image
import numpy as np
# Lade dein Modell (hier als Beispiel die Keras .h5 Datei)
model = tf.keras.models.load_model('pokemon_model.keras')
# Klassennamen, sollten deinem Dataset entsprechen
class_names = ['Jolteon', 'Kakuna', 'Mr. Mime']
def classify_image(image):
image = Image.fromarray(image.astype('uint8'), 'RGB')
img = image.resize((160, 160))
img_array = tf.keras.preprocessing.image.img_to_array(img)
img_array = tf.expand_dims(img_array, 0) # Erstelle einen Batch
predictions = model.predict(img_array)
predicted_class = class_names[np.argmax(predictions[0])]
confidence = np.max(predictions[0])
return predicted_class, confidence
image_input = gr.Image() # Entferne den `shape` Parameter
label = gr.Label(num_top_classes=3)
iface = gr.Interface(
fn=classify_image,
inputs=image_input,
outputs=label,
title='Pokémon Classifier',
description='Upload an image of Jolteon, Kakuna, Mr. Mime and the classifier will tell you which one it is and the confidence level of the prediction.').launch()
iface.launch()
|