Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
learn = load_learner('learn.pkl')
|
| 6 |
+
|
| 7 |
+
categories = ('Polvo', 'Lula')
|
| 8 |
+
|
| 9 |
+
# Function to classify the image using the selected model
|
| 10 |
+
def classify_image(img):
|
| 11 |
+
_, _, probs = learn.predict(img)
|
| 12 |
+
return dict(zip(categories, map(float, probs)))
|
| 13 |
+
|
| 14 |
+
# Define input and output components
|
| 15 |
+
image = gr.Image()
|
| 16 |
+
label = gr.Label()
|
| 17 |
+
|
| 18 |
+
# Examples for testing
|
| 19 |
+
examples = ['Squid.jpg','Octopus.jpg','Lula.jpeg','Polvo.jpg','Graploct.png','Jelly.png']
|
| 20 |
+
|
| 21 |
+
# Create Gradio Interface
|
| 22 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 23 |
+
|
| 24 |
+
# Launch the Gradio interface
|
| 25 |
+
intf.launch(inline=False)
|