my
Browse files
app.py
CHANGED
|
@@ -75,7 +75,7 @@ def upload_file():
|
|
| 75 |
})
|
| 76 |
|
| 77 |
def process_image():
|
| 78 |
-
model = YOLOv10(f'
|
| 79 |
dataset = sv.DetectionDataset.from_yolo(
|
| 80 |
images_directory_path=f"/data/MyNewVersion5.0Dataset/valid/images",
|
| 81 |
annotations_directory_path=f"/data/MyNewVersion5.0Dataset/valid/labels",
|
|
@@ -83,20 +83,20 @@ def process_image():
|
|
| 83 |
)
|
| 84 |
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
| 85 |
label_annotator = sv.LabelAnnotator()
|
| 86 |
-
image_dir = "
|
| 87 |
files = os.listdir('/data1')
|
| 88 |
files.sort()
|
| 89 |
files = files[0:100]
|
| 90 |
print(files)
|
| 91 |
counter = 0
|
| 92 |
for ii in files:
|
| 93 |
-
random_image_data = cv2.imread('
|
| 94 |
-
random_image_data1 = cv2.imread('
|
| 95 |
-
results = model(source='
|
| 96 |
detections = sv.Detections.from_ultralytics(results)
|
| 97 |
annotated_image = bounding_box_annotator.annotate(scene=random_image_data, detections=detections)
|
| 98 |
annotated_image = label_annotator.annotate(scene=annotated_image, detections=detections)
|
| 99 |
-
save_path = "
|
| 100 |
cv2.imwrite(save_path, annotated_image)
|
| 101 |
print(f"Annotated image saved at {save_path}")
|
| 102 |
bounding_boxes = results.boxes.xyxy.cpu().numpy()
|
|
|
|
| 75 |
})
|
| 76 |
|
| 77 |
def process_image():
|
| 78 |
+
model = YOLOv10(f'./runs/detect/train3/weights/best (1).pt')
|
| 79 |
dataset = sv.DetectionDataset.from_yolo(
|
| 80 |
images_directory_path=f"/data/MyNewVersion5.0Dataset/valid/images",
|
| 81 |
annotations_directory_path=f"/data/MyNewVersion5.0Dataset/valid/labels",
|
|
|
|
| 83 |
)
|
| 84 |
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
| 85 |
label_annotator = sv.LabelAnnotator()
|
| 86 |
+
image_dir = "./data1"
|
| 87 |
files = os.listdir('/data1')
|
| 88 |
files.sort()
|
| 89 |
files = files[0:100]
|
| 90 |
print(files)
|
| 91 |
counter = 0
|
| 92 |
for ii in files:
|
| 93 |
+
random_image_data = cv2.imread('./data1/' + ii)
|
| 94 |
+
random_image_data1 = cv2.imread('./data1/' + ii)
|
| 95 |
+
results = model(source='./data1/' + ii, conf=0.07)[0]
|
| 96 |
detections = sv.Detections.from_ultralytics(results)
|
| 97 |
annotated_image = bounding_box_annotator.annotate(scene=random_image_data, detections=detections)
|
| 98 |
annotated_image = label_annotator.annotate(scene=annotated_image, detections=detections)
|
| 99 |
+
save_path = "./Folder1/" + "detection" + ii
|
| 100 |
cv2.imwrite(save_path, annotated_image)
|
| 101 |
print(f"Annotated image saved at {save_path}")
|
| 102 |
bounding_boxes = results.boxes.xyxy.cpu().numpy()
|