mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 12:36:36 +00:00
fix rabbit consumer
This commit is contained in:
+6
-4
@@ -28,6 +28,7 @@ transform = A.Compose([
|
||||
A.HueSaturationValue(p=0.3, hue_shift_limit=8, sat_shift_limit=8, val_shift_limit=8)
|
||||
], bbox_params=A.BboxParams(format='yolo'))
|
||||
|
||||
|
||||
def correct_bboxes(labels):
|
||||
margin = 0.0005
|
||||
min_size = 0.01
|
||||
@@ -40,11 +41,11 @@ def correct_bboxes(labels):
|
||||
|
||||
# calc how much bboxes are outside borders ( +small margin ).
|
||||
# value should be negative. If it's positive, then put 0, as no correction
|
||||
w_diff = min( (1 - margin) - (x + half_width), (x - half_width) - margin, 0 )
|
||||
w_diff = min((1 - margin) - (x + half_width), (x - half_width) - margin, 0)
|
||||
w = bboxes[2] + 2*w_diff
|
||||
if w < min_size:
|
||||
continue
|
||||
h_diff = min( (1 - margin) - (y + half_height), ((y - half_height) - margin), 0)
|
||||
h_diff = min((1 - margin) - (y + half_height), ((y - half_height) - margin), 0)
|
||||
h = bboxes[3] + 2 * h_diff
|
||||
if h < min_size:
|
||||
continue
|
||||
@@ -125,10 +126,11 @@ def preprocess_annotations():
|
||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||
executor.map(process_image_file, images)
|
||||
|
||||
def process_image_file(image_file): # this function will be executed in thread
|
||||
|
||||
def process_image_file(image_file):
|
||||
try:
|
||||
image_path = os.path.join(data_images_dir, image_file.name)
|
||||
labels_path = os.path.join(data_labels_dir, f'{Path(image_path).stem}.txt')
|
||||
labels_path = os.path.join(data_labels_dir, f'{Path(str(image_path)).stem}.txt')
|
||||
image = cv2.imdecode(np.fromfile(image_path, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
|
||||
|
||||
img_ann = ImageLabel(
|
||||
|
||||
Reference in New Issue
Block a user