Spaces:
Runtime error
Runtime error
melindakhosasih
commited on
Commit
•
b27d380
1
Parent(s):
db8bdd5
remove img_1.jpg
Browse files- app.py +5 -4
- examples/img_1.jpg +0 -0
- examples/img_4.jpg +0 -0
app.py
CHANGED
@@ -17,7 +17,7 @@ import gradio as gr
|
|
17 |
# results.save()
|
18 |
def total_price(predicted):
|
19 |
price = 0
|
20 |
-
for name in predicted:
|
21 |
if name == "side dish":
|
22 |
price += 10
|
23 |
elif name == "purple rice" or name == "white rice" or name == "brown rice":
|
@@ -39,8 +39,9 @@ def predict(input_image):
|
|
39 |
with torch.no_grad():
|
40 |
results = model(input_image)
|
41 |
|
42 |
-
|
43 |
-
|
|
|
44 |
output_image = results.render()[0]
|
45 |
price = total_price(predicted)
|
46 |
|
@@ -53,7 +54,7 @@ with gr.Blocks() as demo:
|
|
53 |
"""
|
54 |
<h1 align="center">Group 29 - AI Cafeteria Price Evaluator</h1>
|
55 |
""")
|
56 |
-
examples = ["./examples/img_1.jpg", "./examples/img_2.jpg", "./examples/img_3.jpg"
|
57 |
# gr.Interface(inputs=["image"],outputs=["image"],fn=lambda img:model(img).render()[0]).launch()
|
58 |
gr.Interface(inputs=["image"], outputs=["image", "text"], fn=predict, examples=examples)
|
59 |
|
|
|
17 |
# results.save()
|
18 |
def total_price(predicted):
|
19 |
price = 0
|
20 |
+
for name, confidence in predicted:
|
21 |
if name == "side dish":
|
22 |
price += 10
|
23 |
elif name == "purple rice" or name == "white rice" or name == "brown rice":
|
|
|
39 |
with torch.no_grad():
|
40 |
results = model(input_image)
|
41 |
|
42 |
+
results_pd = results.pandas().xyxy[0]
|
43 |
+
name, confidence = results_pd["name"], results_pd["confidence"]
|
44 |
+
predicted = list(zip(name, confidence))
|
45 |
output_image = results.render()[0]
|
46 |
price = total_price(predicted)
|
47 |
|
|
|
54 |
"""
|
55 |
<h1 align="center">Group 29 - AI Cafeteria Price Evaluator</h1>
|
56 |
""")
|
57 |
+
examples = ["./examples/img_1.jpg", "./examples/img_2.jpg", "./examples/img_3.jpg"]
|
58 |
# gr.Interface(inputs=["image"],outputs=["image"],fn=lambda img:model(img).render()[0]).launch()
|
59 |
gr.Interface(inputs=["image"], outputs=["image", "text"], fn=predict, examples=examples)
|
60 |
|
examples/img_1.jpg
CHANGED
![]() |
![]() |
examples/img_4.jpg
DELETED
Binary file (184 kB)
|
|