<jupyter_start><jupyter_text><jupyter_code>!pip install opencv-python<jupyter_output>Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (4.1.2.30)
Requirement already satisfied: numpy>=1.14.5 in /usr/local/lib/python3.7/dist-packages (from opencv-python) (1.19.5)<jupyter_text>New Section<jupyter_code>import cv2
import matplotlib.pyplot as plt
import numpy as np

image = cv2.imread("/content/people.jpg")
type(image)
image.shape
plt.imshow(image)
new_image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
plt.imshow(new_image)
yolo = cv2.dnn.readNet("./yolov3-tiny.weights","./yolov3-tiny.cfg")

classes = []
with open("./coco.names",'r') as f:
  classes = f.read().splitlines()
len(classes)
blob = cv2.dnn.blobFromImage(image,1/255, (320,320),(0,0,0),swapRB=True, crop = False)
blob.shape
i= blob[0].reshape(320,320,3)
plt.imshow(i)
yolo.setInput(blob)
output_layer_name = yolo.getUnconnectedOutLayersNames()
layeroutput = yolo.forward(output_layer_name)
boxes = []
confidence = []
class_ids = []

for output in layeroutput:
  for detection in output:
    
    score = detection[5:]
    class_id = np.argmax(score)
    confidence = score[class_id]

    print(score)


  if confidence > 0.7:
    center_x = int(detection[0]*width)
    center_y = int(detection[0]*height)

    w = int(detection[0]*width)
    h = int(detection[0]*height)

    x = int(center_x - w/2)
    y = int(center_y - h/2)

   

    boxes.append (float(confidence))
    class_ids.append(class_id)
len(boxes)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15019505851755527, 'fraction_numerical': 0.036410923276983094, 'mean_word_length': 4.785714285714286, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '466756', 'license': 'Apache-2.0', 'n_tokens_mistral': 633, 'n_tokens_neox': 593, 'n_words': 99, 'path': 'Yolo_Demo.ipynb', 'repo_name': 'rahul1975/opencv', 'size': '1538'}