Spaces:
Sleeping
Sleeping
arvindsharmaphd7
commited on
Commit
•
ed706f7
1
Parent(s):
2e0b83f
Upload 4 files
Browse files- Food.jpg +0 -0
- app.py +29 -0
- export2.pkl +3 -0
- requirement.txt +2 -0
Food.jpg
ADDED
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1l1CvBkbH9l4Acj95i78ccFHTGV9JVEGF
|
8 |
+
"""
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
from fastai.vision.all import *
|
12 |
+
import skimage
|
13 |
+
|
14 |
+
learn = load_learner('export2.pkl')
|
15 |
+
|
16 |
+
labels = learn.dls.vocab
|
17 |
+
def predict(img):
|
18 |
+
img = PILImage.create(img)
|
19 |
+
pred,pred_idx,probs = learn.predict(img)
|
20 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
21 |
+
|
22 |
+
title = "Foof_type_classifier"
|
23 |
+
description = "A food classifier trained on the food images dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
24 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
25 |
+
examples = ['Food.jpg']
|
26 |
+
interpretation='default'
|
27 |
+
enable_queue=True
|
28 |
+
|
29 |
+
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=2),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
export2.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:588f0b7fe5dc6ce86d42812f0457340f173ff169713ca7581e2b2bfdd7e421a8
|
3 |
+
size 46965967
|
requirement.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|