<jupyter_start><jupyter_text>Evaluating the model, Inferencing on Test set and Real-Time Inference via Front Cam:<jupyter_code>!pip install gdown
import gdown
url = 'https://drive.google.com/uc?id=1ALTC356iZxLafkiRqG1AfvnM9UyDqYpe'
output = 'YoloV5_files.zip'
gdown.download(url, output, quiet=False)
!unzip -q YoloV5_files.zip
import os
!git clone https://github.com/ultralytics/yolov5.git
%cd yolov5
data_file_path = "data/new_data.yaml"

!echo {f'train: {os.path.join("..", "License-Plate-Detection-Diff-Formats", "YoloV5_format", "train", "images")}'} >> {data_file_path}
!echo {f'val: {os.path.join("..", "License-Plate-Detection-Diff-Formats", "YoloV5_format", "valid", "images")}'} >> {data_file_path}
!echo {f'test: {os.path.join("..", "License-Plate-Detection-Diff-Formats", "YoloV5_format", "test", "images")}'} >> {data_file_path}

!echo "nc: 1" >> {data_file_path}
!echo "names: ['license_plate']" >> {data_file_path}

!cat {data_file_path}
test_images_folder = os.path.join("..", "License-Plate-Detection-Diff-Formats", "YoloV5_format", "test", "images")
tflite_model_folder = os.path.join("..", "yolo-models", "my-submission")
best_model_name = "best_submission"

img_size = 448
batch_size = 1
width = img_size
height = img_size
channels = 3
    
int8 = False
if int8:
    quantization_lvl = "-int8.tflite"
else:
    quantization_lvl = "-fp16.tflite"

tflite_model_path = os.path.join(tflite_model_folder, best_model_name+quantization_lvl)<jupyter_output><empty_output><jupyter_text>Evaluating TFlite model:<jupyter_code>!python val.py --img 448 --batch 1 --data {data_file_path} --weights {tflite_model_path} --device cpu<jupyter_output>[34m[1mval: [0mdata=data/new_data.yaml, weights=['../yolo-models/my-submission/best_submission-fp16.tflite'], batch_size=1, imgsz=448, conf_thres=0.001, iou_thres=0.6, task=val, device=cpu, single_cls=False, augment=False, verbose=False, save_txt=False, save_hybrid=False, save_conf=False, save_json=False, project=runs/val, name=exp, exist_ok=False, half=False, dnn=False
YOLOv5 🚀 v6.0-103-g7a39803 torch 1.10.0+cu113 CPU

Loading ../yolo-models/my-submission/best_submission-fp16.tflite for TensorFlow Lite inference...
Forcing --batch-size 1 square inference shape(1,3,448,448) for non-PyTorch backends
[34m[1mval: [0mScanning '../License-Plate-Detection-Diff-Formats/YoloV5_format/valid/label[0m
[34m[1mval: [0mNew cache created: ../License-Plate-Detection-Diff-Formats/YoloV5_format/valid/labels.cache
               Class     Images     Labels          P          R     mAP@.5 mAP@
                 all         53         54      0.963      0.963      0.966      0.847
Speed: 1.7ms pr[...]<jupyter_text>Inferencing on Test Set:<jupyter_code>inference_command = f'''
python detect.py --device cpu --source {test_images_folder} --weights {tflite_model_path} --img-size {img_size} --save-txt 
'''
inference_command

!{inference_command}<jupyter_output>[34m[1mdetect: [0mweights=['../yolo-models/my-submission/best_submission-fp16.tflite'], source=../License-Plate-Detection-Diff-Formats/YoloV5_format/test/images, imgsz=[448, 448], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=cpu, view_img=False, save_txt=True, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False
YOLOv5 🚀 v6.0-103-g7a39803 torch 1.10.0+cu113 CPU

Loading ../yolo-models/my-submission/best_submission-fp16.tflite for TensorFlow Lite inference...
image 1/53 /home/priyammehta/EDGENeural_object_detection_assignment/License-Plate-Detection-Diff-Formats/YoloV5_format/test/images/car_105_jpg.rf.9b41223a8760f1dc5df1419664cf29fd.jpg: 448x448 1 class0, Done. (0.260s)
image 2/53 /home/priyammehta/EDGENeural_object_detection_assignment/License-Plate-Detection-Diff-Formats/YoloV[...]<jupyter_text>Real-Time Inference using Front Cam:<jupyter_code>real_time_inference_command = f'''
python detect.py --device cpu --source 0 --weights {tflite_model_path} --img-size {img_size} --save-txt 
'''
!{real_time_inference_command}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1515513126491647, 'fraction_numerical': 0.04725536992840095, 'mean_word_length': 5.487616099071207, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '257365', 'license': 'MIT', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1634, 'n_words': 266, 'path': 'inference.ipynb', 'repo_name': 'prikmm/License-Plate-Detection', 'size': '4190'}