Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,17 +5,14 @@ from PIL import Image, ImageDraw, ImageFont
|
|
5 |
from io import BytesIO
|
6 |
import json
|
7 |
import cv2
|
8 |
-
from pathlib import Path
|
9 |
from ultralytics import YOLO
|
10 |
|
11 |
# ======================= МОДЕЛЬ ===================================
|
12 |
-
model_name = "yolov11m_best.pt"
|
13 |
-
model_path = Path(__file__).with_name(model_name)
|
14 |
model = YOLO("yolov11m_best.pt")
|
15 |
|
16 |
# ================== ЧТЕНИЕ НАЗВАНИЙ И ЦЕН =======================
|
17 |
-
|
18 |
-
|
19 |
|
20 |
# =========================== ДЕТЕКЦИЯ ПЛОДА ============================
|
21 |
def detect_fruit(image):
|
@@ -86,9 +83,18 @@ def gradio_interface(image):
|
|
86 |
# receipt = create_receipt(fruit_name, weight, total_price)
|
87 |
# return image, receipt
|
88 |
|
89 |
-
image_input = gr.Image(
|
|
|
|
|
|
|
|
|
90 |
# weight_input = gr.Number(label="Вес (кг)")
|
91 |
-
image_output = gr.Image(
|
|
|
|
|
|
|
|
|
|
|
92 |
# receipt_output = gr.Image(label="Чек", type="numpy")
|
93 |
|
94 |
gr.Interface(
|
|
|
5 |
from io import BytesIO
|
6 |
import json
|
7 |
import cv2
|
|
|
8 |
from ultralytics import YOLO
|
9 |
|
10 |
# ======================= МОДЕЛЬ ===================================
|
|
|
|
|
11 |
model = YOLO("yolov11m_best.pt")
|
12 |
|
13 |
# ================== ЧТЕНИЕ НАЗВАНИЙ И ЦЕН =======================
|
14 |
+
with open('Fruit_Veggies_Price.json', 'r', encoding='utf-8') as file:
|
15 |
+
fruits_data = json.load(file)
|
16 |
|
17 |
# =========================== ДЕТЕКЦИЯ ПЛОДА ============================
|
18 |
def detect_fruit(image):
|
|
|
83 |
# receipt = create_receipt(fruit_name, weight, total_price)
|
84 |
# return image, receipt
|
85 |
|
86 |
+
image_input = gr.Image(
|
87 |
+
label="Изображение",
|
88 |
+
width=640,
|
89 |
+
height=480
|
90 |
+
)
|
91 |
# weight_input = gr.Number(label="Вес (кг)")
|
92 |
+
image_output = gr.Image(
|
93 |
+
label="Распознанный фрукт",
|
94 |
+
type="numpy",
|
95 |
+
width=640,
|
96 |
+
height=480
|
97 |
+
)
|
98 |
# receipt_output = gr.Image(label="Чек", type="numpy")
|
99 |
|
100 |
gr.Interface(
|