Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,6 @@ from fastbook import PILImage
|
|
| 6 |
# Load the pretrained FastAI model
|
| 7 |
learn = load_learner("model.pkl")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
def classify_image(image):
|
| 12 |
# Convert Gradio input to PIL Image
|
| 13 |
image_pil = Image.fromarray(image.astype('uint8'), 'RGB')
|
|
@@ -18,12 +16,12 @@ def classify_image(image):
|
|
| 18 |
# Perform inference
|
| 19 |
classification,_,probs = learn.predict(PILImage.create('temp_image.jpg'))
|
| 20 |
|
| 21 |
-
return f"
|
| 22 |
|
| 23 |
# Define Gradio interface
|
| 24 |
-
inputs = gr.
|
| 25 |
-
|
| 26 |
-
interface = gr.Interface(fn=classify_image, inputs=inputs, outputs=
|
| 27 |
|
| 28 |
# Run the interface
|
| 29 |
interface.launch(share=True)
|
|
|
|
| 6 |
# Load the pretrained FastAI model
|
| 7 |
learn = load_learner("model.pkl")
|
| 8 |
|
|
|
|
|
|
|
| 9 |
def classify_image(image):
|
| 10 |
# Convert Gradio input to PIL Image
|
| 11 |
image_pil = Image.fromarray(image.astype('uint8'), 'RGB')
|
|
|
|
| 16 |
# Perform inference
|
| 17 |
classification,_,probs = learn.predict(PILImage.create('temp_image.jpg'))
|
| 18 |
|
| 19 |
+
return f"This is a {classification}"
|
| 20 |
|
| 21 |
# Define Gradio interface
|
| 22 |
+
inputs = gr.Image()
|
| 23 |
+
label = gr.Textbox(label="Prediction")
|
| 24 |
+
interface = gr.Interface(fn=classify_image, inputs=inputs, outputs=label)
|
| 25 |
|
| 26 |
# Run the interface
|
| 27 |
interface.launch(share=True)
|