Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,27 +25,28 @@ def detect_fruit(image, weight: float):
|
|
25 |
|
26 |
# Проверка на наличие детекций
|
27 |
if len(detections) == 0:
|
28 |
-
return image
|
29 |
|
30 |
result_np_image = detections[0].plot()
|
31 |
result_np_image = cv2.cvtColor(result_np_image, cv2.COLOR_BGR2RGB)
|
32 |
|
33 |
-
detected_fruit = None
|
34 |
|
35 |
-
for det in detections.xyxy[0]: # Предполагается, что вы используете ультралайтики и доступ к детекциям
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
if not detected_fruit:
|
42 |
-
|
43 |
|
44 |
-
fruit_name = fruits_data[detected_fruit]["name"]
|
45 |
-
price_per_kg = fruits_data[detected_fruit]["price_per_kg"]
|
46 |
-
total_price = round(price_per_kg * weight, 2)
|
|
|
47 |
|
48 |
-
return result_np_image, fruit_name, weight, total_price
|
49 |
|
50 |
# =========================== ЧЕК ============================
|
51 |
# def create_receipt(fruit_name, weight, total_price):
|
@@ -89,7 +90,7 @@ image_output = gr.Image(label="Распознанный фрукт", type="numpy
|
|
89 |
|
90 |
gr.Interface(
|
91 |
fn=gradio_interface,
|
92 |
-
inputs=[image_input
|
93 |
outputs=[image_output],
|
94 |
# outputs=[image_output, receipt_output],
|
95 |
title="Определение плода и создание чека",
|
|
|
25 |
|
26 |
# Проверка на наличие детекций
|
27 |
if len(detections) == 0:
|
28 |
+
return image
|
29 |
|
30 |
result_np_image = detections[0].plot()
|
31 |
result_np_image = cv2.cvtColor(result_np_image, cv2.COLOR_BGR2RGB)
|
32 |
|
33 |
+
# detected_fruit = None
|
34 |
|
35 |
+
# for det in detections.xyxy[0]: # Предполагается, что вы используете ультралайтики и доступ к детекциям
|
36 |
+
# label = model.names[int(det[5])] # название фрукта
|
37 |
+
# if label in fruits_data:
|
38 |
+
# detected_fruit = label
|
39 |
+
# break
|
40 |
|
41 |
+
# if not detected_fruit:
|
42 |
+
# return result_np_image, None, None, None
|
43 |
|
44 |
+
# fruit_name = fruits_data[detected_fruit]["name"]
|
45 |
+
# price_per_kg = fruits_data[detected_fruit]["price_per_kg"]
|
46 |
+
# total_price = round(price_per_kg * weight, 2)
|
47 |
+
return result_np_image
|
48 |
|
49 |
+
# return result_np_image, fruit_name, weight, total_price
|
50 |
|
51 |
# =========================== ЧЕК ============================
|
52 |
# def create_receipt(fruit_name, weight, total_price):
|
|
|
90 |
|
91 |
gr.Interface(
|
92 |
fn=gradio_interface,
|
93 |
+
inputs=[image_input],
|
94 |
outputs=[image_output],
|
95 |
# outputs=[image_output, receipt_output],
|
96 |
title="Определение плода и создание чека",
|