Spaces:
Build error
Build error
Commit ·
3af03af
1
Parent(s): 249513d
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,8 +48,22 @@ def normalize_2d(matrix):
|
|
| 48 |
def detect(imagepath):
|
| 49 |
|
| 50 |
pix=model.predict(imagepath, confidence=40, overlap=30)
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
def predict(img):
|
| 55 |
|
|
@@ -93,7 +107,7 @@ inputs_image = [
|
|
| 93 |
]
|
| 94 |
|
| 95 |
outputs_image = [
|
| 96 |
-
gr.components.Image(type="
|
| 97 |
]
|
| 98 |
|
| 99 |
# Create the Gradio demo
|
|
|
|
| 48 |
def detect(imagepath):
|
| 49 |
|
| 50 |
pix=model.predict(imagepath, confidence=40, overlap=30)
|
| 51 |
+
pix=np.array(pix)
|
| 52 |
+
img=cv2.imread(imagepath)
|
| 53 |
+
|
| 54 |
+
for a,b,c,d,_,_,_,_ in pix.items():
|
| 55 |
+
cv2.rectangle(
|
| 56 |
+
img,
|
| 57 |
+
(a,b),
|
| 58 |
+
(a+c,b+d),
|
| 59 |
+
color=(0, 0, 255),
|
| 60 |
+
thickness=2,
|
| 61 |
+
lineType=cv2.LINE_AA)
|
| 62 |
+
|
| 63 |
+
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
|
| 68 |
def predict(img):
|
| 69 |
|
|
|
|
| 107 |
]
|
| 108 |
|
| 109 |
outputs_image = [
|
| 110 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
| 111 |
]
|
| 112 |
|
| 113 |
# Create the Gradio demo
|