my
Browse files
app.py
CHANGED
@@ -39,15 +39,15 @@ def calculate_iou(bbox1, bbox2):
|
|
39 |
return iou
|
40 |
|
41 |
|
42 |
-
cropped_dir = "
|
43 |
if os.path.exists(cropped_dir):
|
44 |
shutil.rmtree(cropped_dir)
|
45 |
os.makedirs(cropped_dir, exist_ok=True)
|
46 |
|
47 |
-
output_dir1 = "
|
48 |
-
output_dir2 = "
|
49 |
-
output_dir3 = "
|
50 |
-
UPLOAD_FOLDER = "
|
51 |
os.makedirs(output_dir1, exist_ok=True)
|
52 |
os.makedirs(output_dir2, exist_ok=True)
|
53 |
os.makedirs(output_dir3, exist_ok=True)
|
@@ -82,14 +82,14 @@ def process_image():
|
|
82 |
|
83 |
model = YOLOv10(f'./runs/detect/train3/weights/best (1).pt')
|
84 |
dataset = sv.DetectionDataset.from_yolo(
|
85 |
-
images_directory_path=f"
|
86 |
-
annotations_directory_path=f"
|
87 |
-
data_yaml_path=f"
|
88 |
)
|
89 |
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
90 |
label_annotator = sv.LabelAnnotator()
|
91 |
image_dir = "./data1"
|
92 |
-
files = os.listdir('
|
93 |
files.sort()
|
94 |
files = files[0:100]
|
95 |
print(files)
|
@@ -107,7 +107,7 @@ def process_image():
|
|
107 |
bounding_boxes = results.boxes.xyxy.cpu().numpy()
|
108 |
class_ids = results.boxes.cls.cpu().numpy()
|
109 |
confidences = results.boxes.conf.cpu().numpy()
|
110 |
-
bounding_box_save_path = "
|
111 |
with open(bounding_box_save_path, 'w') as f:
|
112 |
for i, (bbox, class_id, confidence) in enumerate(zip(bounding_boxes, class_ids, confidences)):
|
113 |
x1, y1, x2, y2 = map(int, bbox)
|
@@ -121,8 +121,8 @@ def process_image():
|
|
121 |
reader = easyocr.Reader(
|
122 |
['en'],
|
123 |
recog_network='en_sample',
|
124 |
-
model_storage_directory='
|
125 |
-
user_network_directory='
|
126 |
import re
|
127 |
input_file_path = '/bounding_boxes.txt'
|
128 |
cropped_images_folder = '/cropped_images/'
|
|
|
39 |
return iou
|
40 |
|
41 |
|
42 |
+
cropped_dir = "./cropped_images/"
|
43 |
if os.path.exists(cropped_dir):
|
44 |
shutil.rmtree(cropped_dir)
|
45 |
os.makedirs(cropped_dir, exist_ok=True)
|
46 |
|
47 |
+
output_dir1 = "./Folder1"
|
48 |
+
output_dir2 = "./Folder2"
|
49 |
+
output_dir3 = "./Folder3"
|
50 |
+
UPLOAD_FOLDER = "./data1"
|
51 |
os.makedirs(output_dir1, exist_ok=True)
|
52 |
os.makedirs(output_dir2, exist_ok=True)
|
53 |
os.makedirs(output_dir3, exist_ok=True)
|
|
|
82 |
|
83 |
model = YOLOv10(f'./runs/detect/train3/weights/best (1).pt')
|
84 |
dataset = sv.DetectionDataset.from_yolo(
|
85 |
+
images_directory_path=f"./data/MyNewVersion5.0Dataset/valid/images",
|
86 |
+
annotations_directory_path=f"./data/MyNewVersion5.0Dataset/valid/labels",
|
87 |
+
data_yaml_path=f"./data/MyNewVersion5.0Dataset/data.yaml"
|
88 |
)
|
89 |
bounding_box_annotator = sv.BoundingBoxAnnotator()
|
90 |
label_annotator = sv.LabelAnnotator()
|
91 |
image_dir = "./data1"
|
92 |
+
files = os.listdir('./data1')
|
93 |
files.sort()
|
94 |
files = files[0:100]
|
95 |
print(files)
|
|
|
107 |
bounding_boxes = results.boxes.xyxy.cpu().numpy()
|
108 |
class_ids = results.boxes.cls.cpu().numpy()
|
109 |
confidences = results.boxes.conf.cpu().numpy()
|
110 |
+
bounding_box_save_path = "./bounding_boxes.txt"
|
111 |
with open(bounding_box_save_path, 'w') as f:
|
112 |
for i, (bbox, class_id, confidence) in enumerate(zip(bounding_boxes, class_ids, confidences)):
|
113 |
x1, y1, x2, y2 = map(int, bbox)
|
|
|
121 |
reader = easyocr.Reader(
|
122 |
['en'],
|
123 |
recog_network='en_sample',
|
124 |
+
model_storage_directory='./EasyOCR-Trainer/EasyOCR/easyocr/model',
|
125 |
+
user_network_directory='./EasyOCR-Trainer/EasyOCR/user_network')
|
126 |
import re
|
127 |
input_file_path = '/bounding_boxes.txt'
|
128 |
cropped_images_folder = '/cropped_images/'
|