Kupredom commited on
Commit
4d42966
1 Parent(s): 505354a

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -52
app.py DELETED
@@ -1,52 +0,0 @@
1
- import gradio as gr
2
- import tensorflow as tf
3
- print(tf.__version__)
4
- import numpy as np
5
- from PIL import Image
6
-
7
- import os
8
-
9
- model_path = "pokemon-model_transferlearning.keras"
10
- model = tf.keras.models.load_model(model_path)
11
-
12
- def predict_pokemon(image):
13
- # Preprocess image
14
- print(type(image))
15
- image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
16
- image = image.resize((150, 150)) # Resize the image to 150x150 pixels
17
- image = np.array(image)
18
- image = np.expand_dims(image, axis=0) # Add batch dimension
19
-
20
- # Predict
21
- prediction = model.predict(image)
22
- # Convert the probabilities to rounded values
23
- prediction = np.round(prediction, 2)
24
-
25
- # Make sure the indices are correct according to your model's training
26
- p_dratini = prediction[0][0] # Probability for class 'dratini'
27
- p_eevee = prediction[0][1] # Probability for class 'eevee'
28
- p_jolteon = prediction[0][2] # Probability for class 'jolteon'
29
-
30
- return {'dratini': p_dratini, 'eevee': p_eevee, 'jolteon': p_jolteon}
31
-
32
-
33
- # Create the Gradio interface
34
- input_image = gr.Image()
35
- iface = gr.Interface(
36
- fn=predict_pokemon,
37
- inputs=input_image,
38
- outputs=gr.Label(),
39
- examples=["C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Dratini1.jpg",
40
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Dratini2.jpg",
41
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Dratini3.jpg",
42
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Eevee1.jpg",
43
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Eevee2.jpg",
44
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Eevee3.jpg",
45
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Jolteon1.jpg",
46
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Jolteon2.jpg",
47
- "C:/Users/dom-k/Visual Studio Code/6. Semester/pokemon/images/Jolteon3.jpg"],
48
- description="TEST.")
49
-
50
- iface.launch()
51
-
52
-