<jupyter_start><jupyter_text><jupyter_code>pip install -r https://raw.githubusercontent.com/ultralytics/yolov5/master/requirements.txt
import torch
import cv2
import numpy as np
from google.colab.patches import cv2_imshow
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
img = cv2.imread('traffic-signal-1.jpg')[..., ::-1]
cv2_imshow(img)
model.classes=[9]
model.conf = 0.8
results = model(img, size=920)
results.save()
crops_image = results.pandas().xyxy[0]
crops_image
results.pandas().xyxy[0].sort_values('xmin')
x1, y1, x2, y2 = int(crops_image.iloc[1,0]), int(crops_image.iloc[1,1]), int(crops_image.iloc[1,2]), int(crops_image.iloc[1,3])
signals = img[y1:y2, x1:x2]
cv2_imshow(signals)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17255434782608695, 'fraction_numerical': 0.04619565217391304, 'mean_word_length': 7.0989010989010985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '506893', 'license': 'MIT', 'n_tokens_mistral': 327, 'n_tokens_neox': 319, 'n_words': 47, 'path': '0-YOLOv5.ipynb', 'repo_name': 'JSJeong-me/YOLOv5_Practitioner_Guide_2', 'size': '736'}