<jupyter_start><jupyter_text>Object Detection - YOLOv3<jupyter_code>import numpy as np
import cv2 as cv
from motrackers.detectors import YOLOv3
import pandas
import pandas as pd
import csv
COLS = ['id','bounding_box']
df = pd.DataFrame(columns=COLS)
VIDEO_FILE = "./../video_data/walking.mp4"
WEIGHTS_PATH = './../pretrained_models/yolo_weights/yolov3.weights'
CONFIG_FILE_PATH = './../pretrained_models/yolo_weights/yolov3.cfg'
LABELS_PATH = "./../pretrained_models/yolo_weights/coco_names.json"

USE_GPU = False
CONFIDENCE_THRESHOLD = 0.5
NMS_THRESHOLD = 0.2
DRAW_BOUNDING_BOXES = True
model = YOLOv3(
    weights_path=WEIGHTS_PATH,
    configfile_path=CONFIG_FILE_PATH,
    labels_path=LABELS_PATH,
    confidence_threshold=CONFIDENCE_THRESHOLD,
    nms_threshold=NMS_THRESHOLD,
    draw_bboxes=DRAW_BOUNDING_BOXES,
    use_gpu=USE_GPU
)
cap = cv.VideoCapture(VIDEO_FILE)
while True:
    ok, image = cap.read()
    
    if not ok:
        print("Cannot read the video feed.")
        break
    
    bboxes, confidences, class_ids = model.detect(image)
    updated_image = model.draw_bboxes(image.copy(), bboxes, confidences, class_ids)
    iter = 0
    for cid in class_ids:
        try:
            label = "{}:{:.4f}".format(model.object_names[cid], confidences[iter])
            new_entry = []
            new_entry.append(label)
            new_entry.append(bboxes[iter])
            single_tweet_df = pd.DataFrame([new_entry], columns=COLS)
            df = df.append(single_tweet_df, ignore_index=True)  
            df.to_csv('bounding_box_collection_walking.csv', columns=COLS,index=False) 
            iter+=1
        except:
             continue
    cv.imshow("image", updated_image)
    if cv.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv.destroyWindow("image")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11348684210526316, 'fraction_numerical': 0.008771929824561403, 'mean_word_length': 3.4188861985472156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '490824', 'license': 'MIT', 'n_tokens_mistral': 663, 'n_tokens_neox': 653, 'n_words': 109, 'path': 'examples/example_notebooks/detector_YOLOv3.ipynb', 'repo_name': 'timseifer/mixed_motion_detection', 'size': '1824'}