Spaces:
Runtime error
Runtime error
Initial Commit
Browse files- .ipynb_checkpoints/app-checkpoint.ipynb +0 -0
- app.ipynb +0 -0
- app.py +34 -0
- examples/madhubani.jpg +0 -0
- examples/warli.jpeg +0 -0
- model.pkl +3 -0
- requirements.txt +2 -0
.ipynb_checkpoints/app-checkpoint.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'labels', 'examples', 'add_image_label', 'predict']
|
5 |
+
|
6 |
+
# %% app.ipynb 2
|
7 |
+
import timm
|
8 |
+
from fastai.vision.all import *
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
|
12 |
+
def add_image_label(x):
|
13 |
+
names = ["gond", "kalighat", "kangra", "madhubani", "mandana", "pichwai", "warli"]
|
14 |
+
for name in names:
|
15 |
+
if name in Path(x).name:
|
16 |
+
return name
|
17 |
+
elif "kerala" in Path(x).name:
|
18 |
+
return "kerala mural"
|
19 |
+
return "unknown"
|
20 |
+
|
21 |
+
# %% app.ipynb 4
|
22 |
+
learn = load_learner("model.pkl")
|
23 |
+
|
24 |
+
# %% app.ipynb 6
|
25 |
+
labels = learn.dls.vocab
|
26 |
+
def predict(img):
|
27 |
+
img = PILImage.create(img)
|
28 |
+
pred,pred_idx,probs = learn.predict(img)
|
29 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
30 |
+
|
31 |
+
|
32 |
+
# %% app.ipynb 8
|
33 |
+
examples = ["examples//warli.jpeg", "examples//madhubani.jpg"]
|
34 |
+
gr.Interface(fn=predict, inputs=gr.Image(type="pil"), outputs=gr.Label(num_top_classes=3), examples = examples, title = "Indian Art Classifier").launch(inline=False, debug=True)
|
examples/madhubani.jpg
ADDED
examples/warli.jpeg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a5dc1e5e8331b150f490d9184bd95bedb3a0ff7238b49918e360f2b24c050b87
|
3 |
+
size 201285114
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
fastai
|