seamusbarnes commited on
Commit
5bf1b4a
·
1 Parent(s): 4496af7

added files and folders to .gitignore

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. app.py +31 -0
  3. sushi.jpg +0 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ *.pkl
2
+ venv/
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+ import glob
4
+ learn = load_learner('model.pkl')
5
+
6
+ labels = learn.dls.vocab
7
+
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ _, _, probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
+
13
+ title='Japanese Food Classifier'
14
+ description = ('Japanese food classifier trained on duckduckgo image search generated custom dataset, fastai library and fine-tuned with the resnet18 model')
15
+ article="<p style='text-align: center'><a href='https://github.com/seamusbarnes/learn-in-public/blob/main/fastai/lesson01.ipynb' target='_blank'>Trained model</a></p>"
16
+
17
+ subfolder = Path('images')
18
+ search_pattern = str(subfolder/'*.jpg')
19
+ jpg_files = glob.glob(search_pattern)
20
+
21
+ intf = gr.Interface(
22
+ fn=predict,
23
+ inputs=gr.Image(),
24
+ outputs=gr.Label(num_top_classes=10),
25
+ title=title,
26
+ description=description,
27
+ article=article,
28
+ examples=jpg_files,
29
+ examples_per_page=37
30
+ )
31
+ intf.launch()
sushi.jpg ADDED