flobbit commited on
Commit
e60702d
1 Parent(s): c4a6804

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +28 -0
  2. food_model.pkl +3 -0
  3. requirements.txt +3 -0
  4. steak.jpg +0 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
2
+
3
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
4
+
5
+ # Cell
6
+ from fastai.vision.all import *
7
+ import gradio as gr
8
+ import timm
9
+
10
+ # Cell
11
+ learn = load_learner('food_model.pkl')
12
+
13
+ # Cell
14
+ categories = learn.dls.vocab
15
+
16
+ def classify_image(img):
17
+ pred,idx,probs = learn.predict(img)
18
+ return dict(zip(categories, map(float,probs)))
19
+
20
+ # Cell
21
+ image = gr.inputs.Image(shape=(192, 192))
22
+ label = gr.outputs.Label()
23
+ examples = ['steak.jpg', ]
24
+
25
+ # Cell
26
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples,
27
+ title="Food Classifier", description="Trained on only URLs.FOODS image set. Provide an image or select from one below.")
28
+ intf.launch()
food_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50f9d9431171e2b6ae826aba85126852263aea09492ea80574de2e0bcf25a9ba
3
+ size 89450226
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch <1.12
2
+ fastai>2.6.1
3
+ timm
steak.jpg ADDED