Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import numpy as np
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
|
| 7 |
-
model_path = "
|
| 8 |
model = tf.keras.models.load_model(model_path)
|
| 9 |
|
| 10 |
# Define the core prediction function
|
|
@@ -23,14 +23,45 @@ def predict_bmwX(image):
|
|
| 23 |
prediction = tf.nn.softmax(prediction)
|
| 24 |
|
| 25 |
# Create a dictionary with the probabilities for each Pokemon
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
return {'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
input_image = gr.Image()
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
|
| 7 |
+
model_path = "DogClassifierComplex.keras"
|
| 8 |
model = tf.keras.models.load_model(model_path)
|
| 9 |
|
| 10 |
# Define the core prediction function
|
|
|
|
| 23 |
prediction = tf.nn.softmax(prediction)
|
| 24 |
|
| 25 |
# Create a dictionary with the probabilities for each Pokemon
|
| 26 |
+
afghan = np.round(float(prediction[0][0]), 2)
|
| 27 |
+
africanWildDog = np.round(float(prediction[0][1]), 2)
|
| 28 |
+
beagle = np.round(float(prediction[0][2]), 2)
|
| 29 |
+
blenheim = np.round(float(prediction[0][3]), 2)
|
| 30 |
+
borderColie = np.round(float(prediction[0][4]), 2)
|
| 31 |
+
bostonTerrier = np.round(float(prediction[0][5]), 2)
|
| 32 |
+
chineseCrested = np.round(float(prediction[0][6]), 2)
|
| 33 |
+
cocker = np.round(float(prediction[0][7]), 2)
|
| 34 |
+
corgi = np.round(float(prediction[0][8]), 2)
|
| 35 |
+
dingo = np.round(float(prediction[0][9]), 2)
|
| 36 |
+
frenchBulldog = np.round(float(prediction[0][10]), 2)
|
| 37 |
+
germanShepard = np.round(float(prediction[0][11]), 2)
|
| 38 |
+
goldenRetriever = np.round(float(prediction[0][12]), 2)
|
| 39 |
+
pitBull = np.round(float(prediction[0][13]), 2)
|
| 40 |
+
rottweiler = np.round(float(prediction[0][14]), 2)
|
| 41 |
+
irishSpaniel = np.round(float(prediction[0][15]), 2)
|
| 42 |
+
labrador = np.round(float(prediction[0][16]), 2)
|
| 43 |
+
maltese = np.round(float(prediction[0][17]), 2)
|
| 44 |
+
newfoundland = np.round(float(prediction[0][18]), 2)
|
| 45 |
+
pomeranian = np.round(float(prediction[0][19]), 2)
|
| 46 |
+
poodle = np.round(float(prediction[0][20]), 2)
|
| 47 |
+
rhodesian = np.round(float(prediction[0][21]), 2)
|
| 48 |
+
saintBernard = np.round(float(prediction[0][22]), 2)
|
| 49 |
+
schnauzer = np.round(float(prediction[0][23]), 2)
|
| 50 |
+
scotchTerrier = np.round(float(prediction[0][24]), 2)
|
| 51 |
+
sharPei = np.round(float(prediction[0][25]), 2)
|
| 52 |
+
shibaInu = np.round(float(prediction[0][26]), 2)
|
| 53 |
+
siberianHusky = np.round(float(prediction[0][27]), 2)
|
| 54 |
+
yorkie = np.round(float(prediction[0][28]), 2)
|
| 55 |
+
|
| 56 |
|
| 57 |
+
return {'Afghan': afghan, 'African Wild Dog': africanWildDog, 'Beagle': beagle, 'Blenheim': blenheim,
|
| 58 |
+
'Border Collie': borderColie, 'Boston Terrier': bostonTerrier, 'Chinese Crested': chineseCrested, 'Cocker': cocker,
|
| 59 |
+
'Corgi': corgi, 'Dingo': dingo, 'French Bulldog': frenchBulldog, 'German Shepard': germanShepard,
|
| 60 |
+
'GoldenRetriever': goldenRetriever, 'Pit Bull': pitBull, 'Rottweiler': rottweiler, 'Irish Spaniel': irishSpaniel,
|
| 61 |
+
'Labrador': labrador, 'Maltese': maltese, 'Newfoundland': newfoundland, 'Pomeranian': pomeranian,
|
| 62 |
+
'Poodle': poodle, 'Rhodesian': rhodesian, 'Saint Bernard': saintBernard, 'Schnauzer': schnauzer,
|
| 63 |
+
'Scotch Terrier': scotchTerrier, 'Shar Pei': sharPei, 'Shiba Inu': shibaInu, 'Siberian Husky': siberianHusky,
|
| 64 |
+
'Yorkie': yorkie}
|
| 65 |
|
| 66 |
|
| 67 |
input_image = gr.Image()
|