<jupyter_start><jupyter_text><jupyter_code>from google.colab import drive
drive.mount('/content/drive')
def visualise_yolo_dataset(image_file,label_file):
    with open(label_file, "r") as f:
        label = f.read()

    img = cv2.imread(image_file)
    img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
    img_h,img_w = img.shape[0], img.shape[1]

    labels = label.strip().split('\n')
    for label in labels:
        label= label.split()
        n_x,n_y = float(label[1]),float(label[2]) 
        n_w,n_h = float(label[3]),float(label[4]) 

        x_c,y_c = int(img_w*n_x) , int(img_h * n_y)
        w,h =  int(img_w*n_w) , int(img_h * n_h)

        x1,y1 = x_c-w//2 , y_c-h//2
        x2,y2 = x_c+w//2 , y_c+h//2

        img = cv2.rectangle(img, (x1,y1),(x2,y2),[0,255,255],3)
    return img<jupyter_output><empty_output><jupyter_text>You can simply change `image_file` to visualise your data.NOTE: This code assumes all labels and images are in same directoryBelow code randomly shows a sample dataset<jupyter_code>import random

root = '/content/combined_all_sets_bike_plate'
dataset_folder_list = os.listdir(root)

image_file = os.path.join(root,random.choice(dataset_folder_list)[:-3]+'jpg')
label_file = image_file[:-3]+'txt'

img = visualise_yolo_dataset(image_file,label_file)
plt.imshow(img)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14586466165413534, 'fraction_numerical': 0.02481203007518797, 'mean_word_length': 4.158914728682171, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '479410', 'license': 'MIT', 'n_tokens_mistral': 552, 'n_tokens_neox': 534, 'n_words': 89, 'path': 'visualize_yolo_label.ipynb', 'repo_name': 'take2rohit/yolov4', 'size': '1330'}