Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,8 +33,6 @@ def detect_fruit(image):
|
|
33 |
detected_fruit = None
|
34 |
|
35 |
for det in detections:
|
36 |
-
print('kekkekek')
|
37 |
-
print(det.boxes.cls)
|
38 |
label = model.names[int(det.boxes.cls)] # название фрукта
|
39 |
if label in fruits_data:
|
40 |
detected_fruit = label
|
@@ -44,7 +42,7 @@ def detect_fruit(image):
|
|
44 |
|
45 |
# =========================== ЧЕК ============================
|
46 |
def create_receipt(detected_fruit, weight):
|
47 |
-
data = fruits_data[detected_fruit]
|
48 |
fruit_name = data['name']
|
49 |
price = data['price_per_kg']
|
50 |
total_price = round(price * weight, 2)
|
@@ -62,10 +60,7 @@ def create_receipt(detected_fruit, weight):
|
|
62 |
draw.text((10, 110), f"Цена за кг: {price} руб.", fill="black", font=font)
|
63 |
draw.text((10, 140), f"Сумма: {total_price} руб.", fill="black", font=font)
|
64 |
|
65 |
-
|
66 |
-
receipt_img.save(output, format="PNG")
|
67 |
-
output.seek(0)
|
68 |
-
return output.getvalue()
|
69 |
|
70 |
# ======================= ИНТЕРФЕЙС ============================
|
71 |
def gradio_interface(image, weight):
|
|
|
33 |
detected_fruit = None
|
34 |
|
35 |
for det in detections:
|
|
|
|
|
36 |
label = model.names[int(det.boxes.cls)] # название фрукта
|
37 |
if label in fruits_data:
|
38 |
detected_fruit = label
|
|
|
42 |
|
43 |
# =========================== ЧЕК ============================
|
44 |
def create_receipt(detected_fruit, weight):
|
45 |
+
data = fruits_data[detected_fruit]
|
46 |
fruit_name = data['name']
|
47 |
price = data['price_per_kg']
|
48 |
total_price = round(price * weight, 2)
|
|
|
60 |
draw.text((10, 110), f"Цена за кг: {price} руб.", fill="black", font=font)
|
61 |
draw.text((10, 140), f"Сумма: {total_price} руб.", fill="black", font=font)
|
62 |
|
63 |
+
return receipt_img
|
|
|
|
|
|
|
64 |
|
65 |
# ======================= ИНТЕРФЕЙС ============================
|
66 |
def gradio_interface(image, weight):
|