Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,14 +16,14 @@ with open('Fruit_Veggies_Price.json', 'r', encoding='utf-8') as file:
|
|
16 |
|
17 |
# =========================== ДЕТЕКЦИЯ ПЛОДА ============================
|
18 |
def detect_fruit(image):
|
19 |
-
#
|
20 |
-
#
|
21 |
image_cv = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
|
22 |
|
23 |
-
#
|
24 |
detections = model.predict(source=image_cv, conf=0.5)
|
25 |
|
26 |
-
#
|
27 |
if len(detections) == 0:
|
28 |
return image, None
|
29 |
|
@@ -78,14 +78,14 @@ def gradio_interface(image, weight):
|
|
78 |
|
79 |
image_input = gr.Image(
|
80 |
label="Изображение",
|
81 |
-
width=
|
82 |
height=380
|
83 |
)
|
84 |
weight_input = gr.Number(label="Вес (кг)")
|
85 |
image_output = gr.Image(
|
86 |
label="Распознанный товар",
|
87 |
type="numpy",
|
88 |
-
width=
|
89 |
height=380
|
90 |
)
|
91 |
receipt_output = gr.Image(
|
|
|
16 |
|
17 |
# =========================== ДЕТЕКЦИЯ ПЛОДА ============================
|
18 |
def detect_fruit(image):
|
19 |
+
# считываем изображение
|
20 |
+
# предполагается, что image - это объект PIL Image
|
21 |
image_cv = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
|
22 |
|
23 |
+
# детекция
|
24 |
detections = model.predict(source=image_cv, conf=0.5)
|
25 |
|
26 |
+
# проверка на наличие детекций
|
27 |
if len(detections) == 0:
|
28 |
return image, None
|
29 |
|
|
|
78 |
|
79 |
image_input = gr.Image(
|
80 |
label="Изображение",
|
81 |
+
width=640,
|
82 |
height=380
|
83 |
)
|
84 |
weight_input = gr.Number(label="Вес (кг)")
|
85 |
image_output = gr.Image(
|
86 |
label="Распознанный товар",
|
87 |
type="numpy",
|
88 |
+
width=640,
|
89 |
height=380
|
90 |
)
|
91 |
receipt_output = gr.Image(
|