Spaces:
Sleeping
Sleeping
new try
Browse files
app.py
CHANGED
@@ -13,38 +13,38 @@ model.conf = 0.20 # NMS confidence threshold
|
|
13 |
|
14 |
path = [['img/test-image.jpg'], ['img/test-image-2.jpg']]
|
15 |
|
16 |
-
# def show_preds_image(image_path):
|
17 |
-
# image = cv2.imread(image_path)
|
18 |
-
# outputs = model.predict(source=image_path)
|
19 |
-
# results = outputs[0].cpu().numpy()
|
20 |
-
# for i, det in enumerate(results.boxes.xyxy):
|
21 |
-
# cv2.rectangle(
|
22 |
-
# image,
|
23 |
-
# (int(det[0]), int(det[1])),
|
24 |
-
# (int(det[2]), int(det[3])),
|
25 |
-
# color=(0, 0, 255),
|
26 |
-
# thickness=2,
|
27 |
-
# lineType=cv2.LINE_AA
|
28 |
-
# )
|
29 |
-
# return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
30 |
-
|
31 |
def show_preds_image(image_path):
|
32 |
-
|
33 |
-
|
34 |
-
results =
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
|
49 |
|
50 |
|
@@ -58,7 +58,7 @@ interface_image = gr.Interface(
|
|
58 |
fn=show_preds_image,
|
59 |
inputs=inputs_image,
|
60 |
outputs=outputs_image,
|
61 |
-
title="
|
62 |
examples=path,
|
63 |
cache_examples=False,
|
64 |
)
|
|
|
13 |
|
14 |
path = [['img/test-image.jpg'], ['img/test-image-2.jpg']]
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def show_preds_image(image_path):
|
17 |
+
image = cv2.imread(image_path)
|
18 |
+
outputs = model(source=image_path)
|
19 |
+
results = outputs[0].cpu().numpy()
|
20 |
+
for i, det in enumerate(results.boxes.xyxy):
|
21 |
+
cv2.rectangle(
|
22 |
+
image,
|
23 |
+
(int(det[0]), int(det[1])),
|
24 |
+
(int(det[2]), int(det[3])),
|
25 |
+
color=(0, 0, 255),
|
26 |
+
thickness=2,
|
27 |
+
lineType=cv2.LINE_AA
|
28 |
+
)
|
29 |
+
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
30 |
+
|
31 |
+
# def show_preds_image(image_path):
|
32 |
+
# # perform inference
|
33 |
+
# image_path = path
|
34 |
+
# results = model(image_path, size=640)
|
35 |
+
# # Results
|
36 |
+
# results.print()
|
37 |
|
38 |
+
# results.xyxy[0] # img1 predictions (tensor)
|
39 |
+
# results.pandas().xyxy[0] # img1 predictions (pandas)
|
40 |
|
41 |
+
# # parse results
|
42 |
+
# predictions = results.pred[0]
|
43 |
+
# boxes = predictions[:, :4] # x1, y1, x2, y2
|
44 |
+
# scores = predictions[:, 4]
|
45 |
+
# categories = predictions[:, 5]
|
46 |
|
47 |
+
# return results.show()
|
48 |
|
49 |
|
50 |
|
|
|
58 |
fn=show_preds_image,
|
59 |
inputs=inputs_image,
|
60 |
outputs=outputs_image,
|
61 |
+
title="Cashew Disease Detection",
|
62 |
examples=path,
|
63 |
cache_examples=False,
|
64 |
)
|