Nineylia commited on
Commit
49e8388
1 Parent(s): bca7038

Upload 14 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
+ Dog_transfer_learning_NASNetLarge.keras filter=lfs diff=lfs merge=lfs -text
Dog_transfer_learning_NASNetLarge.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b800b240bd4e19b82660ac867a7ffffd9be63ec2d9b88a446002959ced9ad46a
3
+ size 1021796704
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 = "Dog_transfer_learning_NASNetLarge.keras"
7
+ model = tf.keras.models.load_model(model_path)
8
+
9
+ # Define the core prediction function
10
+ def predict_dog(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, 3)
24
+
25
+ # Separate the probabilities for each class
26
+ p_husky = prediction[0][0] # Probability for class 'articuno'
27
+ p_pomeranian = prediction[0][1] # Probability for class 'moltres'
28
+ p_rottwiler = prediction[0][2] # Probability for class 'zapdos'
29
+ p_shiba = prediction[0][3] # Probability for class 'zapdos'
30
+
31
+ return {'husky': p_husky, 'pomeranian': p_pomeranian, 'rottwiler': p_rottwiler, 'shiba': p_shiba}
32
+
33
+ # Create the Gradio interface
34
+ input_image = gr.Image()
35
+ iface = gr.Interface(
36
+ fn=predict_dog,
37
+ inputs=input_image,
38
+ outputs=gr.Label(),
39
+ examples=["images/husky_1.jpg", "images/husky_2.jpg", "images/husky_3.jpg", "images/pomeranian_1.jpg", "images/pomeranian_2.jpg", "images/pomeranian_3.jpg", "images/rottwiler_1.jpg", "images/rottwiler_2.jpg", "images/rottwiler_3.jpg", "images/shiba_1.jpg", "images/shiba_2.jpg", "images/shiba_3.jpg"],
40
+ description="TEST.")
41
+
42
+ iface.launch()
images/husky_1.jpg ADDED
images/husky_2.jpg ADDED
images/husky_3.jpg ADDED
images/pomeranian_1.jpg ADDED
images/pomeranian_2.jpg ADDED
images/pomeranian_3.jpg ADDED
images/rottwiler_1.jpg ADDED
images/rottwiler_2.jpg ADDED
images/rottwiler_3.jpg ADDED
images/shiba_1.jpg ADDED
images/shiba_2.jpg ADDED
images/shiba_3.jpg ADDED