Spaces:
Sleeping
Sleeping
Commit
·
b33e657
1
Parent(s):
28fd108
Add comments
Browse files
app.py
CHANGED
@@ -114,6 +114,7 @@ def process_image(img_path):
|
|
114 |
# Remove non alphanumeric characters
|
115 |
image_path = re.sub(r"\W+", "", img_path)
|
116 |
image_path = str(datetime.now()) + ".png"
|
|
|
117 |
|
118 |
# Join to directory path
|
119 |
inf_image = os.path.join("inference", img_path)
|
@@ -157,7 +158,7 @@ def process_image(img_path):
|
|
157 |
|
158 |
return np_image
|
159 |
|
160 |
-
|
161 |
with open("cat_to_name.json", "r") as f:
|
162 |
cat_to_name = json.load(f)
|
163 |
|
@@ -225,7 +226,7 @@ def predict(image_path, model=model, category_names=cat_to_name, topk=5):
|
|
225 |
|
226 |
return fig
|
227 |
|
228 |
-
|
229 |
gr.Interface(
|
230 |
predict,
|
231 |
inputs=gr.inputs.Image(label="Upload a flower image", type="filepath"),
|
|
|
114 |
# Remove non alphanumeric characters
|
115 |
image_path = re.sub(r"\W+", "", img_path)
|
116 |
image_path = str(datetime.now()) + ".png"
|
117 |
+
image_path = image_path.replace(" ", "_")
|
118 |
|
119 |
# Join to directory path
|
120 |
inf_image = os.path.join("inference", img_path)
|
|
|
158 |
|
159 |
return np_image
|
160 |
|
161 |
+
# Category to name mapping
|
162 |
with open("cat_to_name.json", "r") as f:
|
163 |
cat_to_name = json.load(f)
|
164 |
|
|
|
226 |
|
227 |
return fig
|
228 |
|
229 |
+
# Gradio Interface
|
230 |
gr.Interface(
|
231 |
predict,
|
232 |
inputs=gr.inputs.Image(label="Upload a flower image", type="filepath"),
|