Abdullah commited on
Commit
0da441e
1 Parent(s): 386ee30

added files

Browse files
Files changed (10) hide show
  1. app.py +24 -0
  2. ch.jpg +0 -0
  3. chic.jpg +0 -0
  4. colo.jpg +0 -0
  5. great.jpg +0 -0
  6. machu.jpg +0 -0
  7. model.pkl +3 -0
  8. petra.jpg +0 -0
  9. requirements.txt +4 -0
  10. taj.jpg +0 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['learn', 'categories', 'classifier', 'image', 'label', 'examples', 'intf']
2
+
3
+
4
+
5
+ from fastcore.all import *
6
+ from fastdownload import download_url
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ learn = load_learner('model.pkl')
11
+
12
+ categories = ('Great Wall of China', 'Chichén Itzá', 'Petra', 'Machu Picchu', 'Christ the Redeemer', 'Colosseum', 'Taj Mahal')
13
+
14
+ def classifier(img):
15
+ pred, idx, probs = learn.predict(img)
16
+ return dict(zip(categories, map(float, probs)))
17
+
18
+
19
+ image = gr.inputs.Image(shape=(192, 192))
20
+ label = gr.outputs.Label()
21
+ examples = ['great.jpg', 'chic.jpg', 'petra.jpg', 'machu.jpg', 'ch.jpg', 'colo.jpg', 'taj.jpg']
22
+
23
+ intf = gr.Interface(fn = classifier, inputs = image, outputs = label, examples = examples)
24
+ intf.launch(inline = False)
ch.jpg ADDED
chic.jpg ADDED
colo.jpg ADDED
great.jpg ADDED
machu.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:976d9a30f5335796e89a564d8afaee423f7749fc7e02cc0144b81d8bed38a2aa
3
+ size 46967633
petra.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch <1.12
2
+ fastai>2.6.1
3
+ timm
4
+
taj.jpg ADDED