ruidanwang commited on
Commit
558a694
verified
1 Parent(s): 3ff141b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -1,7 +1,26 @@
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello wdq -- " + name + "!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()