linsan01 commited on
Commit
a5ee218
1 Parent(s): 2d1d161

Upload 11 files

Browse files
.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_transferlearning.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ model_path = "pokemon_transferlearning.keras"
7
+ model = tf.keras.models.load_model(model_path)
8
+
9
+ # Define the core prediction function
10
+ def predict_pokemon(image):
11
+ # Preprocess image
12
+ print(type(image))
13
+ image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
14
+ image = image.resize((150, 150)) #resize the image to 28x28 and converts it to gray scale
15
+ image = np.array(image)
16
+ image = np.expand_dims(image, axis=0) # same as image[None, ...]
17
+
18
+ # Predict
19
+ prediction = model.predict(image)
20
+
21
+ # No need to apply sigmoid, as the output layer already uses softmax
22
+ # Convert the probabilities to rounded values
23
+ prediction = np.round(prediction, 2)
24
+
25
+ # Separate the probabilities for each class
26
+ p_charmander = prediction[0][0] # Probability for class 'articuno'
27
+ p_mewtwo = prediction[0][1] # Probability for class 'moltres'
28
+ p_squirtle = prediction[0][2] # Probability for class 'zapdos'
29
+
30
+ return {'charmander': p_charmander, 'mewtwo': p_mewtwo, 'squirtle': p_squirtle}
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/char1.png", "images/char2.png", "images/char3.png", "images/mew1.jpg", "images/mew2.jpg", "images/mew3.jpg", "images/squi1.jpg", "images/squi2.png", "images/squi3.png"],
40
+ description="TEST.")
41
+
42
+ iface.launch()
images/char1.png ADDED
images/char2.png ADDED
images/char3.png ADDED
images/mew1.jpg ADDED
images/mew2.jpg ADDED
images/mew3.jpg ADDED
images/squi1.jpg ADDED
images/squi2.png ADDED
images/squi3.png ADDED
pokemon_transferlearning.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3047e9228f99f9b2b0dc8487cdc6f1e5d5252b6b096bcd5d24273e326a61e34b
3
+ size 250560238