Spaces:
Runtime error
Runtime error
pyesonekyaw
commited on
Commit
•
b0d59a1
1
Parent(s):
bd7d1bb
added theming
Browse files- __pycache__/app.cpython-38.pyc +0 -0
- app.py +69 -6
__pycache__/app.cpython-38.pyc
ADDED
Binary file (6.4 kB). View file
|
|
app.py
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import from_pretrained_fastai
|
3 |
import os
|
|
|
|
|
|
|
|
|
|
|
4 |
os.environ["HF_ENDPOINT"] = "https://huggingface.co"
|
5 |
|
6 |
materials_model = from_pretrained_fastai("pyesonekyaw/recycletree_materials")
|
@@ -33,7 +38,7 @@ material_num_name_dict = {
|
|
33 |
plastic_item_num_dict = {
|
34 |
"CD Disk": ["Yes", "Nil"],
|
35 |
"Straw": ["No, dispose as general waste","Nil"],
|
36 |
-
"Plastic Bag": ["Yes, if they are not oxo- and bio- degradable bags", "Contaminated with food waste/liquid waste/other forms of waste "],
|
37 |
"Clothes Hanger": ["Yes", "Made up of more than one plastic, if unsure, just dispose as normal waste "],
|
38 |
"Plastic Container or Bottle": ["Yes", "When they are not emptied or not rinsed "],
|
39 |
"Disposable Cutlery": ["No, dispose as general waste", "Nil"],
|
@@ -52,9 +57,9 @@ metal_item_num_dict = {
|
|
52 |
"Metal Can or Container": ["Yes","If there is any residue "]
|
53 |
}
|
54 |
others_item_num_dict = {
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
}
|
59 |
paper_item_num_dict = {
|
60 |
"Beverage Carton": ["Yes, rinsed and flattened","Nil"],
|
@@ -71,7 +76,65 @@ paper_item_num_dict = {
|
|
71 |
"Tissue Paper": ["No, dispose as general waste","Nil"]
|
72 |
}
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
def predict_image(inp):
|
77 |
"""
|
@@ -121,7 +184,7 @@ def predict_image(inp):
|
|
121 |
raise Exception("Invalid file format! Please only upload .jpg or .png files!")
|
122 |
|
123 |
|
124 |
-
with gr.Blocks(title="Trash Classification", css="#custom_header {min-height: 3rem} #custom_title {min-height: 3rem; text-align: center}") as demo:
|
125 |
gr.Markdown("# Check whether your trash is recyclable or not!", elem_id="custom_title")
|
126 |
gr.Markdown("Gradio Inference interface for classification of trash and recyclables. To use it, simply upload your image, or click one of the examples to load them. Images uploaded are never saved or indexed.", elem_id="custom_title")
|
127 |
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import from_pretrained_fastai
|
3 |
import os
|
4 |
+
from __future__ import annotations
|
5 |
+
from typing import Iterable
|
6 |
+
from gradio.themes.base import Base
|
7 |
+
from gradio.themes.utils import colors, fonts, sizes
|
8 |
+
|
9 |
os.environ["HF_ENDPOINT"] = "https://huggingface.co"
|
10 |
|
11 |
materials_model = from_pretrained_fastai("pyesonekyaw/recycletree_materials")
|
|
|
38 |
plastic_item_num_dict = {
|
39 |
"CD Disk": ["Yes", "Nil"],
|
40 |
"Straw": ["No, dispose as general waste","Nil"],
|
41 |
+
"Plastic Bag": ["Yes, if they are not oxo- and bio- degradable bags", "Contaminated with food waste/liquid waste/other forms of waste. Please refer to RecycleHowAh for more information"],
|
42 |
"Clothes Hanger": ["Yes", "Made up of more than one plastic, if unsure, just dispose as normal waste "],
|
43 |
"Plastic Container or Bottle": ["Yes", "When they are not emptied or not rinsed "],
|
44 |
"Disposable Cutlery": ["No, dispose as general waste", "Nil"],
|
|
|
57 |
"Metal Can or Container": ["Yes","If there is any residue "]
|
58 |
}
|
59 |
others_item_num_dict = {
|
60 |
+
"battery": ["Battery","No, rechargeable batteries can be recycled through specific collection points (e-waste collection)", "Nil"],
|
61 |
+
"electronic_waste": ["Electronic Waste","Can be recycled through specific collection points (e-waste collection). Please refer to RecycleHowAh for more information"],
|
62 |
+
"stationery": ["Stationery","No, donate if can be reused"]
|
63 |
}
|
64 |
paper_item_num_dict = {
|
65 |
"Beverage Carton": ["Yes, rinsed and flattened","Nil"],
|
|
|
76 |
"Tissue Paper": ["No, dispose as general waste","Nil"]
|
77 |
}
|
78 |
|
79 |
+
class Seafoam(Base):
|
80 |
+
def __init__(
|
81 |
+
self,
|
82 |
+
*,
|
83 |
+
primary_hue: colors.Color | str = colors.emerald,
|
84 |
+
secondary_hue: colors.Color | str = colors.teal,
|
85 |
+
neutral_hue: colors.Color | str = colors.teal,
|
86 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
87 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
88 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
89 |
+
font: fonts.Font
|
90 |
+
| str
|
91 |
+
| Iterable[fonts.Font | str] = (
|
92 |
+
fonts.GoogleFont("Quicksand"),
|
93 |
+
"ui-sans-serif",
|
94 |
+
"sans-serif",
|
95 |
+
),
|
96 |
+
font_mono: fonts.Font
|
97 |
+
| str
|
98 |
+
| Iterable[fonts.Font | str] = (
|
99 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
100 |
+
"ui-monospace",
|
101 |
+
"monospace",
|
102 |
+
),
|
103 |
+
):
|
104 |
+
super().__init__(
|
105 |
+
primary_hue=primary_hue,
|
106 |
+
secondary_hue=secondary_hue,
|
107 |
+
neutral_hue=neutral_hue,
|
108 |
+
spacing_size=spacing_size,
|
109 |
+
radius_size=radius_size,
|
110 |
+
text_size=text_size,
|
111 |
+
font=font,
|
112 |
+
font_mono=font_mono,
|
113 |
+
)
|
114 |
+
|
115 |
+
super().set(
|
116 |
+
body_background_fill="linear-gradient(45deg, *primary_200, *primary_200 10px, *primary_50 10px, *primary_50 20px)",
|
117 |
+
body_background_fill_dark="linear-gradient(45deg, *primary_200, *primary_200 10px, *primary_50 10px, *primary_50 20px)",
|
118 |
+
stat_background_fill_dark="linear-gradient(to right, *primary_400, *primary_200)",
|
119 |
+
error_background_fill_dark=f"linear-gradient(to right, {colors.red.c100}, *background_fill_secondary)",
|
120 |
+
button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
|
121 |
+
button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
|
122 |
+
button_primary_background_fill_hover_dark="linear-gradient(90deg, *primary_200, *secondary_300)",
|
123 |
+
button_primary_text_color="white",
|
124 |
+
button_primary_background_fill_dark="linear-gradient(90deg, *primary_300, *secondary_400)",
|
125 |
+
slider_color="*secondary_300",
|
126 |
+
slider_color_dark="*secondary_300",
|
127 |
+
block_title_text_weight="600",
|
128 |
+
block_border_width="3px",
|
129 |
+
block_shadow="*shadow_drop_lg",
|
130 |
+
button_shadow="*shadow_drop_lg",
|
131 |
+
button_large_padding="32px",
|
132 |
+
)
|
133 |
+
for k in list(self.__dict__.keys()):
|
134 |
+
if '_dark' in k:
|
135 |
+
setattr(self,k,None)
|
136 |
+
|
137 |
+
seafoam = Seafoam()
|
138 |
|
139 |
def predict_image(inp):
|
140 |
"""
|
|
|
184 |
raise Exception("Invalid file format! Please only upload .jpg or .png files!")
|
185 |
|
186 |
|
187 |
+
with gr.Blocks(title="Trash Classification", css="#custom_header {min-height: 3rem} #custom_title {min-height: 3rem; text-align: center}", theme=seafoam) as demo:
|
188 |
gr.Markdown("# Check whether your trash is recyclable or not!", elem_id="custom_title")
|
189 |
gr.Markdown("Gradio Inference interface for classification of trash and recyclables. To use it, simply upload your image, or click one of the examples to load them. Images uploaded are never saved or indexed.", elem_id="custom_title")
|
190 |
|