guumaster commited on
Commit
f88e7a8
1 Parent(s): 1b722ab

initial version

Browse files
Files changed (8) hide show
  1. .gitignore +3 -0
  2. README.md +6 -4
  3. app.py +24 -0
  4. dragon.jpg +0 -0
  5. model-resnet18.pkl +3 -0
  6. model-resnet50.pkl +3 -0
  7. monster.jpg +0 -0
  8. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ flagged/
2
+ .ipynb_checkpoints/
3
+ .vscode/
README.md CHANGED
@@ -1,13 +1,15 @@
1
  ---
2
  title: Fastai Classifier
3
  emoji: 😻
4
- colorFrom: green
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 3.9
8
  app_file: app.py
9
- pinned: false
10
  license: apache-2.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
  title: Fastai Classifier
3
  emoji: 😻
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.9
8
  app_file: app.py
9
+ pinned: true
10
  license: apache-2.0
11
  ---
12
 
13
+ # Dragon or monster
14
+
15
+ This is a simple exercise to detect "monster" or "dragon" trained on ResNet.
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+
5
+ # Cell
6
+ learn = load_learner("model-resnet18.pkl")
7
+
8
+ # Cell
9
+ categories = learn.dls.vocab
10
+
11
+
12
+ def classify_image(img):
13
+ pred, idx, probs = learn.predict(img)
14
+ return dict(zip(categories, map(float, probs)))
15
+
16
+
17
+ # Cell
18
+ image = gr.inputs.Image(shape=(256, 256))
19
+ label = gr.outputs.Label()
20
+
21
+ examples = ["dragon.jpg", "monster.jpg"]
22
+
23
+ app = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
24
+ app.launch()
dragon.jpg ADDED
model-resnet18.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db6aa398454e8ce0d0b2bc7c36aec9c7612741b0700dbec99112fd1080c8142a
3
+ size 46963489
model-resnet50.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0d933f9b7042f0fa93319399c0db74611b7d49935cad7d5bcde76180fbe82b1
3
+ size 102884629
monster.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch <1.12
2
+ fastai>2.6.1