Aleksandra commited on
Commit
6060a8f
·
1 Parent(s): 1ac2fb5

Add app files

Browse files
Files changed (4) hide show
  1. app.py +36 -0
  2. model_trash.pkl +3 -0
  3. requirements.txt +2 -0
  4. szkl.jpg +0 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ path_model = "model_trash.pkl"
5
+ learn = load_learner(path_model)
6
+
7
+ labels = learn.dls.vocab
8
+
9
+ def predict(img):
10
+ #img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ title = "Kind of trash identifier"
15
+ description = "Simple (and not very accurate) model for identifying category of trash for recycling purposes. The model was finetuned version of resnet with 34 layers with trash dataset found on github <https://github.com/garythung/trashnet>"
16
+
17
+ path_example = r"C:\Users\AleksandraMuciek\Documents\99. Other\Sustainability\Zdjęcia z domu\szkl.jpg"
18
+ examples = [path_example]
19
+
20
+ #interpretation function
21
+ interpretation='default'
22
+
23
+ #queueing traffic
24
+ enable_queue=True
25
+
26
+
27
+
28
+ gr.Interface(fn=predict,
29
+ inputs=gr.inputs.Image(shape=(512, 512)),
30
+ outputs=gr.outputs.Label(num_top_classes=3),
31
+ title=title,
32
+ description=description,
33
+ #article=article, # I haven't created that
34
+ examples=examples,
35
+ interpretation=interpretation,
36
+ enable_queue=enable_queue).launch()
model_trash.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a347701ee5e53031321d16fbeab3d6a5e26447162c79b45ed394b0f6326e7084
3
+ size 87501919
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image
szkl.jpg ADDED