fetaiedi commited on
Commit
f47fbdb
1 Parent(s): b2a0888

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -39
app.py DELETED
@@ -1,39 +0,0 @@
1
- import gradio as gr
2
- import tensorflow as tf
3
- from PIL import Image
4
- import numpy as np
5
-
6
- # Load the Pokémon classifier model
7
- model_path = "pokemon_classifier_finetuned.keras"
8
- model = tf.keras.models.load_model(model_path)
9
-
10
- labels = ['Arbok', 'Nidoking', 'Tauros']
11
-
12
- # Define function for Pokémon classification
13
- def preprocess_image(image):
14
- # Preprocess image
15
- image = Image.fromarray(image.astype('uint8'))
16
- image = image.resize((224, 224))
17
- image = np.array(image)
18
- image = image / 255.0 # Normalize pixel values
19
- return image
20
-
21
- # Prediction
22
- def predict_pokemon(image):
23
- image = preprocess_image(image)
24
- prediction = model.predict(image[None, ...])
25
- predicted_class = labels[np.argmax(prediction)]
26
- confidence = np.round(np.max(prediction) * 100, 2)
27
- result = f"Label: {predicted_class}, Confidence: {confidence}%"
28
- return result
29
-
30
- # Create Gradio interface
31
- input_image = gr.Image()
32
- output_text = gr.Textbox(label="Pokemon")
33
- interface = gr.Interface(fn=predict_pokemon,
34
- inputs=input_image,
35
- outputs=output_text,
36
- description="A Pokémon classifier using transfer learning and fine-tuning with EfficientNetB0.")
37
-
38
- if __name__ == "__main__":
39
- interface.launch()