Spaces:
Sleeping
Sleeping
nakranivaibhav
commited on
Commit
·
292ee3e
1
Parent(s):
7eccfd8
Initial push
Browse files- .DS_Store +0 -0
- README.md +3 -3
- app.py +20 -0
- model.pkl +3 -0
- requirements.txt +2 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
-
title: Print
|
3 |
-
emoji:
|
4 |
colorFrom: purple
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.28.3
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
+
title: Print Type Classifier
|
3 |
+
emoji: 🔥
|
4 |
colorFrom: purple
|
5 |
+
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.28.3
|
8 |
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn_inf = load_learner('model.pkl')
|
5 |
+
|
6 |
+
features = learn_inf.dls.vocab
|
7 |
+
|
8 |
+
def predict_image(image):
|
9 |
+
pred_class, pred_idx, probs = learn_inf.predict(image)
|
10 |
+
return {str(features[i]): float(probs[i]) for i in range(len(learn_inf.dls.vocab))}
|
11 |
+
|
12 |
+
input_image = gr.inputs.Image(shape=(None, None))
|
13 |
+
output_label = gr.outputs.Label(num_top_classes=3)
|
14 |
+
|
15 |
+
gr.Interface(fn=predict_image,
|
16 |
+
inputs=input_image,
|
17 |
+
outputs=output_label,
|
18 |
+
title="Image Classifier",
|
19 |
+
description=f"Upload an image to classify it into one of the following categories: {' | '.join([f'{item}' for item in features])}",
|
20 |
+
capture_session=True).launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:223338e7345c9f0f5b35ee280104cc1029b901a81520abaae1f52b106ce72ebd
|
3 |
+
size 47019183
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio == 3.28.3
|
2 |
+
fastai == 2.7.12
|