AlbML commited on
Commit
0d7f589
·
1 Parent(s): 346cadb
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ # Define the main prediction function:
5
+ learn = load_learner('./model_params/planet_cls_1.pkl')
6
+ labels = learn.dls.vocab
7
+ def planet_classifier_predict(img) -> str:
8
+ img = PILImage.create(img)
9
+ _, _, probs = learn.predict(img)
10
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
11
+
12
+
13
+ if __name__ == "__main__":
14
+ # General web app params:
15
+ title = "Planet Classifier Demo"
16
+ description = "Let's say you want to classify a picture if it is one of the 9 planets: \
17
+ Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune. \
18
+ You can do it using this awesome tool!!!! Try it :)"
19
+ article = "<p style='text-align: center'><a href='https://www.tanishq.ai/blog/posts/2021-11-16-gradio-huggingface.html' target='_blank'>The main source of inspiration :) </a></p>"
20
+ examples = ['./example_images/saturn.jpeg', './example_images/car.jpeg']
21
+ interpretation = 'default'
22
+ enable_queue = True
23
+ inputs = "image"
24
+ outputs = "label"
25
+ # The main app interface:
26
+ gr.Interface(
27
+ fn=planet_classifier_predict,
28
+ inputs=inputs,
29
+ outputs=outputs,
30
+ title=title,
31
+ description=description,
32
+ article=article,
33
+ examples=examples,
34
+ ).launch()
example_images/car.jpeg ADDED

Git LFS Details

  • SHA256: 6a4905ae8f3d10638c8dae49a1e7a7a316bee9ca98dac0d7753458aa699cb207
  • Pointer size: 130 Bytes
  • Size of remote file: 13.1 kB
example_images/saturn.jpeg ADDED

Git LFS Details

  • SHA256: 173e84a304a87d1ed02371d1f8883828f0cea9eacd3531b3f5a438b10097c530
  • Pointer size: 129 Bytes
  • Size of remote file: 5.92 kB
model_params/planet_cls_1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ecb82741ed90a93ac87fb4e57dfd2a2c1895f210620feb538c7f22361d1f7dc3
3
+ size 46996647
planet_classifier.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ fastai