Spaces:
Sleeping
Sleeping
anushka81
commited on
Commit
·
f8d7ce1
1
Parent(s):
b95c5bc
app.py add
Browse files- app.py +16 -0
- model.pkl +3 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load the trained model
|
5 |
+
learn = load_learner("model.pkl") # Ensure "model.pkl" is in the working directory
|
6 |
+
|
7 |
+
# Define a function to predict the class
|
8 |
+
def predict(img):
|
9 |
+
pred, pred_idx, probs = learn.predict(img)
|
10 |
+
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
|
11 |
+
|
12 |
+
# Create a Gradio interface
|
13 |
+
interface = gr.Interface(fn=predict, inputs=gr.Image(type="pil"), outputs=gr.Label())
|
14 |
+
|
15 |
+
# Launch the app
|
16 |
+
interface.launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ed17795ca128a737e83d695631285080fe2adc142b4b865ffe6506c6d9b8c037
|
3 |
+
size 46954859
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastai==2.7.12
|
2 |
+
torch>=2.0.0
|
3 |
+
gradio==4.22.0
|
4 |
+
huggingface_hub
|