Upload 11 files
Browse files- .gitattributes +1 -0
- app.py +52 -0
- images/Dratini1.jpg +0 -0
- images/Dratini2.jpg +0 -0
- images/Dratini3.jpg +0 -0
- images/Eevee1.jpg +0 -0
- images/Eevee2.jpg +0 -0
- images/Eevee3.jpg +0 -0
- images/Jolteon1.jpg +0 -0
- images/Jolteon2.jpg +0 -0
- images/Jolteon3.jpg +0 -0
- pokemon-model_transferlearning.keras +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
pokemon-model_transferlearning.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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=["images/Dratini1.jpg",
|
40 |
+
"images/Dratini2.jpg",
|
41 |
+
"images/Dratini3.jpg",
|
42 |
+
"images/Eevee1.jpg",
|
43 |
+
"images/Eevee2.jpg",
|
44 |
+
"images/Eevee3.jpg",
|
45 |
+
"images/Jolteon1.jpg",
|
46 |
+
"images/Jolteon2.jpg",
|
47 |
+
"images/Jolteon3.jpg"],
|
48 |
+
description="TEST.")
|
49 |
+
|
50 |
+
iface.launch()
|
51 |
+
|
52 |
+
|
images/Dratini1.jpg
ADDED
images/Dratini2.jpg
ADDED
images/Dratini3.jpg
ADDED
images/Eevee1.jpg
ADDED
images/Eevee2.jpg
ADDED
images/Eevee3.jpg
ADDED
images/Jolteon1.jpg
ADDED
images/Jolteon2.jpg
ADDED
images/Jolteon3.jpg
ADDED
pokemon-model_transferlearning.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:57c7a246c572082a9fef5d75425767f23cfc76a10aae428276845c0c175341fd
|
3 |
+
size 250560147
|