Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,24 @@ import tensorflow as tf
|
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
-
labels = ['
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
def
|
| 9 |
|
| 10 |
if uploaded_file is None:
|
| 11 |
return "No file uploaded."
|
| 12 |
|
| 13 |
-
model = tf.keras.models.load_model('
|
| 14 |
# Load the image from the file path
|
| 15 |
with Image.open(uploaded_file) as img:
|
| 16 |
img = img.resize((150, 150)).convert('RGB') # Convert image to RGB
|
|
@@ -24,11 +34,11 @@ def predict_pokemon_type(uploaded_file):
|
|
| 24 |
|
| 25 |
# Define the Gradio interface
|
| 26 |
iface = gr.Interface(
|
| 27 |
-
fn=
|
| 28 |
inputs=gr.File(label="Upload File"), # File upload widget
|
| 29 |
outputs="text", # Output type
|
| 30 |
-
title="
|
| 31 |
-
description="Upload a picture of a
|
| 32 |
)
|
| 33 |
|
| 34 |
# Launch the interface
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
+
labels = ['barrel_jellyfish',
|
| 7 |
+
|
| 8 |
+
'blue_jellyfish',
|
| 9 |
+
|
| 10 |
+
'compass_jellyfish'
|
| 11 |
+
|
| 12 |
+
'lions_mane_jellyfish',
|
| 13 |
+
|
| 14 |
+
'mauve_stinger_jellyfish',
|
| 15 |
+
|
| 16 |
+
'Moon_jellyfish']
|
| 17 |
|
| 18 |
+
def predict_jellyfish_type(uploaded_file):
|
| 19 |
|
| 20 |
if uploaded_file is None:
|
| 21 |
return "No file uploaded."
|
| 22 |
|
| 23 |
+
model = tf.keras.models.load_model('Jellyfish_InceptionResNetV2_transferlearning.keras')
|
| 24 |
# Load the image from the file path
|
| 25 |
with Image.open(uploaded_file) as img:
|
| 26 |
img = img.resize((150, 150)).convert('RGB') # Convert image to RGB
|
|
|
|
| 34 |
|
| 35 |
# Define the Gradio interface
|
| 36 |
iface = gr.Interface(
|
| 37 |
+
fn=predict_jellyfish_type, # Function to process the input
|
| 38 |
inputs=gr.File(label="Upload File"), # File upload widget
|
| 39 |
outputs="text", # Output type
|
| 40 |
+
title="Jellifish Classifier", # Title of the interface
|
| 41 |
+
description="Upload a picture of a Jellyfish (preferably barrel, blue, compass, lions mane, mauve stinger, Moon)" # Description of the interface
|
| 42 |
)
|
| 43 |
|
| 44 |
# Launch the interface
|