<jupyter_start><jupyter_text>As of now, I have manually annotated HDR_IMAGES (299 images).During annotation, I found some images in which number plates were not visible at all.So, we will remove images which dont have annotation and shift them to outliers.<jupyter_code>import os
import shutil
import cv2
import matplotlib.pyplot as plt
from tqdm import tqdm
hdr_image_dir = "./training_data/hdr_images/"
hdr_annotations_dir = "./training_data/hdr_annotations/"
outliers_dir = "./training_data/outliers/"
normal_image_dir = "./training_data/normal_images/"
normal_annotations_dir = "./training_data/normal_annotations/"
final_normal_image_dir = "./training_data/final_normal_images/"
# moving images which are not visible from HDR and NORMAL image directory to outliers directory
for file in os.listdir(hdr_image_dir):
    if not os.path.isfile(os.path.join(hdr_annotations_dir,file[:-4]+".xml")):
        shutil.move(os.path.join(hdr_image_dir,file), outliers_dir)
        shutil.move(os.path.join(normal_image_dir,"NORMAL_"+file.split('_')[1]), outliers_dir)
        print(file)
# generating annotation for normal images using hdr annotation
mismatch_img = []
for img in tqdm(os.listdir(hdr_image_dir)):
    hdr_img = cv2.imread(os.path.join(hdr_image_dir, img))
    norm_img = cv2.imread(os.path.join(normal_image_dir, "NORMAL_"+img.split('_')[1]))
    
    # this will ensure that both are same image with same dimension but diferent color saturation.
    # so, bbox will be same for both of them.
    if hdr_img.shape == norm_img.shape:
        shutil.copy2(os.path.join(normal_image_dir,"NORMAL_"+img.split('_')[1]),
                     os.path.join(final_normal_image_dir, "NORMAL_"+img.split('_')[1]))
        
        # generating annotation
        fp = open(os.path.join(hdr_annotations_dir, img[:-4]+".xml"), "r")
        data = fp.readlines()
        fp.close()
        
        
        # updating annotation according to new file name
        data[2] = data[2].replace("HDR_","NORMAL_")
        data[3] = data[3].replace("HDR_","NORMAL_")
        fp = open(os.path.join(normal_annotations_dir,"NORMAL_"+img[4:-4]+".xml"),'w')
        fp.writelines(data)
        fp.close()
        
    else:
        mismatch_img.append(img)
mismatch_img<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12352168199737187, 'fraction_numerical': 0.008322382829610162, 'mean_word_length': 3.828752642706131, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '381908', 'license': 'MIT', 'n_tokens_mistral': 759, 'n_tokens_neox': 744, 'n_words': 165, 'path': 'ocr_number_plate/data_preparation.ipynb', 'repo_name': 'abhishek795jha/projects', 'size': '2283'}