Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,26 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# prompt: gradio image 鍒嗙被
|
2 |
+
import fastai
|
3 |
+
from fastai.vision import *
|
4 |
import gradio as gr
|
5 |
|
6 |
+
# Load the model
|
7 |
+
model = load_learner("model.pkl")
|
8 |
|
9 |
+
# Define an image classification function
|
10 |
+
def classify_image(image):
|
11 |
+
# Preprocess the image
|
12 |
+
image = PILImage.create(image).resize((192, 192))
|
13 |
+
|
14 |
+
# Make a prediction
|
15 |
+
prediction = model.predict(image)[0]
|
16 |
+
|
17 |
+
# Return the prediction
|
18 |
+
return {prediction: 1.0}
|
19 |
+
|
20 |
+
# Create the Gradio interface
|
21 |
+
image_input = gr.Image()
|
22 |
+
label_output = gr.Label(num_top_classes=3)
|
23 |
+
interface = gr.Interface(fn=classify_image, inputs=image_input, outputs=label_output)
|
24 |
+
|
25 |
+
# Launch the interface
|
26 |
+
interface.launch()
|