OsnNos commited on
Commit
56c9d7e
1 Parent(s): a37d2d5

Upload 5 files

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. app.py +31 -0
  3. forest.jpg +3 -0
  4. kinds_of_butterflies_model.pkl +3 -0
  5. monarch.jpeg +0 -0
  6. swallow.jpg +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ forest.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import * # noqa: F403
2
+ from fastai.vision.widgets import * # noqa: F403
3
+ import gradio as gr
4
+
5
+ # Load the pre-trained model, the model has been trained on the following Butterflies:
6
+ # 1. Monarch
7
+ # 2. Painted Lady
8
+ # 3. Red Admiral
9
+ # 4. Viceroy
10
+ # 5. Bronze Copper
11
+ # 6. Buckeye
12
+ # The model has an error_rate of ~6.7%
13
+ learn = load_learner('kinds_of_butterflies_model.pkl')
14
+
15
+
16
+ def classify_image(img):
17
+ pred, idx, probs = learn.predict(img)
18
+ categories = learn.dls.vocab
19
+ label_pred = widgets.Label()
20
+ label_pred.value = f'Prediction: {pred}; Probability: {probs[idx]:.04f}'
21
+ print(label_pred)
22
+ float_values = map(float, probs)
23
+ return dict(zip(categories, float_values))
24
+
25
+
26
+ image = gr.Image()
27
+ label = gr.Label()
28
+ examples = ['forest.jpg', 'monarch.jpg', 'swallow.jpg']
29
+
30
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
31
+ intf.launch(inline=False)
forest.jpg ADDED

Git LFS Details

  • SHA256: 07103b3c0f5aba163cfd6a221228c174b1b270ed57120b51898b6bbd0725e065
  • Pointer size: 132 Bytes
  • Size of remote file: 5.37 MB
kinds_of_butterflies_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c25217ab76258493ee5f2ec585568f924a0d055ce532d392d8babeb9bb46f78c
3
+ size 46980542
monarch.jpeg ADDED
swallow.jpg ADDED