Upload 9 files
Browse files- .gitattributes +1 -0
- app.py +41 -0
- images/ce (1).jpg +0 -0
- images/ce (2).jpg +0 -0
- images/cv (2).png +3 -0
- images/cv (4).png +0 -0
- images/ncvc (1).png +0 -0
- images/ncvc (5).png +0 -0
- images/nncv (2).png +0 -0
- images/nncv (4).png +0 -0
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* 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 |
fungi-model_transferlearning_xception.keras 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 |
fungi-model_transferlearning_xception.keras filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
images/cv[[:space:]](2).png filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
model_path = "fungi-model_transferlearning_xception.keras"
|
| 7 |
+
model = tf.keras.models.load_model(model_path)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def predict_fungi(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 |
+
prediction = model.predict(image)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# Convert the probabilities to rounded values
|
| 22 |
+
prediction = np.round(prediction, 2)
|
| 23 |
+
|
| 24 |
+
# Separate the probabilities for each class
|
| 25 |
+
p_ediblemushroomsporocarp = prediction[0][0]
|
| 26 |
+
p_ediblesporocarp = prediction[0][1]
|
| 27 |
+
p_poisonousmushroomsporocarp = prediction[0][2]
|
| 28 |
+
p_poisonoussporocarp = prediction[0][2]
|
| 29 |
+
|
| 30 |
+
return {'Edible Mushroom Sporocarp': p_ediblemushroomsporocarp, 'Edible Sporocarp': p_ediblesporocarp, 'Poisonous Mushroom Sporocarp': p_poisonousmushroomsporocarp, 'Poisonous Sporocarp': p_poisonoussporocarp}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
input_image = gr.Image()
|
| 34 |
+
iface = gr.Interface(
|
| 35 |
+
fn=predict_fungi,
|
| 36 |
+
inputs=input_image,
|
| 37 |
+
outputs=gr.Label(),
|
| 38 |
+
examples=["images/ce (1).jpg", "images/ce (2).jpg", "images/ncvc (1).png", "images/ncvc (5).png", "images/nncv (2).png", "images/nncv (4).png", "images/cv (2).png", "images/cv (4).png"],
|
| 39 |
+
description="TEST.")
|
| 40 |
+
|
| 41 |
+
iface.launch()
|
images/ce (1).jpg
ADDED
|
images/ce (2).jpg
ADDED
|
images/cv (2).png
ADDED
|
Git LFS Details
|
images/cv (4).png
ADDED
|
images/ncvc (1).png
ADDED
|
images/ncvc (5).png
ADDED
|
images/nncv (2).png
ADDED
|
images/nncv (4).png
ADDED
|