Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,14 +36,15 @@ async def detect_objects(images):
|
|
| 36 |
for image, detection in zip(processed_images, results_detection):
|
| 37 |
names = []
|
| 38 |
if detection:
|
|
|
|
| 39 |
for box in detection.boxes:
|
| 40 |
x1, y1, x2, y2 = map(int, box.xyxy[0])
|
| 41 |
cropped_img = image[y1:y2, x1:x2]
|
| 42 |
resized_img = cv2.resize(cropped_img, (640, 640))
|
| 43 |
resized_img = cv2.cvtColor(resized_img, cv2.COLOR_BGR2RGB)
|
| 44 |
-
|
| 45 |
results_classification = model_classification.predict(resized_img)
|
| 46 |
-
|
| 47 |
if results_classification:
|
| 48 |
top1_class = results_classification[0].probs.top1
|
| 49 |
names.append(classes[top1_class])
|
|
|
|
| 36 |
for image, detection in zip(processed_images, results_detection):
|
| 37 |
names = []
|
| 38 |
if detection:
|
| 39 |
+
i = 0
|
| 40 |
for box in detection.boxes:
|
| 41 |
x1, y1, x2, y2 = map(int, box.xyxy[0])
|
| 42 |
cropped_img = image[y1:y2, x1:x2]
|
| 43 |
resized_img = cv2.resize(cropped_img, (640, 640))
|
| 44 |
resized_img = cv2.cvtColor(resized_img, cv2.COLOR_BGR2RGB)
|
| 45 |
+
cv2.imwrite(f'resized_{i}.png',resized_img)
|
| 46 |
results_classification = model_classification.predict(resized_img)
|
| 47 |
+
i+=1
|
| 48 |
if results_classification:
|
| 49 |
top1_class = results_classification[0].probs.top1
|
| 50 |
names.append(classes[top1_class])
|