Spaces:
Build error
Build error
Rename app.py to app
Browse files- app.py → app +7 -8
app.py → app
RENAMED
|
@@ -1,18 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import load_learner, PILImage
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
| 5 |
learn = load_learner('export.pkl')
|
| 6 |
|
| 7 |
-
# Define the prediction function
|
| 8 |
def predict(img):
|
| 9 |
-
img = PILImage.create(img)
|
| 10 |
-
pred, pred_idx, probs = learn.predict(img)
|
| 11 |
-
labels = learn.dls.vocab
|
| 12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 13 |
|
| 14 |
-
# Define the Gradio interface
|
| 15 |
interface = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3))
|
| 16 |
-
|
| 17 |
-
# Launch the interface
|
| 18 |
interface.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import load_learner, PILImage
|
| 3 |
|
| 4 |
+
# Import any custom code here (if needed)
|
| 5 |
+
# Example:
|
| 6 |
+
# from your_module import CustomTransform, CustomModel
|
| 7 |
+
|
| 8 |
learn = load_learner('export.pkl')
|
| 9 |
|
|
|
|
| 10 |
def predict(img):
|
| 11 |
+
img = PILImage.create(img)
|
| 12 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 13 |
+
labels = learn.dls.vocab
|
| 14 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 15 |
|
|
|
|
| 16 |
interface = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3))
|
|
|
|
|
|
|
| 17 |
interface.launch(share=True)
|