├── .gitignore
├── Create_Neural_network_Pytorch.ipynb
├── DeepFake
├── 1.mp4
├── 3.mp4
├── 4.mp4
├── 5.mp4
├── 6.mp4
├── 7.mp4
├── 8.mp4
└── Deep_Fake.ipynb
├── FaceMask_detection
├── Covid-19_Face_mask_detection.ipynb
├── alarm.wav
├── haarcascade_frontalface_default.xml
├── mask_classification.py
└── model-090.rar
├── Neural network from scratch.ipynb
├── Realtime-human-pose-estimation
├── dance.mp4
├── graph_opt.pb
└── openpose.py
├── Realtime_Human_Emotion_detection
├── .idea
│ ├── .gitignore
│ ├── Realtime_Human_Emotion_detection.iml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ └── modules.xml
├── Test_realtime_code.py
├── datasets.txt
├── emotion.h5
├── emotion.json
└── haarcascade_frontalface_default.xml
├── Realtime_People_Counting
├── Log.csv
├── main.py
├── mobilenet_ssd
│ ├── MobileNetSSD_deploy.caffemodel
│ └── MobileNetSSD_deploy.prototxt
├── mylib
│ ├── __pycache__
│ │ ├── centroidtracker.cpython-37.pyc
│ │ ├── centroidtracker.cpython-39.pyc
│ │ ├── config.cpython-37.pyc
│ │ ├── config.cpython-39.pyc
│ │ ├── mailer.cpython-37.pyc
│ │ ├── mailer.cpython-39.pyc
│ │ ├── thread.cpython-37.pyc
│ │ ├── thread.cpython-39.pyc
│ │ ├── trackableobject.cpython-37.pyc
│ │ └── trackableobject.cpython-39.pyc
│ ├── centroidtracker.py
│ ├── config.py
│ ├── mailer.py
│ ├── thread.py
│ └── trackableobject.py
├── requirements.txt
└── videos
│ └── example_01.mp4
├── Social_distancing
├── MobileNetSSD_deploy.caffemodel
├── MobileNetSSD_deploy.prototxt
├── __pycache__
│ └── centroidtracker.cpython-38.pyc
├── centroidtracker.py
└── social_distancing.py
└── Yolo_Object_Detection
├── input
└── file.mp4
├── yolo-coco
├── coco.names
└── yolov3.cfg
├── yolo_img.py
└── yolo_video.py
/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/.gitignore
--------------------------------------------------------------------------------
/Create_Neural_network_Pytorch.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "name": "Create_Neural_network_Pytorch.ipynb",
7 | "provenance": []
8 | },
9 | "kernelspec": {
10 | "name": "python3",
11 | "display_name": "Python 3"
12 | }
13 | },
14 | "cells": [
15 | {
16 | "cell_type": "code",
17 | "metadata": {
18 | "id": "GQ2oQMdLob71"
19 | },
20 | "source": [
21 | "import torch\r\n",
22 | "import torch.nn as nn\r\n",
23 | "import torch.nn.functional as F"
24 | ],
25 | "execution_count": 1,
26 | "outputs": []
27 | },
28 | {
29 | "cell_type": "code",
30 | "metadata": {
31 | "id": "e7W_nnn6op4_"
32 | },
33 | "source": [
34 | "class Neuralnetworkmodel(nn.Module):\r\n",
35 | " def __init__(self):\r\n",
36 | " super(Neuralnetworkmodel,self).__init__()\r\n",
37 | " self.layer1=nn.Linear(784,300)\r\n",
38 | " self.layer2=nn.Linear(300,100)\r\n",
39 | " self.layer3=nn.Linear(100,10)\r\n",
40 | " def forward(self):\r\n",
41 | " x=x.view(-1,728)\r\n",
42 | " x=F.relu(self.layer1(x))\r\n",
43 | " x=F.relu(self.layer2(x))\r\n",
44 | " x=F.softmax(self.layer3(x))\r\n",
45 | " return x"
46 | ],
47 | "execution_count": 11,
48 | "outputs": []
49 | },
50 | {
51 | "cell_type": "code",
52 | "metadata": {
53 | "id": "aVqR6HGKpLvr"
54 | },
55 | "source": [
56 | "neuralnetwork= Neuralnetworkmodel()"
57 | ],
58 | "execution_count": 12,
59 | "outputs": []
60 | },
61 | {
62 | "cell_type": "code",
63 | "metadata": {
64 | "colab": {
65 | "base_uri": "https://localhost:8080/"
66 | },
67 | "id": "ANBSa6DCq4Oj",
68 | "outputId": "4878048b-fb49-4ff0-fd8a-99b3eab3d3c2"
69 | },
70 | "source": [
71 | "neuralnetwork"
72 | ],
73 | "execution_count": 13,
74 | "outputs": [
75 | {
76 | "output_type": "execute_result",
77 | "data": {
78 | "text/plain": [
79 | "Neuralnetworkmodel(\n",
80 | " (layer1): Linear(in_features=784, out_features=300, bias=True)\n",
81 | " (layer2): Linear(in_features=300, out_features=100, bias=True)\n",
82 | " (layer3): Linear(in_features=100, out_features=10, bias=True)\n",
83 | ")"
84 | ]
85 | },
86 | "metadata": {
87 | "tags": []
88 | },
89 | "execution_count": 13
90 | }
91 | ]
92 | },
93 | {
94 | "cell_type": "code",
95 | "metadata": {
96 | "id": "3SUB-Y0Pq6ou"
97 | },
98 | "source": [
99 | ""
100 | ],
101 | "execution_count": null,
102 | "outputs": []
103 | }
104 | ]
105 | }
--------------------------------------------------------------------------------
/DeepFake/1.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/1.mp4
--------------------------------------------------------------------------------
/DeepFake/3.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/3.mp4
--------------------------------------------------------------------------------
/DeepFake/4.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/4.mp4
--------------------------------------------------------------------------------
/DeepFake/5.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/5.mp4
--------------------------------------------------------------------------------
/DeepFake/6.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/6.mp4
--------------------------------------------------------------------------------
/DeepFake/7.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/7.mp4
--------------------------------------------------------------------------------
/DeepFake/8.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/DeepFake/8.mp4
--------------------------------------------------------------------------------
/FaceMask_detection/alarm.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/FaceMask_detection/alarm.wav
--------------------------------------------------------------------------------
/FaceMask_detection/mask_classification.py:
--------------------------------------------------------------------------------
1 | from keras.models import load_model
2 | import cv2
3 | import numpy as np
4 |
5 |
6 |
7 | from pygame import mixer
8 | mixer.init()
9 | sound = mixer.Sound('alarm.wav')
10 |
11 |
12 |
13 | model = load_model('model-090.model')
14 |
15 | face_clsfr=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
16 |
17 | cap=cv2.VideoCapture(0)
18 |
19 |
20 | labels_dict={0:'MASK',1:'NO MASK'}
21 | color_dict={0:(0,255,0),1:(0,0,255)}
22 |
23 |
24 | while(True):
25 |
26 | ret,frame=cap.read()
27 | gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
28 | faces=face_clsfr.detectMultiScale(gray,1.3,5)
29 |
30 | for (x,y,w,h) in faces:
31 |
32 | face_img=gray[y:y+w,x:x+w]
33 | resized=cv2.resize(face_img,(100,100))
34 | normalized=resized/255.0
35 | reshaped=np.reshape(normalized,(1,100,100,1))
36 | result=model.predict(reshaped)
37 |
38 | label=np.argmax(result,axis=1)[0]
39 |
40 | cv2.rectangle(frame,(x,y),(x+w,y+h),color_dict[label],4)
41 | cv2.rectangle(frame,(x,y-40),(x+w,y),color_dict[label],4)
42 | cv2.putText(frame, labels_dict[label], (x, y-10),cv2.FONT_ITALIC, 1,(255,255,255),4)
43 |
44 | if(labels_dict[label] =='MASK'):
45 | print("No Beep")
46 | elif(labels_dict[label] =='NO MASK'):
47 | sound.play()
48 | print("Beep")
49 |
50 | cv2.imshow('Mask Detection App',frame)
51 | if cv2.waitKey(1) & 0xFF == ord('q'):
52 | break
53 | cap.release()
54 | cv2.destroyAllWindows()
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/FaceMask_detection/model-090.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/FaceMask_detection/model-090.rar
--------------------------------------------------------------------------------
/Realtime-human-pose-estimation/dance.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime-human-pose-estimation/dance.mp4
--------------------------------------------------------------------------------
/Realtime-human-pose-estimation/graph_opt.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime-human-pose-estimation/graph_opt.pb
--------------------------------------------------------------------------------
/Realtime-human-pose-estimation/openpose.py:
--------------------------------------------------------------------------------
1 |
2 | import cv2 as cv
3 | import argparse
4 |
5 | parser = argparse.ArgumentParser()
6 | parser.add_argument('--input', help='Path to image or video. Skip to capture frames from camera')
7 | parser.add_argument('--thr', default=0.2, type=float, help='Threshold value for pose parts heat map')
8 | parser.add_argument('--width', default=368, type=int, help='Resize input to specific width.')
9 | parser.add_argument('--height', default=368, type=int, help='Resize input to specific height.')
10 |
11 | args = parser.parse_args()
12 |
13 | BODY_PARTS = { "Nose": 0, "Neck": 1, "RShoulder": 2, "RElbow": 3, "RWrist": 4,
14 | "LShoulder": 5, "LElbow": 6, "LWrist": 7, "RHip": 8, "RKnee": 9,
15 | "RAnkle": 10, "LHip": 11, "LKnee": 12, "LAnkle": 13, "REye": 14,
16 | "LEye": 15, "REar": 16, "LEar": 17, "Background": 18 }
17 |
18 | POSE_PAIRS = [ ["Neck", "RShoulder"], ["Neck", "LShoulder"], ["RShoulder", "RElbow"],
19 | ["RElbow", "RWrist"], ["LShoulder", "LElbow"], ["LElbow", "LWrist"],
20 | ["Neck", "RHip"], ["RHip", "RKnee"], ["RKnee", "RAnkle"], ["Neck", "LHip"],
21 | ["LHip", "LKnee"], ["LKnee", "LAnkle"], ["Neck", "Nose"], ["Nose", "REye"],
22 | ["REye", "REar"], ["Nose", "LEye"], ["LEye", "LEar"] ]
23 |
24 | inWidth = args.width
25 | inHeight = args.height
26 |
27 | net = cv.dnn.readNetFromTensorflow("graph_opt.pb")
28 |
29 | cap = cv.VideoCapture('dance.mp4')
30 |
31 | while cv.waitKey(1) < 0:
32 | hasFrame, frame = cap.read()
33 | if not hasFrame:
34 | cv.waitKey()
35 | break
36 |
37 | frameWidth = frame.shape[1]
38 | frameHeight = frame.shape[0]
39 |
40 | net.setInput(cv.dnn.blobFromImage(frame, 1.0, (inWidth, inHeight), (127.5, 127.5, 127.5), swapRB=True, crop=False))
41 | out = net.forward()
42 | out = out[:, :19, :, :] # MobileNet output [1, 57, -1, -1], we only need the first 19 elements
43 |
44 | assert(len(BODY_PARTS) == out.shape[1])
45 |
46 | points = []
47 | for i in range(len(BODY_PARTS)):
48 | # Slice heatmap of corresponging body's part.
49 | heatMap = out[0, i, :, :]
50 |
51 | # Originally, we try to find all the local maximums. To simplify a sample
52 | # we just find a global one. However only a single pose at the same time
53 | # could be detected this way.
54 | _, conf, _, point = cv.minMaxLoc(heatMap)
55 | x = (frameWidth * point[0]) / out.shape[3]
56 | y = (frameHeight * point[1]) / out.shape[2]
57 | # Add a point if it's confidence is higher than threshold.
58 | points.append((int(x), int(y)) if conf > args.thr else None)
59 |
60 | for pair in POSE_PAIRS:
61 | partFrom = pair[0]
62 | partTo = pair[1]
63 | assert(partFrom in BODY_PARTS)
64 | assert(partTo in BODY_PARTS)
65 |
66 | idFrom = BODY_PARTS[partFrom]
67 | idTo = BODY_PARTS[partTo]
68 |
69 | if points[idFrom] and points[idTo]:
70 | cv.line(frame, points[idFrom], points[idTo], (0, 255, 0), 3)
71 | cv.ellipse(frame, points[idFrom], (3, 3), 0, 0, 360, (0, 0, 255), cv.FILLED)
72 | cv.ellipse(frame, points[idTo], (3, 3), 0, 0, 360, (0, 0, 255), cv.FILLED)
73 |
74 | t, _ = net.getPerfProfile()
75 | freq = cv.getTickFrequency() / 1000
76 | cv.putText(frame, '%.2fms' % (t / freq), (10, 20), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0))
77 |
78 | cv.imshow('OpenPose using OpenCV', frame)
79 | key = cv.waitKey(1)
80 | if key == ord('q'):
81 | break
82 |
83 |
84 | # release the file pointers
85 | cv.destroyAllWindows()
86 | cap.release()
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/.idea/Realtime_Human_Emotion_detection.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/Test_realtime_code.py:
--------------------------------------------------------------------------------
1 | import os
2 | import cv2
3 | import numpy as np
4 | from keras.models import model_from_json
5 | from keras.preprocessing import image
6 |
7 | #load model
8 | model = model_from_json(open("emotion.json", "r").read())
9 | #load weights
10 | model.load_weights('emotion.h5')
11 |
12 |
13 | face_haar_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
14 |
15 |
16 | cap=cv2.VideoCapture(0)
17 |
18 | while True:
19 | ret,test_img=cap.read()# captures frame and returns boolean value and captured image
20 | if not ret:
21 | continue
22 | gray_img= cv2.cvtColor(test_img, cv2.COLOR_BGR2GRAY)
23 |
24 | faces_detected = face_haar_cascade.detectMultiScale(gray_img, 1.32, 5)
25 |
26 |
27 | for (x,y,w,h) in faces_detected:
28 | cv2.rectangle(test_img,(x,y),(x+w,y+h),(255,0,0),thickness=7)
29 | roi_gray=gray_img[y:y+w,x:x+h]#cropping region of interest i.e. face area from image
30 | roi_gray=cv2.resize(roi_gray,(48,48))
31 | img_pixels = image.img_to_array(roi_gray)
32 | img_pixels = np.expand_dims(img_pixels, axis = 0)
33 | img_pixels /= 255
34 |
35 | predictions = model.predict(img_pixels)
36 |
37 | #find max indexed array
38 | max_index = np.argmax(predictions[0])
39 |
40 | emotions = ('angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', 'neutral')
41 | predicted_emotion = emotions[max_index]
42 |
43 | cv2.putText(test_img, predicted_emotion, (int(x), int(y)), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2)
44 |
45 | resized_img = cv2.resize(test_img, (1000, 700))
46 | cv2.imshow('Realtime_Human_Emotion_detection',resized_img)
47 |
48 |
49 |
50 | if cv2.waitKey(10) == ord('q'):#wait until 'q' key is pressed
51 | break
52 |
53 | cap.release()
54 | cv2.destroyAllWindows
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/datasets.txt:
--------------------------------------------------------------------------------
1 | For dataset please link on this link mention below:
2 |
3 | https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/data
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/emotion.h5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_Human_Emotion_detection/emotion.h5
--------------------------------------------------------------------------------
/Realtime_Human_Emotion_detection/emotion.json:
--------------------------------------------------------------------------------
1 | {"class_name": "Sequential", "config": {"name": "sequential_1", "layers": [{"class_name": "Conv2D", "config": {"name": "conv2d_1", "trainable": true, "batch_input_shape": [null, 48, 48, 1], "dtype": "float32", "filters": 64, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Conv2D", "config": {"name": "conv2d_2", "trainable": true, "filters": 64, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "MaxPooling2D", "config": {"name": "max_pooling2d_1", "trainable": true, "pool_size": [2, 2], "padding": "valid", "strides": [2, 2], "data_format": "channels_last"}}, {"class_name": "Dropout", "config": {"name": "dropout_1", "trainable": true, "rate": 0.5, "noise_shape": null, "seed": null}}, {"class_name": "Conv2D", "config": {"name": "conv2d_3", "trainable": true, "filters": 64, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Conv2D", "config": {"name": "conv2d_4", "trainable": true, "filters": 64, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "MaxPooling2D", "config": {"name": "max_pooling2d_2", "trainable": true, "pool_size": [2, 2], "padding": "valid", "strides": [2, 2], "data_format": "channels_last"}}, {"class_name": "Dropout", "config": {"name": "dropout_2", "trainable": true, "rate": 0.5, "noise_shape": null, "seed": null}}, {"class_name": "Conv2D", "config": {"name": "conv2d_5", "trainable": true, "filters": 128, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Conv2D", "config": {"name": "conv2d_6", "trainable": true, "filters": 128, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "MaxPooling2D", "config": {"name": "max_pooling2d_3", "trainable": true, "pool_size": [2, 2], "padding": "valid", "strides": [2, 2], "data_format": "channels_last"}}, {"class_name": "Flatten", "config": {"name": "flatten_1", "trainable": true, "data_format": "channels_last"}}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "units": 1024, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Dropout", "config": {"name": "dropout_3", "trainable": true, "rate": 0.2, "noise_shape": null, "seed": null}}, {"class_name": "Dense", "config": {"name": "dense_2", "trainable": true, "units": 1024, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Dropout", "config": {"name": "dropout_4", "trainable": true, "rate": 0.2, "noise_shape": null, "seed": null}}, {"class_name": "Dense", "config": {"name": "dense_3", "trainable": true, "units": 7, "activation": "softmax", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "keras_version": "2.2.4", "backend": "tensorflow"}
--------------------------------------------------------------------------------
/Realtime_People_Counting/Log.csv:
--------------------------------------------------------------------------------
1 | "End Time","In","Out","Total Inside"
2 | "2020-08-18 20:46:03.573500","1","1","4"
3 | "","2","2",""
4 | "","3","3",""
5 | "","4","",""
6 | "","5","",""
7 | "","6","",""
8 | "","7","",""
9 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/main.py:
--------------------------------------------------------------------------------
1 | from mylib.centroidtracker import CentroidTracker
2 | from mylib.trackableobject import TrackableObject
3 | from imutils.video import VideoStream
4 | from imutils.video import FPS
5 | from mylib.mailer import Mailer
6 | from mylib import config, thread
7 | import time, schedule, csv
8 | import numpy as np
9 | import argparse, imutils
10 | import time, dlib, cv2, datetime
11 | from itertools import zip_longest
12 |
13 |
14 |
15 | #python main.py --prototxt mobilenet_ssd/MobileNetSSD_deploy.prototxt --model mobilenet_ssd/MobileNetSSD_deploy.caffemodel --input videos/example_01.mp4
16 |
17 | t0 = time.time()
18 |
19 | def run():
20 |
21 | # construct the argument parse and parse the arguments
22 | ap = argparse.ArgumentParser()
23 | ap.add_argument("-p", "--prototxt", required=False,
24 | help="path to Caffe 'deploy' prototxt file")
25 | ap.add_argument("-m", "--model", required=True,
26 | help="path to Caffe pre-trained model")
27 | ap.add_argument("-i", "--input", type=str,
28 | help="path to optional input video file")
29 | ap.add_argument("-o", "--output", type=str,
30 | help="path to optional output video file")
31 | # confidence default 0.4
32 | ap.add_argument("-c", "--confidence", type=float, default=0.4,
33 | help="minimum probability to filter weak detections")
34 | ap.add_argument("-s", "--skip-frames", type=int, default=30,
35 | help="# of skip frames between detections")
36 | args = vars(ap.parse_args())
37 |
38 | # initialize the list of class labels MobileNet SSD was trained to
39 | # detect
40 | CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",
41 | "bottle", "bus", "car", "cat", "chair", "cow", "diningtable",
42 | "dog", "horse", "motorbike", "person", "pottedplant", "sheep",
43 | "sofa", "train", "tvmonitor"]
44 |
45 | # load our serialized model from disk
46 | net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])
47 |
48 | # if a video path was not supplied, grab a reference to the ip camera
49 | if not args.get("input", False):
50 | print("[INFO] Starting the live stream..")
51 | vs = VideoStream(config.url).start()
52 | time.sleep(2.0)
53 |
54 | # otherwise, grab a reference to the video file
55 | else:
56 | print("[INFO] Starting the video..")
57 | vs = cv2.VideoCapture(args["input"])
58 |
59 | # initialize the video writer (we'll instantiate later if need be)
60 | writer = None
61 |
62 | # initialize the frame dimensions (we'll set them as soon as we read
63 | # the first frame from the video)
64 | W = None
65 | H = None
66 |
67 | # instantiate our centroid tracker, then initialize a list to store
68 | # each of our dlib correlation trackers, followed by a dictionary to
69 | # map each unique object ID to a TrackableObject
70 | ct = CentroidTracker(maxDisappeared=40, maxDistance=50)
71 | trackers = []
72 | trackableObjects = {}
73 |
74 | # initialize the total number of frames processed thus far, along
75 | # with the total number of objects that have moved either up or down
76 | totalFrames = 0
77 | totalDown = 0
78 | totalUp = 0
79 | x = []
80 | empty=[]
81 | empty1=[]
82 |
83 | # start the frames per second throughput estimator
84 | fps = FPS().start()
85 |
86 | if config.Thread:
87 | vs = thread.ThreadingClass(config.url)
88 |
89 | # loop over frames from the video stream
90 | while True:
91 | # grab the next frame and handle if we are reading from either
92 | # VideoCapture or VideoStream
93 | frame = vs.read()
94 | frame = frame[1] if args.get("input", False) else frame
95 |
96 | # if we are viewing a video and we did not grab a frame then we
97 | # have reached the end of the video
98 | if args["input"] is not None and frame is None:
99 | break
100 |
101 | # resize the frame to have a maximum width of 500 pixels (the
102 | # less data we have, the faster we can process it), then convert
103 | # the frame from BGR to RGB for dlib
104 | frame = imutils.resize(frame, width = 500)
105 | rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
106 |
107 | # if the frame dimensions are empty, set them
108 | if W is None or H is None:
109 | (H, W) = frame.shape[:2]
110 |
111 | # if we are supposed to be writing a video to disk, initialize
112 | # the writer
113 | if args["output"] is not None and writer is None:
114 | fourcc = cv2.VideoWriter_fourcc(*"MJPG")
115 | writer = cv2.VideoWriter(args["output"], fourcc, 30,
116 | (W, H), True)
117 |
118 | # initialize the current status along with our list of bounding
119 | # box rectangles returned by either (1) our object detector or
120 | # (2) the correlation trackers
121 | status = "Waiting"
122 | rects = []
123 |
124 | # check to see if we should run a more computationally expensive
125 | # object detection method to aid our tracker
126 | if totalFrames % args["skip_frames"] == 0:
127 | # set the status and initialize our new set of object trackers
128 | status = "Detecting"
129 | trackers = []
130 |
131 | # convert the frame to a blob and pass the blob through the
132 | # network and obtain the detections
133 | blob = cv2.dnn.blobFromImage(frame, 0.007843, (W, H), 127.5)
134 | net.setInput(blob)
135 | detections = net.forward()
136 |
137 | # loop over the detections
138 | for i in np.arange(0, detections.shape[2]):
139 | # extract the confidence (i.e., probability) associated
140 | # with the prediction
141 | confidence = detections[0, 0, i, 2]
142 |
143 | # filter out weak detections by requiring a minimum
144 | # confidence
145 | if confidence > args["confidence"]:
146 | # extract the index of the class label from the
147 | # detections list
148 | idx = int(detections[0, 0, i, 1])
149 |
150 | # if the class label is not a person, ignore it
151 | if CLASSES[idx] != "person":
152 | continue
153 |
154 | # compute the (x, y)-coordinates of the bounding box
155 | # for the object
156 | box = detections[0, 0, i, 3:7] * np.array([W, H, W, H])
157 | (startX, startY, endX, endY) = box.astype("int")
158 |
159 |
160 | # construct a dlib rectangle object from the bounding
161 | # box coordinates and then start the dlib correlation
162 | # tracker
163 | tracker = dlib.correlation_tracker()
164 | rect = dlib.rectangle(startX, startY, endX, endY)
165 | tracker.start_track(rgb, rect)
166 |
167 | # add the tracker to our list of trackers so we can
168 | # utilize it during skip frames
169 | trackers.append(tracker)
170 |
171 | # otherwise, we should utilize our object *trackers* rather than
172 | # object *detectors* to obtain a higher frame processing throughput
173 | else:
174 | # loop over the trackers
175 | for tracker in trackers:
176 | # set the status of our system to be 'tracking' rather
177 | # than 'waiting' or 'detecting'
178 | status = "Tracking"
179 |
180 | # update the tracker and grab the updated position
181 | tracker.update(rgb)
182 | pos = tracker.get_position()
183 |
184 | # unpack the position object
185 | startX = int(pos.left())
186 | startY = int(pos.top())
187 | endX = int(pos.right())
188 | endY = int(pos.bottom())
189 |
190 | # add the bounding box coordinates to the rectangles list
191 | rects.append((startX, startY, endX, endY))
192 |
193 | # draw a horizontal line in the center of the frame -- once an
194 | # object crosses this line we will determine whether they were
195 | # moving 'up' or 'down'
196 | cv2.line(frame, (0, H // 2), (W, H // 2), (0, 0, 0), 3)
197 | cv2.putText(frame, "-Prediction border - Entrance-", (10, H - ((i * 20) + 200)),
198 | cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
199 |
200 | # use the centroid tracker to associate the (1) old object
201 | # centroids with (2) the newly computed object centroids
202 | objects = ct.update(rects)
203 |
204 | # loop over the tracked objects
205 | for (objectID, centroid) in objects.items():
206 | # check to see if a trackable object exists for the current
207 | # object ID
208 | to = trackableObjects.get(objectID, None)
209 |
210 | # if there is no existing trackable object, create one
211 | if to is None:
212 | to = TrackableObject(objectID, centroid)
213 |
214 | # otherwise, there is a trackable object so we can utilize it
215 | # to determine direction
216 | else:
217 | # the difference between the y-coordinate of the *current*
218 | # centroid and the mean of *previous* centroids will tell
219 | # us in which direction the object is moving (negative for
220 | # 'up' and positive for 'down')
221 | y = [c[1] for c in to.centroids]
222 | direction = centroid[1] - np.mean(y)
223 | to.centroids.append(centroid)
224 |
225 | # check to see if the object has been counted or not
226 | if not to.counted:
227 | # if the direction is negative (indicating the object
228 | # is moving up) AND the centroid is above the center
229 | # line, count the object
230 | if direction < 0 and centroid[1] < H // 2:
231 | totalUp += 1
232 | empty.append(totalUp)
233 | to.counted = True
234 |
235 | # if the direction is positive (indicating the object
236 | # is moving down) AND the centroid is below the
237 | # center line, count the object
238 | elif direction > 0 and centroid[1] > H // 2:
239 | totalDown += 1
240 | empty1.append(totalDown)
241 | #print(empty1[-1])
242 | x = []
243 | # compute the sum of total people inside
244 | x.append(len(empty1)-len(empty))
245 | #print("Total people inside:", x)
246 | # if the people limit exceeds over threshold, send an email alert
247 | if sum(x) >= config.Threshold:
248 | cv2.putText(frame, "-ALERT: People limit exceeded-", (10, frame.shape[0] - 80),
249 | cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 255), 2)
250 | if config.ALERT:
251 | print("[INFO] Sending email alert..")
252 | Mailer().send(config.MAIL)
253 | print("[INFO] Alert sent")
254 |
255 | to.counted = True
256 |
257 |
258 | # store the trackable object in our dictionary
259 | trackableObjects[objectID] = to
260 |
261 | # draw both the ID of the object and the centroid of the
262 | # object on the output frame
263 | text = "ID {}".format(objectID)
264 | cv2.putText(frame, text, (centroid[0] - 10, centroid[1] - 10),
265 | cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 2)
266 | cv2.circle(frame, (centroid[0], centroid[1]), 4, (255, 255, 255), -1)
267 |
268 | # construct a tuple of information we will be displaying on the
269 | info = [
270 | ("Exit", totalUp),
271 | ("Enter", totalDown),
272 | ("Status", status),
273 | ]
274 |
275 | info2 = [
276 | ("Total people inside", x),
277 | ]
278 |
279 | # Display the output
280 | for (i, (k, v)) in enumerate(info):
281 | text = "{}: {}".format(k, v)
282 | cv2.putText(frame, text, (10, H - ((i * 20) + 20)), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 0), 2)
283 |
284 | for (i, (k, v)) in enumerate(info2):
285 | text = "{}: {}".format(k, v)
286 | cv2.putText(frame, text, (265, H - ((i * 20) + 60)), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2)
287 |
288 | # Initiate a simple log to save data at end of the day
289 | if config.Log:
290 | datetimee = [datetime.datetime.now()]
291 | d = [datetimee, empty1, empty, x]
292 | export_data = zip_longest(*d, fillvalue = '')
293 |
294 | with open('Log.csv', 'w', newline='') as myfile:
295 | wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
296 | wr.writerow(("End Time", "In", "Out", "Total Inside"))
297 | wr.writerows(export_data)
298 |
299 |
300 | # show the output frame
301 | cv2.imshow("Real-Time Monitoring/Analysis Window", frame)
302 | key = cv2.waitKey(1) & 0xFF
303 |
304 | # if the `q` key was pressed, break from the loop
305 | if key == ord("q"):
306 | break
307 |
308 | # increment the total number of frames processed thus far and
309 | # then update the FPS counter
310 | totalFrames += 1
311 | fps.update()
312 |
313 | if config.Timer:
314 | # Automatic timer to stop the live stream. Set to 8 hours (28800s).
315 | t1 = time.time()
316 | num_seconds=(t1-t0)
317 | if num_seconds > 28800:
318 | break
319 |
320 | # stop the timer and display FPS information
321 | fps.stop()
322 | print("[INFO] elapsed time: {:.2f}".format(fps.elapsed()))
323 | print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
324 |
325 |
326 | # # if we are not using a video file, stop the camera video stream
327 | # if not args.get("input", False):
328 | # vs.stop()
329 | #
330 | # # otherwise, release the video file pointer
331 | # else:
332 | # vs.release()
333 |
334 | # close any open windows
335 | cv2.destroyAllWindows()
336 |
337 |
338 | ##learn more about different schedules here: https://pypi.org/project/schedule/
339 | if config.Scheduler:
340 | ##Runs for every 1 second
341 | #schedule.every(1).seconds.do(run)
342 | ##Runs at every day (9:00 am). You can change it.
343 | schedule.every().day.at("9:00").do(run)
344 |
345 | while 1:
346 | schedule.run_pending()
347 |
348 | else:
349 | run()
350 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/mobilenet_ssd/MobileNetSSD_deploy.caffemodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mobilenet_ssd/MobileNetSSD_deploy.caffemodel
--------------------------------------------------------------------------------
/Realtime_People_Counting/mobilenet_ssd/MobileNetSSD_deploy.prototxt:
--------------------------------------------------------------------------------
1 | name: "MobileNet-SSD"
2 | input: "data"
3 | input_shape {
4 | dim: 1
5 | dim: 3
6 | dim: 300
7 | dim: 300
8 | }
9 | layer {
10 | name: "conv0"
11 | type: "Convolution"
12 | bottom: "data"
13 | top: "conv0"
14 | param {
15 | lr_mult: 1.0
16 | decay_mult: 1.0
17 | }
18 | param {
19 | lr_mult: 2.0
20 | decay_mult: 0.0
21 | }
22 | convolution_param {
23 | num_output: 32
24 | pad: 1
25 | kernel_size: 3
26 | stride: 2
27 | weight_filler {
28 | type: "msra"
29 | }
30 | bias_filler {
31 | type: "constant"
32 | value: 0.0
33 | }
34 | }
35 | }
36 | layer {
37 | name: "conv0/relu"
38 | type: "ReLU"
39 | bottom: "conv0"
40 | top: "conv0"
41 | }
42 | layer {
43 | name: "conv1/dw"
44 | type: "Convolution"
45 | bottom: "conv0"
46 | top: "conv1/dw"
47 | param {
48 | lr_mult: 1.0
49 | decay_mult: 1.0
50 | }
51 | param {
52 | lr_mult: 2.0
53 | decay_mult: 0.0
54 | }
55 | convolution_param {
56 | num_output: 32
57 | pad: 1
58 | kernel_size: 3
59 | group: 32
60 | engine: CAFFE
61 | weight_filler {
62 | type: "msra"
63 | }
64 | bias_filler {
65 | type: "constant"
66 | value: 0.0
67 | }
68 | }
69 | }
70 | layer {
71 | name: "conv1/dw/relu"
72 | type: "ReLU"
73 | bottom: "conv1/dw"
74 | top: "conv1/dw"
75 | }
76 | layer {
77 | name: "conv1"
78 | type: "Convolution"
79 | bottom: "conv1/dw"
80 | top: "conv1"
81 | param {
82 | lr_mult: 1.0
83 | decay_mult: 1.0
84 | }
85 | param {
86 | lr_mult: 2.0
87 | decay_mult: 0.0
88 | }
89 | convolution_param {
90 | num_output: 64
91 | kernel_size: 1
92 | weight_filler {
93 | type: "msra"
94 | }
95 | bias_filler {
96 | type: "constant"
97 | value: 0.0
98 | }
99 | }
100 | }
101 | layer {
102 | name: "conv1/relu"
103 | type: "ReLU"
104 | bottom: "conv1"
105 | top: "conv1"
106 | }
107 | layer {
108 | name: "conv2/dw"
109 | type: "Convolution"
110 | bottom: "conv1"
111 | top: "conv2/dw"
112 | param {
113 | lr_mult: 1.0
114 | decay_mult: 1.0
115 | }
116 | param {
117 | lr_mult: 2.0
118 | decay_mult: 0.0
119 | }
120 | convolution_param {
121 | num_output: 64
122 | pad: 1
123 | kernel_size: 3
124 | stride: 2
125 | group: 64
126 | engine: CAFFE
127 | weight_filler {
128 | type: "msra"
129 | }
130 | bias_filler {
131 | type: "constant"
132 | value: 0.0
133 | }
134 | }
135 | }
136 | layer {
137 | name: "conv2/dw/relu"
138 | type: "ReLU"
139 | bottom: "conv2/dw"
140 | top: "conv2/dw"
141 | }
142 | layer {
143 | name: "conv2"
144 | type: "Convolution"
145 | bottom: "conv2/dw"
146 | top: "conv2"
147 | param {
148 | lr_mult: 1.0
149 | decay_mult: 1.0
150 | }
151 | param {
152 | lr_mult: 2.0
153 | decay_mult: 0.0
154 | }
155 | convolution_param {
156 | num_output: 128
157 | kernel_size: 1
158 | weight_filler {
159 | type: "msra"
160 | }
161 | bias_filler {
162 | type: "constant"
163 | value: 0.0
164 | }
165 | }
166 | }
167 | layer {
168 | name: "conv2/relu"
169 | type: "ReLU"
170 | bottom: "conv2"
171 | top: "conv2"
172 | }
173 | layer {
174 | name: "conv3/dw"
175 | type: "Convolution"
176 | bottom: "conv2"
177 | top: "conv3/dw"
178 | param {
179 | lr_mult: 1.0
180 | decay_mult: 1.0
181 | }
182 | param {
183 | lr_mult: 2.0
184 | decay_mult: 0.0
185 | }
186 | convolution_param {
187 | num_output: 128
188 | pad: 1
189 | kernel_size: 3
190 | group: 128
191 | engine: CAFFE
192 | weight_filler {
193 | type: "msra"
194 | }
195 | bias_filler {
196 | type: "constant"
197 | value: 0.0
198 | }
199 | }
200 | }
201 | layer {
202 | name: "conv3/dw/relu"
203 | type: "ReLU"
204 | bottom: "conv3/dw"
205 | top: "conv3/dw"
206 | }
207 | layer {
208 | name: "conv3"
209 | type: "Convolution"
210 | bottom: "conv3/dw"
211 | top: "conv3"
212 | param {
213 | lr_mult: 1.0
214 | decay_mult: 1.0
215 | }
216 | param {
217 | lr_mult: 2.0
218 | decay_mult: 0.0
219 | }
220 | convolution_param {
221 | num_output: 128
222 | kernel_size: 1
223 | weight_filler {
224 | type: "msra"
225 | }
226 | bias_filler {
227 | type: "constant"
228 | value: 0.0
229 | }
230 | }
231 | }
232 | layer {
233 | name: "conv3/relu"
234 | type: "ReLU"
235 | bottom: "conv3"
236 | top: "conv3"
237 | }
238 | layer {
239 | name: "conv4/dw"
240 | type: "Convolution"
241 | bottom: "conv3"
242 | top: "conv4/dw"
243 | param {
244 | lr_mult: 1.0
245 | decay_mult: 1.0
246 | }
247 | param {
248 | lr_mult: 2.0
249 | decay_mult: 0.0
250 | }
251 | convolution_param {
252 | num_output: 128
253 | pad: 1
254 | kernel_size: 3
255 | stride: 2
256 | group: 128
257 | engine: CAFFE
258 | weight_filler {
259 | type: "msra"
260 | }
261 | bias_filler {
262 | type: "constant"
263 | value: 0.0
264 | }
265 | }
266 | }
267 | layer {
268 | name: "conv4/dw/relu"
269 | type: "ReLU"
270 | bottom: "conv4/dw"
271 | top: "conv4/dw"
272 | }
273 | layer {
274 | name: "conv4"
275 | type: "Convolution"
276 | bottom: "conv4/dw"
277 | top: "conv4"
278 | param {
279 | lr_mult: 1.0
280 | decay_mult: 1.0
281 | }
282 | param {
283 | lr_mult: 2.0
284 | decay_mult: 0.0
285 | }
286 | convolution_param {
287 | num_output: 256
288 | kernel_size: 1
289 | weight_filler {
290 | type: "msra"
291 | }
292 | bias_filler {
293 | type: "constant"
294 | value: 0.0
295 | }
296 | }
297 | }
298 | layer {
299 | name: "conv4/relu"
300 | type: "ReLU"
301 | bottom: "conv4"
302 | top: "conv4"
303 | }
304 | layer {
305 | name: "conv5/dw"
306 | type: "Convolution"
307 | bottom: "conv4"
308 | top: "conv5/dw"
309 | param {
310 | lr_mult: 1.0
311 | decay_mult: 1.0
312 | }
313 | param {
314 | lr_mult: 2.0
315 | decay_mult: 0.0
316 | }
317 | convolution_param {
318 | num_output: 256
319 | pad: 1
320 | kernel_size: 3
321 | group: 256
322 | engine: CAFFE
323 | weight_filler {
324 | type: "msra"
325 | }
326 | bias_filler {
327 | type: "constant"
328 | value: 0.0
329 | }
330 | }
331 | }
332 | layer {
333 | name: "conv5/dw/relu"
334 | type: "ReLU"
335 | bottom: "conv5/dw"
336 | top: "conv5/dw"
337 | }
338 | layer {
339 | name: "conv5"
340 | type: "Convolution"
341 | bottom: "conv5/dw"
342 | top: "conv5"
343 | param {
344 | lr_mult: 1.0
345 | decay_mult: 1.0
346 | }
347 | param {
348 | lr_mult: 2.0
349 | decay_mult: 0.0
350 | }
351 | convolution_param {
352 | num_output: 256
353 | kernel_size: 1
354 | weight_filler {
355 | type: "msra"
356 | }
357 | bias_filler {
358 | type: "constant"
359 | value: 0.0
360 | }
361 | }
362 | }
363 | layer {
364 | name: "conv5/relu"
365 | type: "ReLU"
366 | bottom: "conv5"
367 | top: "conv5"
368 | }
369 | layer {
370 | name: "conv6/dw"
371 | type: "Convolution"
372 | bottom: "conv5"
373 | top: "conv6/dw"
374 | param {
375 | lr_mult: 1.0
376 | decay_mult: 1.0
377 | }
378 | param {
379 | lr_mult: 2.0
380 | decay_mult: 0.0
381 | }
382 | convolution_param {
383 | num_output: 256
384 | pad: 1
385 | kernel_size: 3
386 | stride: 2
387 | group: 256
388 | engine: CAFFE
389 | weight_filler {
390 | type: "msra"
391 | }
392 | bias_filler {
393 | type: "constant"
394 | value: 0.0
395 | }
396 | }
397 | }
398 | layer {
399 | name: "conv6/dw/relu"
400 | type: "ReLU"
401 | bottom: "conv6/dw"
402 | top: "conv6/dw"
403 | }
404 | layer {
405 | name: "conv6"
406 | type: "Convolution"
407 | bottom: "conv6/dw"
408 | top: "conv6"
409 | param {
410 | lr_mult: 1.0
411 | decay_mult: 1.0
412 | }
413 | param {
414 | lr_mult: 2.0
415 | decay_mult: 0.0
416 | }
417 | convolution_param {
418 | num_output: 512
419 | kernel_size: 1
420 | weight_filler {
421 | type: "msra"
422 | }
423 | bias_filler {
424 | type: "constant"
425 | value: 0.0
426 | }
427 | }
428 | }
429 | layer {
430 | name: "conv6/relu"
431 | type: "ReLU"
432 | bottom: "conv6"
433 | top: "conv6"
434 | }
435 | layer {
436 | name: "conv7/dw"
437 | type: "Convolution"
438 | bottom: "conv6"
439 | top: "conv7/dw"
440 | param {
441 | lr_mult: 1.0
442 | decay_mult: 1.0
443 | }
444 | param {
445 | lr_mult: 2.0
446 | decay_mult: 0.0
447 | }
448 | convolution_param {
449 | num_output: 512
450 | pad: 1
451 | kernel_size: 3
452 | group: 512
453 | engine: CAFFE
454 | weight_filler {
455 | type: "msra"
456 | }
457 | bias_filler {
458 | type: "constant"
459 | value: 0.0
460 | }
461 | }
462 | }
463 | layer {
464 | name: "conv7/dw/relu"
465 | type: "ReLU"
466 | bottom: "conv7/dw"
467 | top: "conv7/dw"
468 | }
469 | layer {
470 | name: "conv7"
471 | type: "Convolution"
472 | bottom: "conv7/dw"
473 | top: "conv7"
474 | param {
475 | lr_mult: 1.0
476 | decay_mult: 1.0
477 | }
478 | param {
479 | lr_mult: 2.0
480 | decay_mult: 0.0
481 | }
482 | convolution_param {
483 | num_output: 512
484 | kernel_size: 1
485 | weight_filler {
486 | type: "msra"
487 | }
488 | bias_filler {
489 | type: "constant"
490 | value: 0.0
491 | }
492 | }
493 | }
494 | layer {
495 | name: "conv7/relu"
496 | type: "ReLU"
497 | bottom: "conv7"
498 | top: "conv7"
499 | }
500 | layer {
501 | name: "conv8/dw"
502 | type: "Convolution"
503 | bottom: "conv7"
504 | top: "conv8/dw"
505 | param {
506 | lr_mult: 1.0
507 | decay_mult: 1.0
508 | }
509 | param {
510 | lr_mult: 2.0
511 | decay_mult: 0.0
512 | }
513 | convolution_param {
514 | num_output: 512
515 | pad: 1
516 | kernel_size: 3
517 | group: 512
518 | engine: CAFFE
519 | weight_filler {
520 | type: "msra"
521 | }
522 | bias_filler {
523 | type: "constant"
524 | value: 0.0
525 | }
526 | }
527 | }
528 | layer {
529 | name: "conv8/dw/relu"
530 | type: "ReLU"
531 | bottom: "conv8/dw"
532 | top: "conv8/dw"
533 | }
534 | layer {
535 | name: "conv8"
536 | type: "Convolution"
537 | bottom: "conv8/dw"
538 | top: "conv8"
539 | param {
540 | lr_mult: 1.0
541 | decay_mult: 1.0
542 | }
543 | param {
544 | lr_mult: 2.0
545 | decay_mult: 0.0
546 | }
547 | convolution_param {
548 | num_output: 512
549 | kernel_size: 1
550 | weight_filler {
551 | type: "msra"
552 | }
553 | bias_filler {
554 | type: "constant"
555 | value: 0.0
556 | }
557 | }
558 | }
559 | layer {
560 | name: "conv8/relu"
561 | type: "ReLU"
562 | bottom: "conv8"
563 | top: "conv8"
564 | }
565 | layer {
566 | name: "conv9/dw"
567 | type: "Convolution"
568 | bottom: "conv8"
569 | top: "conv9/dw"
570 | param {
571 | lr_mult: 1.0
572 | decay_mult: 1.0
573 | }
574 | param {
575 | lr_mult: 2.0
576 | decay_mult: 0.0
577 | }
578 | convolution_param {
579 | num_output: 512
580 | pad: 1
581 | kernel_size: 3
582 | group: 512
583 | engine: CAFFE
584 | weight_filler {
585 | type: "msra"
586 | }
587 | bias_filler {
588 | type: "constant"
589 | value: 0.0
590 | }
591 | }
592 | }
593 | layer {
594 | name: "conv9/dw/relu"
595 | type: "ReLU"
596 | bottom: "conv9/dw"
597 | top: "conv9/dw"
598 | }
599 | layer {
600 | name: "conv9"
601 | type: "Convolution"
602 | bottom: "conv9/dw"
603 | top: "conv9"
604 | param {
605 | lr_mult: 1.0
606 | decay_mult: 1.0
607 | }
608 | param {
609 | lr_mult: 2.0
610 | decay_mult: 0.0
611 | }
612 | convolution_param {
613 | num_output: 512
614 | kernel_size: 1
615 | weight_filler {
616 | type: "msra"
617 | }
618 | bias_filler {
619 | type: "constant"
620 | value: 0.0
621 | }
622 | }
623 | }
624 | layer {
625 | name: "conv9/relu"
626 | type: "ReLU"
627 | bottom: "conv9"
628 | top: "conv9"
629 | }
630 | layer {
631 | name: "conv10/dw"
632 | type: "Convolution"
633 | bottom: "conv9"
634 | top: "conv10/dw"
635 | param {
636 | lr_mult: 1.0
637 | decay_mult: 1.0
638 | }
639 | param {
640 | lr_mult: 2.0
641 | decay_mult: 0.0
642 | }
643 | convolution_param {
644 | num_output: 512
645 | pad: 1
646 | kernel_size: 3
647 | group: 512
648 | engine: CAFFE
649 | weight_filler {
650 | type: "msra"
651 | }
652 | bias_filler {
653 | type: "constant"
654 | value: 0.0
655 | }
656 | }
657 | }
658 | layer {
659 | name: "conv10/dw/relu"
660 | type: "ReLU"
661 | bottom: "conv10/dw"
662 | top: "conv10/dw"
663 | }
664 | layer {
665 | name: "conv10"
666 | type: "Convolution"
667 | bottom: "conv10/dw"
668 | top: "conv10"
669 | param {
670 | lr_mult: 1.0
671 | decay_mult: 1.0
672 | }
673 | param {
674 | lr_mult: 2.0
675 | decay_mult: 0.0
676 | }
677 | convolution_param {
678 | num_output: 512
679 | kernel_size: 1
680 | weight_filler {
681 | type: "msra"
682 | }
683 | bias_filler {
684 | type: "constant"
685 | value: 0.0
686 | }
687 | }
688 | }
689 | layer {
690 | name: "conv10/relu"
691 | type: "ReLU"
692 | bottom: "conv10"
693 | top: "conv10"
694 | }
695 | layer {
696 | name: "conv11/dw"
697 | type: "Convolution"
698 | bottom: "conv10"
699 | top: "conv11/dw"
700 | param {
701 | lr_mult: 1.0
702 | decay_mult: 1.0
703 | }
704 | param {
705 | lr_mult: 2.0
706 | decay_mult: 0.0
707 | }
708 | convolution_param {
709 | num_output: 512
710 | pad: 1
711 | kernel_size: 3
712 | group: 512
713 | engine: CAFFE
714 | weight_filler {
715 | type: "msra"
716 | }
717 | bias_filler {
718 | type: "constant"
719 | value: 0.0
720 | }
721 | }
722 | }
723 | layer {
724 | name: "conv11/dw/relu"
725 | type: "ReLU"
726 | bottom: "conv11/dw"
727 | top: "conv11/dw"
728 | }
729 | layer {
730 | name: "conv11"
731 | type: "Convolution"
732 | bottom: "conv11/dw"
733 | top: "conv11"
734 | param {
735 | lr_mult: 1.0
736 | decay_mult: 1.0
737 | }
738 | param {
739 | lr_mult: 2.0
740 | decay_mult: 0.0
741 | }
742 | convolution_param {
743 | num_output: 512
744 | kernel_size: 1
745 | weight_filler {
746 | type: "msra"
747 | }
748 | bias_filler {
749 | type: "constant"
750 | value: 0.0
751 | }
752 | }
753 | }
754 | layer {
755 | name: "conv11/relu"
756 | type: "ReLU"
757 | bottom: "conv11"
758 | top: "conv11"
759 | }
760 | layer {
761 | name: "conv12/dw"
762 | type: "Convolution"
763 | bottom: "conv11"
764 | top: "conv12/dw"
765 | param {
766 | lr_mult: 1.0
767 | decay_mult: 1.0
768 | }
769 | param {
770 | lr_mult: 2.0
771 | decay_mult: 0.0
772 | }
773 | convolution_param {
774 | num_output: 512
775 | pad: 1
776 | kernel_size: 3
777 | stride: 2
778 | group: 512
779 | engine: CAFFE
780 | weight_filler {
781 | type: "msra"
782 | }
783 | bias_filler {
784 | type: "constant"
785 | value: 0.0
786 | }
787 | }
788 | }
789 | layer {
790 | name: "conv12/dw/relu"
791 | type: "ReLU"
792 | bottom: "conv12/dw"
793 | top: "conv12/dw"
794 | }
795 | layer {
796 | name: "conv12"
797 | type: "Convolution"
798 | bottom: "conv12/dw"
799 | top: "conv12"
800 | param {
801 | lr_mult: 1.0
802 | decay_mult: 1.0
803 | }
804 | param {
805 | lr_mult: 2.0
806 | decay_mult: 0.0
807 | }
808 | convolution_param {
809 | num_output: 1024
810 | kernel_size: 1
811 | weight_filler {
812 | type: "msra"
813 | }
814 | bias_filler {
815 | type: "constant"
816 | value: 0.0
817 | }
818 | }
819 | }
820 | layer {
821 | name: "conv12/relu"
822 | type: "ReLU"
823 | bottom: "conv12"
824 | top: "conv12"
825 | }
826 | layer {
827 | name: "conv13/dw"
828 | type: "Convolution"
829 | bottom: "conv12"
830 | top: "conv13/dw"
831 | param {
832 | lr_mult: 1.0
833 | decay_mult: 1.0
834 | }
835 | param {
836 | lr_mult: 2.0
837 | decay_mult: 0.0
838 | }
839 | convolution_param {
840 | num_output: 1024
841 | pad: 1
842 | kernel_size: 3
843 | group: 1024
844 | engine: CAFFE
845 | weight_filler {
846 | type: "msra"
847 | }
848 | bias_filler {
849 | type: "constant"
850 | value: 0.0
851 | }
852 | }
853 | }
854 | layer {
855 | name: "conv13/dw/relu"
856 | type: "ReLU"
857 | bottom: "conv13/dw"
858 | top: "conv13/dw"
859 | }
860 | layer {
861 | name: "conv13"
862 | type: "Convolution"
863 | bottom: "conv13/dw"
864 | top: "conv13"
865 | param {
866 | lr_mult: 1.0
867 | decay_mult: 1.0
868 | }
869 | param {
870 | lr_mult: 2.0
871 | decay_mult: 0.0
872 | }
873 | convolution_param {
874 | num_output: 1024
875 | kernel_size: 1
876 | weight_filler {
877 | type: "msra"
878 | }
879 | bias_filler {
880 | type: "constant"
881 | value: 0.0
882 | }
883 | }
884 | }
885 | layer {
886 | name: "conv13/relu"
887 | type: "ReLU"
888 | bottom: "conv13"
889 | top: "conv13"
890 | }
891 | layer {
892 | name: "conv14_1"
893 | type: "Convolution"
894 | bottom: "conv13"
895 | top: "conv14_1"
896 | param {
897 | lr_mult: 1.0
898 | decay_mult: 1.0
899 | }
900 | param {
901 | lr_mult: 2.0
902 | decay_mult: 0.0
903 | }
904 | convolution_param {
905 | num_output: 256
906 | kernel_size: 1
907 | weight_filler {
908 | type: "msra"
909 | }
910 | bias_filler {
911 | type: "constant"
912 | value: 0.0
913 | }
914 | }
915 | }
916 | layer {
917 | name: "conv14_1/relu"
918 | type: "ReLU"
919 | bottom: "conv14_1"
920 | top: "conv14_1"
921 | }
922 | layer {
923 | name: "conv14_2"
924 | type: "Convolution"
925 | bottom: "conv14_1"
926 | top: "conv14_2"
927 | param {
928 | lr_mult: 1.0
929 | decay_mult: 1.0
930 | }
931 | param {
932 | lr_mult: 2.0
933 | decay_mult: 0.0
934 | }
935 | convolution_param {
936 | num_output: 512
937 | pad: 1
938 | kernel_size: 3
939 | stride: 2
940 | weight_filler {
941 | type: "msra"
942 | }
943 | bias_filler {
944 | type: "constant"
945 | value: 0.0
946 | }
947 | }
948 | }
949 | layer {
950 | name: "conv14_2/relu"
951 | type: "ReLU"
952 | bottom: "conv14_2"
953 | top: "conv14_2"
954 | }
955 | layer {
956 | name: "conv15_1"
957 | type: "Convolution"
958 | bottom: "conv14_2"
959 | top: "conv15_1"
960 | param {
961 | lr_mult: 1.0
962 | decay_mult: 1.0
963 | }
964 | param {
965 | lr_mult: 2.0
966 | decay_mult: 0.0
967 | }
968 | convolution_param {
969 | num_output: 128
970 | kernel_size: 1
971 | weight_filler {
972 | type: "msra"
973 | }
974 | bias_filler {
975 | type: "constant"
976 | value: 0.0
977 | }
978 | }
979 | }
980 | layer {
981 | name: "conv15_1/relu"
982 | type: "ReLU"
983 | bottom: "conv15_1"
984 | top: "conv15_1"
985 | }
986 | layer {
987 | name: "conv15_2"
988 | type: "Convolution"
989 | bottom: "conv15_1"
990 | top: "conv15_2"
991 | param {
992 | lr_mult: 1.0
993 | decay_mult: 1.0
994 | }
995 | param {
996 | lr_mult: 2.0
997 | decay_mult: 0.0
998 | }
999 | convolution_param {
1000 | num_output: 256
1001 | pad: 1
1002 | kernel_size: 3
1003 | stride: 2
1004 | weight_filler {
1005 | type: "msra"
1006 | }
1007 | bias_filler {
1008 | type: "constant"
1009 | value: 0.0
1010 | }
1011 | }
1012 | }
1013 | layer {
1014 | name: "conv15_2/relu"
1015 | type: "ReLU"
1016 | bottom: "conv15_2"
1017 | top: "conv15_2"
1018 | }
1019 | layer {
1020 | name: "conv16_1"
1021 | type: "Convolution"
1022 | bottom: "conv15_2"
1023 | top: "conv16_1"
1024 | param {
1025 | lr_mult: 1.0
1026 | decay_mult: 1.0
1027 | }
1028 | param {
1029 | lr_mult: 2.0
1030 | decay_mult: 0.0
1031 | }
1032 | convolution_param {
1033 | num_output: 128
1034 | kernel_size: 1
1035 | weight_filler {
1036 | type: "msra"
1037 | }
1038 | bias_filler {
1039 | type: "constant"
1040 | value: 0.0
1041 | }
1042 | }
1043 | }
1044 | layer {
1045 | name: "conv16_1/relu"
1046 | type: "ReLU"
1047 | bottom: "conv16_1"
1048 | top: "conv16_1"
1049 | }
1050 | layer {
1051 | name: "conv16_2"
1052 | type: "Convolution"
1053 | bottom: "conv16_1"
1054 | top: "conv16_2"
1055 | param {
1056 | lr_mult: 1.0
1057 | decay_mult: 1.0
1058 | }
1059 | param {
1060 | lr_mult: 2.0
1061 | decay_mult: 0.0
1062 | }
1063 | convolution_param {
1064 | num_output: 256
1065 | pad: 1
1066 | kernel_size: 3
1067 | stride: 2
1068 | weight_filler {
1069 | type: "msra"
1070 | }
1071 | bias_filler {
1072 | type: "constant"
1073 | value: 0.0
1074 | }
1075 | }
1076 | }
1077 | layer {
1078 | name: "conv16_2/relu"
1079 | type: "ReLU"
1080 | bottom: "conv16_2"
1081 | top: "conv16_2"
1082 | }
1083 | layer {
1084 | name: "conv17_1"
1085 | type: "Convolution"
1086 | bottom: "conv16_2"
1087 | top: "conv17_1"
1088 | param {
1089 | lr_mult: 1.0
1090 | decay_mult: 1.0
1091 | }
1092 | param {
1093 | lr_mult: 2.0
1094 | decay_mult: 0.0
1095 | }
1096 | convolution_param {
1097 | num_output: 64
1098 | kernel_size: 1
1099 | weight_filler {
1100 | type: "msra"
1101 | }
1102 | bias_filler {
1103 | type: "constant"
1104 | value: 0.0
1105 | }
1106 | }
1107 | }
1108 | layer {
1109 | name: "conv17_1/relu"
1110 | type: "ReLU"
1111 | bottom: "conv17_1"
1112 | top: "conv17_1"
1113 | }
1114 | layer {
1115 | name: "conv17_2"
1116 | type: "Convolution"
1117 | bottom: "conv17_1"
1118 | top: "conv17_2"
1119 | param {
1120 | lr_mult: 1.0
1121 | decay_mult: 1.0
1122 | }
1123 | param {
1124 | lr_mult: 2.0
1125 | decay_mult: 0.0
1126 | }
1127 | convolution_param {
1128 | num_output: 128
1129 | pad: 1
1130 | kernel_size: 3
1131 | stride: 2
1132 | weight_filler {
1133 | type: "msra"
1134 | }
1135 | bias_filler {
1136 | type: "constant"
1137 | value: 0.0
1138 | }
1139 | }
1140 | }
1141 | layer {
1142 | name: "conv17_2/relu"
1143 | type: "ReLU"
1144 | bottom: "conv17_2"
1145 | top: "conv17_2"
1146 | }
1147 | layer {
1148 | name: "conv11_mbox_loc"
1149 | type: "Convolution"
1150 | bottom: "conv11"
1151 | top: "conv11_mbox_loc"
1152 | param {
1153 | lr_mult: 1.0
1154 | decay_mult: 1.0
1155 | }
1156 | param {
1157 | lr_mult: 2.0
1158 | decay_mult: 0.0
1159 | }
1160 | convolution_param {
1161 | num_output: 12
1162 | kernel_size: 1
1163 | weight_filler {
1164 | type: "msra"
1165 | }
1166 | bias_filler {
1167 | type: "constant"
1168 | value: 0.0
1169 | }
1170 | }
1171 | }
1172 | layer {
1173 | name: "conv11_mbox_loc_perm"
1174 | type: "Permute"
1175 | bottom: "conv11_mbox_loc"
1176 | top: "conv11_mbox_loc_perm"
1177 | permute_param {
1178 | order: 0
1179 | order: 2
1180 | order: 3
1181 | order: 1
1182 | }
1183 | }
1184 | layer {
1185 | name: "conv11_mbox_loc_flat"
1186 | type: "Flatten"
1187 | bottom: "conv11_mbox_loc_perm"
1188 | top: "conv11_mbox_loc_flat"
1189 | flatten_param {
1190 | axis: 1
1191 | }
1192 | }
1193 | layer {
1194 | name: "conv11_mbox_conf"
1195 | type: "Convolution"
1196 | bottom: "conv11"
1197 | top: "conv11_mbox_conf"
1198 | param {
1199 | lr_mult: 1.0
1200 | decay_mult: 1.0
1201 | }
1202 | param {
1203 | lr_mult: 2.0
1204 | decay_mult: 0.0
1205 | }
1206 | convolution_param {
1207 | num_output: 63
1208 | kernel_size: 1
1209 | weight_filler {
1210 | type: "msra"
1211 | }
1212 | bias_filler {
1213 | type: "constant"
1214 | value: 0.0
1215 | }
1216 | }
1217 | }
1218 | layer {
1219 | name: "conv11_mbox_conf_perm"
1220 | type: "Permute"
1221 | bottom: "conv11_mbox_conf"
1222 | top: "conv11_mbox_conf_perm"
1223 | permute_param {
1224 | order: 0
1225 | order: 2
1226 | order: 3
1227 | order: 1
1228 | }
1229 | }
1230 | layer {
1231 | name: "conv11_mbox_conf_flat"
1232 | type: "Flatten"
1233 | bottom: "conv11_mbox_conf_perm"
1234 | top: "conv11_mbox_conf_flat"
1235 | flatten_param {
1236 | axis: 1
1237 | }
1238 | }
1239 | layer {
1240 | name: "conv11_mbox_priorbox"
1241 | type: "PriorBox"
1242 | bottom: "conv11"
1243 | bottom: "data"
1244 | top: "conv11_mbox_priorbox"
1245 | prior_box_param {
1246 | min_size: 60.0
1247 | aspect_ratio: 2.0
1248 | flip: true
1249 | clip: false
1250 | variance: 0.1
1251 | variance: 0.1
1252 | variance: 0.2
1253 | variance: 0.2
1254 | offset: 0.5
1255 | }
1256 | }
1257 | layer {
1258 | name: "conv13_mbox_loc"
1259 | type: "Convolution"
1260 | bottom: "conv13"
1261 | top: "conv13_mbox_loc"
1262 | param {
1263 | lr_mult: 1.0
1264 | decay_mult: 1.0
1265 | }
1266 | param {
1267 | lr_mult: 2.0
1268 | decay_mult: 0.0
1269 | }
1270 | convolution_param {
1271 | num_output: 24
1272 | kernel_size: 1
1273 | weight_filler {
1274 | type: "msra"
1275 | }
1276 | bias_filler {
1277 | type: "constant"
1278 | value: 0.0
1279 | }
1280 | }
1281 | }
1282 | layer {
1283 | name: "conv13_mbox_loc_perm"
1284 | type: "Permute"
1285 | bottom: "conv13_mbox_loc"
1286 | top: "conv13_mbox_loc_perm"
1287 | permute_param {
1288 | order: 0
1289 | order: 2
1290 | order: 3
1291 | order: 1
1292 | }
1293 | }
1294 | layer {
1295 | name: "conv13_mbox_loc_flat"
1296 | type: "Flatten"
1297 | bottom: "conv13_mbox_loc_perm"
1298 | top: "conv13_mbox_loc_flat"
1299 | flatten_param {
1300 | axis: 1
1301 | }
1302 | }
1303 | layer {
1304 | name: "conv13_mbox_conf"
1305 | type: "Convolution"
1306 | bottom: "conv13"
1307 | top: "conv13_mbox_conf"
1308 | param {
1309 | lr_mult: 1.0
1310 | decay_mult: 1.0
1311 | }
1312 | param {
1313 | lr_mult: 2.0
1314 | decay_mult: 0.0
1315 | }
1316 | convolution_param {
1317 | num_output: 126
1318 | kernel_size: 1
1319 | weight_filler {
1320 | type: "msra"
1321 | }
1322 | bias_filler {
1323 | type: "constant"
1324 | value: 0.0
1325 | }
1326 | }
1327 | }
1328 | layer {
1329 | name: "conv13_mbox_conf_perm"
1330 | type: "Permute"
1331 | bottom: "conv13_mbox_conf"
1332 | top: "conv13_mbox_conf_perm"
1333 | permute_param {
1334 | order: 0
1335 | order: 2
1336 | order: 3
1337 | order: 1
1338 | }
1339 | }
1340 | layer {
1341 | name: "conv13_mbox_conf_flat"
1342 | type: "Flatten"
1343 | bottom: "conv13_mbox_conf_perm"
1344 | top: "conv13_mbox_conf_flat"
1345 | flatten_param {
1346 | axis: 1
1347 | }
1348 | }
1349 | layer {
1350 | name: "conv13_mbox_priorbox"
1351 | type: "PriorBox"
1352 | bottom: "conv13"
1353 | bottom: "data"
1354 | top: "conv13_mbox_priorbox"
1355 | prior_box_param {
1356 | min_size: 105.0
1357 | max_size: 150.0
1358 | aspect_ratio: 2.0
1359 | aspect_ratio: 3.0
1360 | flip: true
1361 | clip: false
1362 | variance: 0.1
1363 | variance: 0.1
1364 | variance: 0.2
1365 | variance: 0.2
1366 | offset: 0.5
1367 | }
1368 | }
1369 | layer {
1370 | name: "conv14_2_mbox_loc"
1371 | type: "Convolution"
1372 | bottom: "conv14_2"
1373 | top: "conv14_2_mbox_loc"
1374 | param {
1375 | lr_mult: 1.0
1376 | decay_mult: 1.0
1377 | }
1378 | param {
1379 | lr_mult: 2.0
1380 | decay_mult: 0.0
1381 | }
1382 | convolution_param {
1383 | num_output: 24
1384 | kernel_size: 1
1385 | weight_filler {
1386 | type: "msra"
1387 | }
1388 | bias_filler {
1389 | type: "constant"
1390 | value: 0.0
1391 | }
1392 | }
1393 | }
1394 | layer {
1395 | name: "conv14_2_mbox_loc_perm"
1396 | type: "Permute"
1397 | bottom: "conv14_2_mbox_loc"
1398 | top: "conv14_2_mbox_loc_perm"
1399 | permute_param {
1400 | order: 0
1401 | order: 2
1402 | order: 3
1403 | order: 1
1404 | }
1405 | }
1406 | layer {
1407 | name: "conv14_2_mbox_loc_flat"
1408 | type: "Flatten"
1409 | bottom: "conv14_2_mbox_loc_perm"
1410 | top: "conv14_2_mbox_loc_flat"
1411 | flatten_param {
1412 | axis: 1
1413 | }
1414 | }
1415 | layer {
1416 | name: "conv14_2_mbox_conf"
1417 | type: "Convolution"
1418 | bottom: "conv14_2"
1419 | top: "conv14_2_mbox_conf"
1420 | param {
1421 | lr_mult: 1.0
1422 | decay_mult: 1.0
1423 | }
1424 | param {
1425 | lr_mult: 2.0
1426 | decay_mult: 0.0
1427 | }
1428 | convolution_param {
1429 | num_output: 126
1430 | kernel_size: 1
1431 | weight_filler {
1432 | type: "msra"
1433 | }
1434 | bias_filler {
1435 | type: "constant"
1436 | value: 0.0
1437 | }
1438 | }
1439 | }
1440 | layer {
1441 | name: "conv14_2_mbox_conf_perm"
1442 | type: "Permute"
1443 | bottom: "conv14_2_mbox_conf"
1444 | top: "conv14_2_mbox_conf_perm"
1445 | permute_param {
1446 | order: 0
1447 | order: 2
1448 | order: 3
1449 | order: 1
1450 | }
1451 | }
1452 | layer {
1453 | name: "conv14_2_mbox_conf_flat"
1454 | type: "Flatten"
1455 | bottom: "conv14_2_mbox_conf_perm"
1456 | top: "conv14_2_mbox_conf_flat"
1457 | flatten_param {
1458 | axis: 1
1459 | }
1460 | }
1461 | layer {
1462 | name: "conv14_2_mbox_priorbox"
1463 | type: "PriorBox"
1464 | bottom: "conv14_2"
1465 | bottom: "data"
1466 | top: "conv14_2_mbox_priorbox"
1467 | prior_box_param {
1468 | min_size: 150.0
1469 | max_size: 195.0
1470 | aspect_ratio: 2.0
1471 | aspect_ratio: 3.0
1472 | flip: true
1473 | clip: false
1474 | variance: 0.1
1475 | variance: 0.1
1476 | variance: 0.2
1477 | variance: 0.2
1478 | offset: 0.5
1479 | }
1480 | }
1481 | layer {
1482 | name: "conv15_2_mbox_loc"
1483 | type: "Convolution"
1484 | bottom: "conv15_2"
1485 | top: "conv15_2_mbox_loc"
1486 | param {
1487 | lr_mult: 1.0
1488 | decay_mult: 1.0
1489 | }
1490 | param {
1491 | lr_mult: 2.0
1492 | decay_mult: 0.0
1493 | }
1494 | convolution_param {
1495 | num_output: 24
1496 | kernel_size: 1
1497 | weight_filler {
1498 | type: "msra"
1499 | }
1500 | bias_filler {
1501 | type: "constant"
1502 | value: 0.0
1503 | }
1504 | }
1505 | }
1506 | layer {
1507 | name: "conv15_2_mbox_loc_perm"
1508 | type: "Permute"
1509 | bottom: "conv15_2_mbox_loc"
1510 | top: "conv15_2_mbox_loc_perm"
1511 | permute_param {
1512 | order: 0
1513 | order: 2
1514 | order: 3
1515 | order: 1
1516 | }
1517 | }
1518 | layer {
1519 | name: "conv15_2_mbox_loc_flat"
1520 | type: "Flatten"
1521 | bottom: "conv15_2_mbox_loc_perm"
1522 | top: "conv15_2_mbox_loc_flat"
1523 | flatten_param {
1524 | axis: 1
1525 | }
1526 | }
1527 | layer {
1528 | name: "conv15_2_mbox_conf"
1529 | type: "Convolution"
1530 | bottom: "conv15_2"
1531 | top: "conv15_2_mbox_conf"
1532 | param {
1533 | lr_mult: 1.0
1534 | decay_mult: 1.0
1535 | }
1536 | param {
1537 | lr_mult: 2.0
1538 | decay_mult: 0.0
1539 | }
1540 | convolution_param {
1541 | num_output: 126
1542 | kernel_size: 1
1543 | weight_filler {
1544 | type: "msra"
1545 | }
1546 | bias_filler {
1547 | type: "constant"
1548 | value: 0.0
1549 | }
1550 | }
1551 | }
1552 | layer {
1553 | name: "conv15_2_mbox_conf_perm"
1554 | type: "Permute"
1555 | bottom: "conv15_2_mbox_conf"
1556 | top: "conv15_2_mbox_conf_perm"
1557 | permute_param {
1558 | order: 0
1559 | order: 2
1560 | order: 3
1561 | order: 1
1562 | }
1563 | }
1564 | layer {
1565 | name: "conv15_2_mbox_conf_flat"
1566 | type: "Flatten"
1567 | bottom: "conv15_2_mbox_conf_perm"
1568 | top: "conv15_2_mbox_conf_flat"
1569 | flatten_param {
1570 | axis: 1
1571 | }
1572 | }
1573 | layer {
1574 | name: "conv15_2_mbox_priorbox"
1575 | type: "PriorBox"
1576 | bottom: "conv15_2"
1577 | bottom: "data"
1578 | top: "conv15_2_mbox_priorbox"
1579 | prior_box_param {
1580 | min_size: 195.0
1581 | max_size: 240.0
1582 | aspect_ratio: 2.0
1583 | aspect_ratio: 3.0
1584 | flip: true
1585 | clip: false
1586 | variance: 0.1
1587 | variance: 0.1
1588 | variance: 0.2
1589 | variance: 0.2
1590 | offset: 0.5
1591 | }
1592 | }
1593 | layer {
1594 | name: "conv16_2_mbox_loc"
1595 | type: "Convolution"
1596 | bottom: "conv16_2"
1597 | top: "conv16_2_mbox_loc"
1598 | param {
1599 | lr_mult: 1.0
1600 | decay_mult: 1.0
1601 | }
1602 | param {
1603 | lr_mult: 2.0
1604 | decay_mult: 0.0
1605 | }
1606 | convolution_param {
1607 | num_output: 24
1608 | kernel_size: 1
1609 | weight_filler {
1610 | type: "msra"
1611 | }
1612 | bias_filler {
1613 | type: "constant"
1614 | value: 0.0
1615 | }
1616 | }
1617 | }
1618 | layer {
1619 | name: "conv16_2_mbox_loc_perm"
1620 | type: "Permute"
1621 | bottom: "conv16_2_mbox_loc"
1622 | top: "conv16_2_mbox_loc_perm"
1623 | permute_param {
1624 | order: 0
1625 | order: 2
1626 | order: 3
1627 | order: 1
1628 | }
1629 | }
1630 | layer {
1631 | name: "conv16_2_mbox_loc_flat"
1632 | type: "Flatten"
1633 | bottom: "conv16_2_mbox_loc_perm"
1634 | top: "conv16_2_mbox_loc_flat"
1635 | flatten_param {
1636 | axis: 1
1637 | }
1638 | }
1639 | layer {
1640 | name: "conv16_2_mbox_conf"
1641 | type: "Convolution"
1642 | bottom: "conv16_2"
1643 | top: "conv16_2_mbox_conf"
1644 | param {
1645 | lr_mult: 1.0
1646 | decay_mult: 1.0
1647 | }
1648 | param {
1649 | lr_mult: 2.0
1650 | decay_mult: 0.0
1651 | }
1652 | convolution_param {
1653 | num_output: 126
1654 | kernel_size: 1
1655 | weight_filler {
1656 | type: "msra"
1657 | }
1658 | bias_filler {
1659 | type: "constant"
1660 | value: 0.0
1661 | }
1662 | }
1663 | }
1664 | layer {
1665 | name: "conv16_2_mbox_conf_perm"
1666 | type: "Permute"
1667 | bottom: "conv16_2_mbox_conf"
1668 | top: "conv16_2_mbox_conf_perm"
1669 | permute_param {
1670 | order: 0
1671 | order: 2
1672 | order: 3
1673 | order: 1
1674 | }
1675 | }
1676 | layer {
1677 | name: "conv16_2_mbox_conf_flat"
1678 | type: "Flatten"
1679 | bottom: "conv16_2_mbox_conf_perm"
1680 | top: "conv16_2_mbox_conf_flat"
1681 | flatten_param {
1682 | axis: 1
1683 | }
1684 | }
1685 | layer {
1686 | name: "conv16_2_mbox_priorbox"
1687 | type: "PriorBox"
1688 | bottom: "conv16_2"
1689 | bottom: "data"
1690 | top: "conv16_2_mbox_priorbox"
1691 | prior_box_param {
1692 | min_size: 240.0
1693 | max_size: 285.0
1694 | aspect_ratio: 2.0
1695 | aspect_ratio: 3.0
1696 | flip: true
1697 | clip: false
1698 | variance: 0.1
1699 | variance: 0.1
1700 | variance: 0.2
1701 | variance: 0.2
1702 | offset: 0.5
1703 | }
1704 | }
1705 | layer {
1706 | name: "conv17_2_mbox_loc"
1707 | type: "Convolution"
1708 | bottom: "conv17_2"
1709 | top: "conv17_2_mbox_loc"
1710 | param {
1711 | lr_mult: 1.0
1712 | decay_mult: 1.0
1713 | }
1714 | param {
1715 | lr_mult: 2.0
1716 | decay_mult: 0.0
1717 | }
1718 | convolution_param {
1719 | num_output: 24
1720 | kernel_size: 1
1721 | weight_filler {
1722 | type: "msra"
1723 | }
1724 | bias_filler {
1725 | type: "constant"
1726 | value: 0.0
1727 | }
1728 | }
1729 | }
1730 | layer {
1731 | name: "conv17_2_mbox_loc_perm"
1732 | type: "Permute"
1733 | bottom: "conv17_2_mbox_loc"
1734 | top: "conv17_2_mbox_loc_perm"
1735 | permute_param {
1736 | order: 0
1737 | order: 2
1738 | order: 3
1739 | order: 1
1740 | }
1741 | }
1742 | layer {
1743 | name: "conv17_2_mbox_loc_flat"
1744 | type: "Flatten"
1745 | bottom: "conv17_2_mbox_loc_perm"
1746 | top: "conv17_2_mbox_loc_flat"
1747 | flatten_param {
1748 | axis: 1
1749 | }
1750 | }
1751 | layer {
1752 | name: "conv17_2_mbox_conf"
1753 | type: "Convolution"
1754 | bottom: "conv17_2"
1755 | top: "conv17_2_mbox_conf"
1756 | param {
1757 | lr_mult: 1.0
1758 | decay_mult: 1.0
1759 | }
1760 | param {
1761 | lr_mult: 2.0
1762 | decay_mult: 0.0
1763 | }
1764 | convolution_param {
1765 | num_output: 126
1766 | kernel_size: 1
1767 | weight_filler {
1768 | type: "msra"
1769 | }
1770 | bias_filler {
1771 | type: "constant"
1772 | value: 0.0
1773 | }
1774 | }
1775 | }
1776 | layer {
1777 | name: "conv17_2_mbox_conf_perm"
1778 | type: "Permute"
1779 | bottom: "conv17_2_mbox_conf"
1780 | top: "conv17_2_mbox_conf_perm"
1781 | permute_param {
1782 | order: 0
1783 | order: 2
1784 | order: 3
1785 | order: 1
1786 | }
1787 | }
1788 | layer {
1789 | name: "conv17_2_mbox_conf_flat"
1790 | type: "Flatten"
1791 | bottom: "conv17_2_mbox_conf_perm"
1792 | top: "conv17_2_mbox_conf_flat"
1793 | flatten_param {
1794 | axis: 1
1795 | }
1796 | }
1797 | layer {
1798 | name: "conv17_2_mbox_priorbox"
1799 | type: "PriorBox"
1800 | bottom: "conv17_2"
1801 | bottom: "data"
1802 | top: "conv17_2_mbox_priorbox"
1803 | prior_box_param {
1804 | min_size: 285.0
1805 | max_size: 300.0
1806 | aspect_ratio: 2.0
1807 | aspect_ratio: 3.0
1808 | flip: true
1809 | clip: false
1810 | variance: 0.1
1811 | variance: 0.1
1812 | variance: 0.2
1813 | variance: 0.2
1814 | offset: 0.5
1815 | }
1816 | }
1817 | layer {
1818 | name: "mbox_loc"
1819 | type: "Concat"
1820 | bottom: "conv11_mbox_loc_flat"
1821 | bottom: "conv13_mbox_loc_flat"
1822 | bottom: "conv14_2_mbox_loc_flat"
1823 | bottom: "conv15_2_mbox_loc_flat"
1824 | bottom: "conv16_2_mbox_loc_flat"
1825 | bottom: "conv17_2_mbox_loc_flat"
1826 | top: "mbox_loc"
1827 | concat_param {
1828 | axis: 1
1829 | }
1830 | }
1831 | layer {
1832 | name: "mbox_conf"
1833 | type: "Concat"
1834 | bottom: "conv11_mbox_conf_flat"
1835 | bottom: "conv13_mbox_conf_flat"
1836 | bottom: "conv14_2_mbox_conf_flat"
1837 | bottom: "conv15_2_mbox_conf_flat"
1838 | bottom: "conv16_2_mbox_conf_flat"
1839 | bottom: "conv17_2_mbox_conf_flat"
1840 | top: "mbox_conf"
1841 | concat_param {
1842 | axis: 1
1843 | }
1844 | }
1845 | layer {
1846 | name: "mbox_priorbox"
1847 | type: "Concat"
1848 | bottom: "conv11_mbox_priorbox"
1849 | bottom: "conv13_mbox_priorbox"
1850 | bottom: "conv14_2_mbox_priorbox"
1851 | bottom: "conv15_2_mbox_priorbox"
1852 | bottom: "conv16_2_mbox_priorbox"
1853 | bottom: "conv17_2_mbox_priorbox"
1854 | top: "mbox_priorbox"
1855 | concat_param {
1856 | axis: 2
1857 | }
1858 | }
1859 | layer {
1860 | name: "mbox_conf_reshape"
1861 | type: "Reshape"
1862 | bottom: "mbox_conf"
1863 | top: "mbox_conf_reshape"
1864 | reshape_param {
1865 | shape {
1866 | dim: 0
1867 | dim: -1
1868 | dim: 21
1869 | }
1870 | }
1871 | }
1872 | layer {
1873 | name: "mbox_conf_softmax"
1874 | type: "Softmax"
1875 | bottom: "mbox_conf_reshape"
1876 | top: "mbox_conf_softmax"
1877 | softmax_param {
1878 | axis: 2
1879 | }
1880 | }
1881 | layer {
1882 | name: "mbox_conf_flatten"
1883 | type: "Flatten"
1884 | bottom: "mbox_conf_softmax"
1885 | top: "mbox_conf_flatten"
1886 | flatten_param {
1887 | axis: 1
1888 | }
1889 | }
1890 | layer {
1891 | name: "detection_out"
1892 | type: "DetectionOutput"
1893 | bottom: "mbox_loc"
1894 | bottom: "mbox_conf_flatten"
1895 | bottom: "mbox_priorbox"
1896 | top: "detection_out"
1897 | include {
1898 | phase: TEST
1899 | }
1900 | detection_output_param {
1901 | num_classes: 21
1902 | share_location: true
1903 | background_label_id: 0
1904 | nms_param {
1905 | nms_threshold: 0.45
1906 | top_k: 100
1907 | }
1908 | code_type: CENTER_SIZE
1909 | keep_top_k: 100
1910 | confidence_threshold: 0.25
1911 | }
1912 | }
1913 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/centroidtracker.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/centroidtracker.cpython-37.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/centroidtracker.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/centroidtracker.cpython-39.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/config.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/config.cpython-37.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/config.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/config.cpython-39.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/mailer.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/mailer.cpython-37.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/mailer.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/mailer.cpython-39.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/thread.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/thread.cpython-37.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/thread.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/thread.cpython-39.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/trackableobject.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/trackableobject.cpython-37.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/__pycache__/trackableobject.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/mylib/__pycache__/trackableobject.cpython-39.pyc
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/centroidtracker.py:
--------------------------------------------------------------------------------
1 | # import the necessary packages
2 | from scipy.spatial import distance as dist
3 | from collections import OrderedDict
4 | import numpy as np
5 |
6 | class CentroidTracker:
7 | def __init__(self, maxDisappeared=50, maxDistance=50):
8 | # initialize the next unique object ID along with two ordered
9 | # dictionaries used to keep track of mapping a given object
10 | # ID to its centroid and number of consecutive frames it has
11 | # been marked as "disappeared", respectively
12 | self.nextObjectID = 0
13 | self.objects = OrderedDict()
14 | self.disappeared = OrderedDict()
15 |
16 | # store the number of maximum consecutive frames a given
17 | # object is allowed to be marked as "disappeared" until we
18 | # need to deregister the object from tracking
19 | self.maxDisappeared = maxDisappeared
20 |
21 | # store the maximum distance between centroids to associate
22 | # an object -- if the distance is larger than this maximum
23 | # distance we'll start to mark the object as "disappeared"
24 | self.maxDistance = maxDistance
25 |
26 | def register(self, centroid):
27 | # when registering an object we use the next available object
28 | # ID to store the centroid
29 | self.objects[self.nextObjectID] = centroid
30 | self.disappeared[self.nextObjectID] = 0
31 | self.nextObjectID += 1
32 |
33 | def deregister(self, objectID):
34 | # to deregister an object ID we delete the object ID from
35 | # both of our respective dictionaries
36 | del self.objects[objectID]
37 | del self.disappeared[objectID]
38 |
39 | def update(self, rects):
40 | # check to see if the list of input bounding box rectangles
41 | # is empty
42 | if len(rects) == 0:
43 | # loop over any existing tracked objects and mark them
44 | # as disappeared
45 | for objectID in list(self.disappeared.keys()):
46 | self.disappeared[objectID] += 1
47 |
48 | # if we have reached a maximum number of consecutive
49 | # frames where a given object has been marked as
50 | # missing, deregister it
51 | if self.disappeared[objectID] > self.maxDisappeared:
52 | self.deregister(objectID)
53 |
54 | # return early as there are no centroids or tracking info
55 | # to update
56 | return self.objects
57 |
58 | # initialize an array of input centroids for the current frame
59 | inputCentroids = np.zeros((len(rects), 2), dtype="int")
60 |
61 | # loop over the bounding box rectangles
62 | for (i, (startX, startY, endX, endY)) in enumerate(rects):
63 | # use the bounding box coordinates to derive the centroid
64 | cX = int((startX + endX) / 2.0)
65 | cY = int((startY + endY) / 2.0)
66 | inputCentroids[i] = (cX, cY)
67 |
68 | # if we are currently not tracking any objects take the input
69 | # centroids and register each of them
70 | if len(self.objects) == 0:
71 | for i in range(0, len(inputCentroids)):
72 | self.register(inputCentroids[i])
73 |
74 | # otherwise, are are currently tracking objects so we need to
75 | # try to match the input centroids to existing object
76 | # centroids
77 | else:
78 | # grab the set of object IDs and corresponding centroids
79 | objectIDs = list(self.objects.keys())
80 | objectCentroids = list(self.objects.values())
81 |
82 | # compute the distance between each pair of object
83 | # centroids and input centroids, respectively -- our
84 | # goal will be to match an input centroid to an existing
85 | # object centroid
86 | D = dist.cdist(np.array(objectCentroids), inputCentroids)
87 |
88 | # in order to perform this matching we must (1) find the
89 | # smallest value in each row and then (2) sort the row
90 | # indexes based on their minimum values so that the row
91 | # with the smallest value as at the *front* of the index
92 | # list
93 | rows = D.min(axis=1).argsort()
94 |
95 | # next, we perform a similar process on the columns by
96 | # finding the smallest value in each column and then
97 | # sorting using the previously computed row index list
98 | cols = D.argmin(axis=1)[rows]
99 |
100 | # in order to determine if we need to update, register,
101 | # or deregister an object we need to keep track of which
102 | # of the rows and column indexes we have already examined
103 | usedRows = set()
104 | usedCols = set()
105 |
106 | # loop over the combination of the (row, column) index
107 | # tuples
108 | for (row, col) in zip(rows, cols):
109 | # if we have already examined either the row or
110 | # column value before, ignore it
111 | if row in usedRows or col in usedCols:
112 | continue
113 |
114 | # if the distance between centroids is greater than
115 | # the maximum distance, do not associate the two
116 | # centroids to the same object
117 | if D[row, col] > self.maxDistance:
118 | continue
119 |
120 | # otherwise, grab the object ID for the current row,
121 | # set its new centroid, and reset the disappeared
122 | # counter
123 | objectID = objectIDs[row]
124 | self.objects[objectID] = inputCentroids[col]
125 | self.disappeared[objectID] = 0
126 |
127 | # indicate that we have examined each of the row and
128 | # column indexes, respectively
129 | usedRows.add(row)
130 | usedCols.add(col)
131 |
132 | # compute both the row and column index we have NOT yet
133 | # examined
134 | unusedRows = set(range(0, D.shape[0])).difference(usedRows)
135 | unusedCols = set(range(0, D.shape[1])).difference(usedCols)
136 |
137 | # in the event that the number of object centroids is
138 | # equal or greater than the number of input centroids
139 | # we need to check and see if some of these objects have
140 | # potentially disappeared
141 | if D.shape[0] >= D.shape[1]:
142 | # loop over the unused row indexes
143 | for row in unusedRows:
144 | # grab the object ID for the corresponding row
145 | # index and increment the disappeared counter
146 | objectID = objectIDs[row]
147 | self.disappeared[objectID] += 1
148 |
149 | # check to see if the number of consecutive
150 | # frames the object has been marked "disappeared"
151 | # for warrants deregistering the object
152 | if self.disappeared[objectID] > self.maxDisappeared:
153 | self.deregister(objectID)
154 |
155 | # otherwise, if the number of input centroids is greater
156 | # than the number of existing object centroids we need to
157 | # register each new input centroid as a trackable object
158 | else:
159 | for col in unusedCols:
160 | self.register(inputCentroids[col])
161 |
162 | # return the set of trackable objects
163 | return self.objects
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/config.py:
--------------------------------------------------------------------------------
1 | #===============================================================================
2 | """ Optional features config. """
3 | #===============================================================================
4 | # Enter mail below to receive real-time email alerts
5 | # e.g., 'email@gmail.com'
6 | MAIL = ''
7 | # Enter the ip camera url (e.g., url = 'http://191.138.0.100:8040/video')
8 | url = ''
9 |
10 | # ON/OFF for mail feature. Enter True to turn on the email alert feature.
11 | ALERT = False
12 | # Set max. people inside limit. Optimise number below: 10, 50, 100, etc.
13 | Threshold = 10
14 | # Threading ON/OFF
15 | Thread = False
16 | # Simple log to log the counting data
17 | Log = False
18 | # Auto run/Schedule the software to run at your desired time
19 | Scheduler = False
20 | # Auto stop the software after certain a time/hours
21 | Timer = False
22 | #===============================================================================
23 | #===============================================================================
24 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/mailer.py:
--------------------------------------------------------------------------------
1 | import smtplib, ssl
2 |
3 | class Mailer:
4 |
5 | """
6 | This script initiaties the email alert function.
7 |
8 | """
9 | def __init__(self):
10 | # Enter your email below. This email will be used to send alerts.
11 | # E.g., "email@gmail.com"
12 | self.EMAIL = ""
13 | # Enter the email password below. Note that the password varies if you have secured
14 | # 2 step verification turned on. You can refer the links below and create an application specific password.
15 | # Google mail has a guide here: https://myaccount.google.com/lesssecureapps
16 | # For 2 step verified accounts: https://support.google.com/accounts/answer/185833
17 | self.PASS = ""
18 | self.PORT = 465
19 | self.server = smtplib.SMTP_SSL('smtp.gmail.com', self.PORT)
20 |
21 | def send(self, mail):
22 | self.server = smtplib.SMTP_SSL('smtp.gmail.com', self.PORT)
23 | self.server.login(self.EMAIL, self.PASS)
24 | # message to be sent
25 | SUBJECT = 'ALERT!'
26 | TEXT = f'People limit exceeded in your building!'
27 | message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
28 |
29 | # sending the mail
30 | self.server.sendmail(self.EMAIL, mail, message)
31 | self.server.quit()
32 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/thread.py:
--------------------------------------------------------------------------------
1 | import cv2, threading, queue
2 |
3 | class ThreadingClass:
4 | # initiate threading class
5 | def __init__(self, name):
6 | self.cap = cv2.VideoCapture(name)
7 | # define an empty queue and thread
8 | self.q = queue.Queue()
9 | t = threading.Thread(target=self._reader)
10 | t.daemon = True
11 | t.start()
12 |
13 | # read the frames as soon as they are available
14 | # this approach removes OpenCV's internal buffer and reduces the frame lag
15 | def _reader(self):
16 | while True:
17 | ret, frame = self.cap.read() # read the frames and ---
18 | if not ret:
19 | break
20 | if not self.q.empty():
21 | try:
22 | self.q.get_nowait()
23 | except queue.Empty:
24 | pass
25 | self.q.put(frame) # --- store them in a queue (instead of the buffer)
26 |
27 | def read(self):
28 | return self.q.get() # fetch frames from the queue one by one
29 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/mylib/trackableobject.py:
--------------------------------------------------------------------------------
1 | class TrackableObject:
2 | def __init__(self, objectID, centroid):
3 | # store the object ID, then initialize a list of centroids
4 | # using the current centroid
5 | self.objectID = objectID
6 | self.centroids = [centroid]
7 |
8 | # initialize a boolean used to indicate if the object has
9 | # already been counted or not
10 | self.counted = False
--------------------------------------------------------------------------------
/Realtime_People_Counting/requirements.txt:
--------------------------------------------------------------------------------
1 | schedule
2 | numpy
3 | argparse
4 | imutils
5 | dlib
6 | opencv-python
7 | scipy
8 |
--------------------------------------------------------------------------------
/Realtime_People_Counting/videos/example_01.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Realtime_People_Counting/videos/example_01.mp4
--------------------------------------------------------------------------------
/Social_distancing/MobileNetSSD_deploy.caffemodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Social_distancing/MobileNetSSD_deploy.caffemodel
--------------------------------------------------------------------------------
/Social_distancing/MobileNetSSD_deploy.prototxt:
--------------------------------------------------------------------------------
1 | name: "MobileNet-SSD"
2 | input: "data"
3 | input_shape {
4 | dim: 1
5 | dim: 3
6 | dim: 300
7 | dim: 300
8 | }
9 | layer {
10 | name: "conv0"
11 | type: "Convolution"
12 | bottom: "data"
13 | top: "conv0"
14 | param {
15 | lr_mult: 1.0
16 | decay_mult: 1.0
17 | }
18 | param {
19 | lr_mult: 2.0
20 | decay_mult: 0.0
21 | }
22 | convolution_param {
23 | num_output: 32
24 | pad: 1
25 | kernel_size: 3
26 | stride: 2
27 | weight_filler {
28 | type: "msra"
29 | }
30 | bias_filler {
31 | type: "constant"
32 | value: 0.0
33 | }
34 | }
35 | }
36 | layer {
37 | name: "conv0/relu"
38 | type: "ReLU"
39 | bottom: "conv0"
40 | top: "conv0"
41 | }
42 | layer {
43 | name: "conv1/dw"
44 | type: "Convolution"
45 | bottom: "conv0"
46 | top: "conv1/dw"
47 | param {
48 | lr_mult: 1.0
49 | decay_mult: 1.0
50 | }
51 | param {
52 | lr_mult: 2.0
53 | decay_mult: 0.0
54 | }
55 | convolution_param {
56 | num_output: 32
57 | pad: 1
58 | kernel_size: 3
59 | group: 32
60 | engine: CAFFE
61 | weight_filler {
62 | type: "msra"
63 | }
64 | bias_filler {
65 | type: "constant"
66 | value: 0.0
67 | }
68 | }
69 | }
70 | layer {
71 | name: "conv1/dw/relu"
72 | type: "ReLU"
73 | bottom: "conv1/dw"
74 | top: "conv1/dw"
75 | }
76 | layer {
77 | name: "conv1"
78 | type: "Convolution"
79 | bottom: "conv1/dw"
80 | top: "conv1"
81 | param {
82 | lr_mult: 1.0
83 | decay_mult: 1.0
84 | }
85 | param {
86 | lr_mult: 2.0
87 | decay_mult: 0.0
88 | }
89 | convolution_param {
90 | num_output: 64
91 | kernel_size: 1
92 | weight_filler {
93 | type: "msra"
94 | }
95 | bias_filler {
96 | type: "constant"
97 | value: 0.0
98 | }
99 | }
100 | }
101 | layer {
102 | name: "conv1/relu"
103 | type: "ReLU"
104 | bottom: "conv1"
105 | top: "conv1"
106 | }
107 | layer {
108 | name: "conv2/dw"
109 | type: "Convolution"
110 | bottom: "conv1"
111 | top: "conv2/dw"
112 | param {
113 | lr_mult: 1.0
114 | decay_mult: 1.0
115 | }
116 | param {
117 | lr_mult: 2.0
118 | decay_mult: 0.0
119 | }
120 | convolution_param {
121 | num_output: 64
122 | pad: 1
123 | kernel_size: 3
124 | stride: 2
125 | group: 64
126 | engine: CAFFE
127 | weight_filler {
128 | type: "msra"
129 | }
130 | bias_filler {
131 | type: "constant"
132 | value: 0.0
133 | }
134 | }
135 | }
136 | layer {
137 | name: "conv2/dw/relu"
138 | type: "ReLU"
139 | bottom: "conv2/dw"
140 | top: "conv2/dw"
141 | }
142 | layer {
143 | name: "conv2"
144 | type: "Convolution"
145 | bottom: "conv2/dw"
146 | top: "conv2"
147 | param {
148 | lr_mult: 1.0
149 | decay_mult: 1.0
150 | }
151 | param {
152 | lr_mult: 2.0
153 | decay_mult: 0.0
154 | }
155 | convolution_param {
156 | num_output: 128
157 | kernel_size: 1
158 | weight_filler {
159 | type: "msra"
160 | }
161 | bias_filler {
162 | type: "constant"
163 | value: 0.0
164 | }
165 | }
166 | }
167 | layer {
168 | name: "conv2/relu"
169 | type: "ReLU"
170 | bottom: "conv2"
171 | top: "conv2"
172 | }
173 | layer {
174 | name: "conv3/dw"
175 | type: "Convolution"
176 | bottom: "conv2"
177 | top: "conv3/dw"
178 | param {
179 | lr_mult: 1.0
180 | decay_mult: 1.0
181 | }
182 | param {
183 | lr_mult: 2.0
184 | decay_mult: 0.0
185 | }
186 | convolution_param {
187 | num_output: 128
188 | pad: 1
189 | kernel_size: 3
190 | group: 128
191 | engine: CAFFE
192 | weight_filler {
193 | type: "msra"
194 | }
195 | bias_filler {
196 | type: "constant"
197 | value: 0.0
198 | }
199 | }
200 | }
201 | layer {
202 | name: "conv3/dw/relu"
203 | type: "ReLU"
204 | bottom: "conv3/dw"
205 | top: "conv3/dw"
206 | }
207 | layer {
208 | name: "conv3"
209 | type: "Convolution"
210 | bottom: "conv3/dw"
211 | top: "conv3"
212 | param {
213 | lr_mult: 1.0
214 | decay_mult: 1.0
215 | }
216 | param {
217 | lr_mult: 2.0
218 | decay_mult: 0.0
219 | }
220 | convolution_param {
221 | num_output: 128
222 | kernel_size: 1
223 | weight_filler {
224 | type: "msra"
225 | }
226 | bias_filler {
227 | type: "constant"
228 | value: 0.0
229 | }
230 | }
231 | }
232 | layer {
233 | name: "conv3/relu"
234 | type: "ReLU"
235 | bottom: "conv3"
236 | top: "conv3"
237 | }
238 | layer {
239 | name: "conv4/dw"
240 | type: "Convolution"
241 | bottom: "conv3"
242 | top: "conv4/dw"
243 | param {
244 | lr_mult: 1.0
245 | decay_mult: 1.0
246 | }
247 | param {
248 | lr_mult: 2.0
249 | decay_mult: 0.0
250 | }
251 | convolution_param {
252 | num_output: 128
253 | pad: 1
254 | kernel_size: 3
255 | stride: 2
256 | group: 128
257 | engine: CAFFE
258 | weight_filler {
259 | type: "msra"
260 | }
261 | bias_filler {
262 | type: "constant"
263 | value: 0.0
264 | }
265 | }
266 | }
267 | layer {
268 | name: "conv4/dw/relu"
269 | type: "ReLU"
270 | bottom: "conv4/dw"
271 | top: "conv4/dw"
272 | }
273 | layer {
274 | name: "conv4"
275 | type: "Convolution"
276 | bottom: "conv4/dw"
277 | top: "conv4"
278 | param {
279 | lr_mult: 1.0
280 | decay_mult: 1.0
281 | }
282 | param {
283 | lr_mult: 2.0
284 | decay_mult: 0.0
285 | }
286 | convolution_param {
287 | num_output: 256
288 | kernel_size: 1
289 | weight_filler {
290 | type: "msra"
291 | }
292 | bias_filler {
293 | type: "constant"
294 | value: 0.0
295 | }
296 | }
297 | }
298 | layer {
299 | name: "conv4/relu"
300 | type: "ReLU"
301 | bottom: "conv4"
302 | top: "conv4"
303 | }
304 | layer {
305 | name: "conv5/dw"
306 | type: "Convolution"
307 | bottom: "conv4"
308 | top: "conv5/dw"
309 | param {
310 | lr_mult: 1.0
311 | decay_mult: 1.0
312 | }
313 | param {
314 | lr_mult: 2.0
315 | decay_mult: 0.0
316 | }
317 | convolution_param {
318 | num_output: 256
319 | pad: 1
320 | kernel_size: 3
321 | group: 256
322 | engine: CAFFE
323 | weight_filler {
324 | type: "msra"
325 | }
326 | bias_filler {
327 | type: "constant"
328 | value: 0.0
329 | }
330 | }
331 | }
332 | layer {
333 | name: "conv5/dw/relu"
334 | type: "ReLU"
335 | bottom: "conv5/dw"
336 | top: "conv5/dw"
337 | }
338 | layer {
339 | name: "conv5"
340 | type: "Convolution"
341 | bottom: "conv5/dw"
342 | top: "conv5"
343 | param {
344 | lr_mult: 1.0
345 | decay_mult: 1.0
346 | }
347 | param {
348 | lr_mult: 2.0
349 | decay_mult: 0.0
350 | }
351 | convolution_param {
352 | num_output: 256
353 | kernel_size: 1
354 | weight_filler {
355 | type: "msra"
356 | }
357 | bias_filler {
358 | type: "constant"
359 | value: 0.0
360 | }
361 | }
362 | }
363 | layer {
364 | name: "conv5/relu"
365 | type: "ReLU"
366 | bottom: "conv5"
367 | top: "conv5"
368 | }
369 | layer {
370 | name: "conv6/dw"
371 | type: "Convolution"
372 | bottom: "conv5"
373 | top: "conv6/dw"
374 | param {
375 | lr_mult: 1.0
376 | decay_mult: 1.0
377 | }
378 | param {
379 | lr_mult: 2.0
380 | decay_mult: 0.0
381 | }
382 | convolution_param {
383 | num_output: 256
384 | pad: 1
385 | kernel_size: 3
386 | stride: 2
387 | group: 256
388 | engine: CAFFE
389 | weight_filler {
390 | type: "msra"
391 | }
392 | bias_filler {
393 | type: "constant"
394 | value: 0.0
395 | }
396 | }
397 | }
398 | layer {
399 | name: "conv6/dw/relu"
400 | type: "ReLU"
401 | bottom: "conv6/dw"
402 | top: "conv6/dw"
403 | }
404 | layer {
405 | name: "conv6"
406 | type: "Convolution"
407 | bottom: "conv6/dw"
408 | top: "conv6"
409 | param {
410 | lr_mult: 1.0
411 | decay_mult: 1.0
412 | }
413 | param {
414 | lr_mult: 2.0
415 | decay_mult: 0.0
416 | }
417 | convolution_param {
418 | num_output: 512
419 | kernel_size: 1
420 | weight_filler {
421 | type: "msra"
422 | }
423 | bias_filler {
424 | type: "constant"
425 | value: 0.0
426 | }
427 | }
428 | }
429 | layer {
430 | name: "conv6/relu"
431 | type: "ReLU"
432 | bottom: "conv6"
433 | top: "conv6"
434 | }
435 | layer {
436 | name: "conv7/dw"
437 | type: "Convolution"
438 | bottom: "conv6"
439 | top: "conv7/dw"
440 | param {
441 | lr_mult: 1.0
442 | decay_mult: 1.0
443 | }
444 | param {
445 | lr_mult: 2.0
446 | decay_mult: 0.0
447 | }
448 | convolution_param {
449 | num_output: 512
450 | pad: 1
451 | kernel_size: 3
452 | group: 512
453 | engine: CAFFE
454 | weight_filler {
455 | type: "msra"
456 | }
457 | bias_filler {
458 | type: "constant"
459 | value: 0.0
460 | }
461 | }
462 | }
463 | layer {
464 | name: "conv7/dw/relu"
465 | type: "ReLU"
466 | bottom: "conv7/dw"
467 | top: "conv7/dw"
468 | }
469 | layer {
470 | name: "conv7"
471 | type: "Convolution"
472 | bottom: "conv7/dw"
473 | top: "conv7"
474 | param {
475 | lr_mult: 1.0
476 | decay_mult: 1.0
477 | }
478 | param {
479 | lr_mult: 2.0
480 | decay_mult: 0.0
481 | }
482 | convolution_param {
483 | num_output: 512
484 | kernel_size: 1
485 | weight_filler {
486 | type: "msra"
487 | }
488 | bias_filler {
489 | type: "constant"
490 | value: 0.0
491 | }
492 | }
493 | }
494 | layer {
495 | name: "conv7/relu"
496 | type: "ReLU"
497 | bottom: "conv7"
498 | top: "conv7"
499 | }
500 | layer {
501 | name: "conv8/dw"
502 | type: "Convolution"
503 | bottom: "conv7"
504 | top: "conv8/dw"
505 | param {
506 | lr_mult: 1.0
507 | decay_mult: 1.0
508 | }
509 | param {
510 | lr_mult: 2.0
511 | decay_mult: 0.0
512 | }
513 | convolution_param {
514 | num_output: 512
515 | pad: 1
516 | kernel_size: 3
517 | group: 512
518 | engine: CAFFE
519 | weight_filler {
520 | type: "msra"
521 | }
522 | bias_filler {
523 | type: "constant"
524 | value: 0.0
525 | }
526 | }
527 | }
528 | layer {
529 | name: "conv8/dw/relu"
530 | type: "ReLU"
531 | bottom: "conv8/dw"
532 | top: "conv8/dw"
533 | }
534 | layer {
535 | name: "conv8"
536 | type: "Convolution"
537 | bottom: "conv8/dw"
538 | top: "conv8"
539 | param {
540 | lr_mult: 1.0
541 | decay_mult: 1.0
542 | }
543 | param {
544 | lr_mult: 2.0
545 | decay_mult: 0.0
546 | }
547 | convolution_param {
548 | num_output: 512
549 | kernel_size: 1
550 | weight_filler {
551 | type: "msra"
552 | }
553 | bias_filler {
554 | type: "constant"
555 | value: 0.0
556 | }
557 | }
558 | }
559 | layer {
560 | name: "conv8/relu"
561 | type: "ReLU"
562 | bottom: "conv8"
563 | top: "conv8"
564 | }
565 | layer {
566 | name: "conv9/dw"
567 | type: "Convolution"
568 | bottom: "conv8"
569 | top: "conv9/dw"
570 | param {
571 | lr_mult: 1.0
572 | decay_mult: 1.0
573 | }
574 | param {
575 | lr_mult: 2.0
576 | decay_mult: 0.0
577 | }
578 | convolution_param {
579 | num_output: 512
580 | pad: 1
581 | kernel_size: 3
582 | group: 512
583 | engine: CAFFE
584 | weight_filler {
585 | type: "msra"
586 | }
587 | bias_filler {
588 | type: "constant"
589 | value: 0.0
590 | }
591 | }
592 | }
593 | layer {
594 | name: "conv9/dw/relu"
595 | type: "ReLU"
596 | bottom: "conv9/dw"
597 | top: "conv9/dw"
598 | }
599 | layer {
600 | name: "conv9"
601 | type: "Convolution"
602 | bottom: "conv9/dw"
603 | top: "conv9"
604 | param {
605 | lr_mult: 1.0
606 | decay_mult: 1.0
607 | }
608 | param {
609 | lr_mult: 2.0
610 | decay_mult: 0.0
611 | }
612 | convolution_param {
613 | num_output: 512
614 | kernel_size: 1
615 | weight_filler {
616 | type: "msra"
617 | }
618 | bias_filler {
619 | type: "constant"
620 | value: 0.0
621 | }
622 | }
623 | }
624 | layer {
625 | name: "conv9/relu"
626 | type: "ReLU"
627 | bottom: "conv9"
628 | top: "conv9"
629 | }
630 | layer {
631 | name: "conv10/dw"
632 | type: "Convolution"
633 | bottom: "conv9"
634 | top: "conv10/dw"
635 | param {
636 | lr_mult: 1.0
637 | decay_mult: 1.0
638 | }
639 | param {
640 | lr_mult: 2.0
641 | decay_mult: 0.0
642 | }
643 | convolution_param {
644 | num_output: 512
645 | pad: 1
646 | kernel_size: 3
647 | group: 512
648 | engine: CAFFE
649 | weight_filler {
650 | type: "msra"
651 | }
652 | bias_filler {
653 | type: "constant"
654 | value: 0.0
655 | }
656 | }
657 | }
658 | layer {
659 | name: "conv10/dw/relu"
660 | type: "ReLU"
661 | bottom: "conv10/dw"
662 | top: "conv10/dw"
663 | }
664 | layer {
665 | name: "conv10"
666 | type: "Convolution"
667 | bottom: "conv10/dw"
668 | top: "conv10"
669 | param {
670 | lr_mult: 1.0
671 | decay_mult: 1.0
672 | }
673 | param {
674 | lr_mult: 2.0
675 | decay_mult: 0.0
676 | }
677 | convolution_param {
678 | num_output: 512
679 | kernel_size: 1
680 | weight_filler {
681 | type: "msra"
682 | }
683 | bias_filler {
684 | type: "constant"
685 | value: 0.0
686 | }
687 | }
688 | }
689 | layer {
690 | name: "conv10/relu"
691 | type: "ReLU"
692 | bottom: "conv10"
693 | top: "conv10"
694 | }
695 | layer {
696 | name: "conv11/dw"
697 | type: "Convolution"
698 | bottom: "conv10"
699 | top: "conv11/dw"
700 | param {
701 | lr_mult: 1.0
702 | decay_mult: 1.0
703 | }
704 | param {
705 | lr_mult: 2.0
706 | decay_mult: 0.0
707 | }
708 | convolution_param {
709 | num_output: 512
710 | pad: 1
711 | kernel_size: 3
712 | group: 512
713 | engine: CAFFE
714 | weight_filler {
715 | type: "msra"
716 | }
717 | bias_filler {
718 | type: "constant"
719 | value: 0.0
720 | }
721 | }
722 | }
723 | layer {
724 | name: "conv11/dw/relu"
725 | type: "ReLU"
726 | bottom: "conv11/dw"
727 | top: "conv11/dw"
728 | }
729 | layer {
730 | name: "conv11"
731 | type: "Convolution"
732 | bottom: "conv11/dw"
733 | top: "conv11"
734 | param {
735 | lr_mult: 1.0
736 | decay_mult: 1.0
737 | }
738 | param {
739 | lr_mult: 2.0
740 | decay_mult: 0.0
741 | }
742 | convolution_param {
743 | num_output: 512
744 | kernel_size: 1
745 | weight_filler {
746 | type: "msra"
747 | }
748 | bias_filler {
749 | type: "constant"
750 | value: 0.0
751 | }
752 | }
753 | }
754 | layer {
755 | name: "conv11/relu"
756 | type: "ReLU"
757 | bottom: "conv11"
758 | top: "conv11"
759 | }
760 | layer {
761 | name: "conv12/dw"
762 | type: "Convolution"
763 | bottom: "conv11"
764 | top: "conv12/dw"
765 | param {
766 | lr_mult: 1.0
767 | decay_mult: 1.0
768 | }
769 | param {
770 | lr_mult: 2.0
771 | decay_mult: 0.0
772 | }
773 | convolution_param {
774 | num_output: 512
775 | pad: 1
776 | kernel_size: 3
777 | stride: 2
778 | group: 512
779 | engine: CAFFE
780 | weight_filler {
781 | type: "msra"
782 | }
783 | bias_filler {
784 | type: "constant"
785 | value: 0.0
786 | }
787 | }
788 | }
789 | layer {
790 | name: "conv12/dw/relu"
791 | type: "ReLU"
792 | bottom: "conv12/dw"
793 | top: "conv12/dw"
794 | }
795 | layer {
796 | name: "conv12"
797 | type: "Convolution"
798 | bottom: "conv12/dw"
799 | top: "conv12"
800 | param {
801 | lr_mult: 1.0
802 | decay_mult: 1.0
803 | }
804 | param {
805 | lr_mult: 2.0
806 | decay_mult: 0.0
807 | }
808 | convolution_param {
809 | num_output: 1024
810 | kernel_size: 1
811 | weight_filler {
812 | type: "msra"
813 | }
814 | bias_filler {
815 | type: "constant"
816 | value: 0.0
817 | }
818 | }
819 | }
820 | layer {
821 | name: "conv12/relu"
822 | type: "ReLU"
823 | bottom: "conv12"
824 | top: "conv12"
825 | }
826 | layer {
827 | name: "conv13/dw"
828 | type: "Convolution"
829 | bottom: "conv12"
830 | top: "conv13/dw"
831 | param {
832 | lr_mult: 1.0
833 | decay_mult: 1.0
834 | }
835 | param {
836 | lr_mult: 2.0
837 | decay_mult: 0.0
838 | }
839 | convolution_param {
840 | num_output: 1024
841 | pad: 1
842 | kernel_size: 3
843 | group: 1024
844 | engine: CAFFE
845 | weight_filler {
846 | type: "msra"
847 | }
848 | bias_filler {
849 | type: "constant"
850 | value: 0.0
851 | }
852 | }
853 | }
854 | layer {
855 | name: "conv13/dw/relu"
856 | type: "ReLU"
857 | bottom: "conv13/dw"
858 | top: "conv13/dw"
859 | }
860 | layer {
861 | name: "conv13"
862 | type: "Convolution"
863 | bottom: "conv13/dw"
864 | top: "conv13"
865 | param {
866 | lr_mult: 1.0
867 | decay_mult: 1.0
868 | }
869 | param {
870 | lr_mult: 2.0
871 | decay_mult: 0.0
872 | }
873 | convolution_param {
874 | num_output: 1024
875 | kernel_size: 1
876 | weight_filler {
877 | type: "msra"
878 | }
879 | bias_filler {
880 | type: "constant"
881 | value: 0.0
882 | }
883 | }
884 | }
885 | layer {
886 | name: "conv13/relu"
887 | type: "ReLU"
888 | bottom: "conv13"
889 | top: "conv13"
890 | }
891 | layer {
892 | name: "conv14_1"
893 | type: "Convolution"
894 | bottom: "conv13"
895 | top: "conv14_1"
896 | param {
897 | lr_mult: 1.0
898 | decay_mult: 1.0
899 | }
900 | param {
901 | lr_mult: 2.0
902 | decay_mult: 0.0
903 | }
904 | convolution_param {
905 | num_output: 256
906 | kernel_size: 1
907 | weight_filler {
908 | type: "msra"
909 | }
910 | bias_filler {
911 | type: "constant"
912 | value: 0.0
913 | }
914 | }
915 | }
916 | layer {
917 | name: "conv14_1/relu"
918 | type: "ReLU"
919 | bottom: "conv14_1"
920 | top: "conv14_1"
921 | }
922 | layer {
923 | name: "conv14_2"
924 | type: "Convolution"
925 | bottom: "conv14_1"
926 | top: "conv14_2"
927 | param {
928 | lr_mult: 1.0
929 | decay_mult: 1.0
930 | }
931 | param {
932 | lr_mult: 2.0
933 | decay_mult: 0.0
934 | }
935 | convolution_param {
936 | num_output: 512
937 | pad: 1
938 | kernel_size: 3
939 | stride: 2
940 | weight_filler {
941 | type: "msra"
942 | }
943 | bias_filler {
944 | type: "constant"
945 | value: 0.0
946 | }
947 | }
948 | }
949 | layer {
950 | name: "conv14_2/relu"
951 | type: "ReLU"
952 | bottom: "conv14_2"
953 | top: "conv14_2"
954 | }
955 | layer {
956 | name: "conv15_1"
957 | type: "Convolution"
958 | bottom: "conv14_2"
959 | top: "conv15_1"
960 | param {
961 | lr_mult: 1.0
962 | decay_mult: 1.0
963 | }
964 | param {
965 | lr_mult: 2.0
966 | decay_mult: 0.0
967 | }
968 | convolution_param {
969 | num_output: 128
970 | kernel_size: 1
971 | weight_filler {
972 | type: "msra"
973 | }
974 | bias_filler {
975 | type: "constant"
976 | value: 0.0
977 | }
978 | }
979 | }
980 | layer {
981 | name: "conv15_1/relu"
982 | type: "ReLU"
983 | bottom: "conv15_1"
984 | top: "conv15_1"
985 | }
986 | layer {
987 | name: "conv15_2"
988 | type: "Convolution"
989 | bottom: "conv15_1"
990 | top: "conv15_2"
991 | param {
992 | lr_mult: 1.0
993 | decay_mult: 1.0
994 | }
995 | param {
996 | lr_mult: 2.0
997 | decay_mult: 0.0
998 | }
999 | convolution_param {
1000 | num_output: 256
1001 | pad: 1
1002 | kernel_size: 3
1003 | stride: 2
1004 | weight_filler {
1005 | type: "msra"
1006 | }
1007 | bias_filler {
1008 | type: "constant"
1009 | value: 0.0
1010 | }
1011 | }
1012 | }
1013 | layer {
1014 | name: "conv15_2/relu"
1015 | type: "ReLU"
1016 | bottom: "conv15_2"
1017 | top: "conv15_2"
1018 | }
1019 | layer {
1020 | name: "conv16_1"
1021 | type: "Convolution"
1022 | bottom: "conv15_2"
1023 | top: "conv16_1"
1024 | param {
1025 | lr_mult: 1.0
1026 | decay_mult: 1.0
1027 | }
1028 | param {
1029 | lr_mult: 2.0
1030 | decay_mult: 0.0
1031 | }
1032 | convolution_param {
1033 | num_output: 128
1034 | kernel_size: 1
1035 | weight_filler {
1036 | type: "msra"
1037 | }
1038 | bias_filler {
1039 | type: "constant"
1040 | value: 0.0
1041 | }
1042 | }
1043 | }
1044 | layer {
1045 | name: "conv16_1/relu"
1046 | type: "ReLU"
1047 | bottom: "conv16_1"
1048 | top: "conv16_1"
1049 | }
1050 | layer {
1051 | name: "conv16_2"
1052 | type: "Convolution"
1053 | bottom: "conv16_1"
1054 | top: "conv16_2"
1055 | param {
1056 | lr_mult: 1.0
1057 | decay_mult: 1.0
1058 | }
1059 | param {
1060 | lr_mult: 2.0
1061 | decay_mult: 0.0
1062 | }
1063 | convolution_param {
1064 | num_output: 256
1065 | pad: 1
1066 | kernel_size: 3
1067 | stride: 2
1068 | weight_filler {
1069 | type: "msra"
1070 | }
1071 | bias_filler {
1072 | type: "constant"
1073 | value: 0.0
1074 | }
1075 | }
1076 | }
1077 | layer {
1078 | name: "conv16_2/relu"
1079 | type: "ReLU"
1080 | bottom: "conv16_2"
1081 | top: "conv16_2"
1082 | }
1083 | layer {
1084 | name: "conv17_1"
1085 | type: "Convolution"
1086 | bottom: "conv16_2"
1087 | top: "conv17_1"
1088 | param {
1089 | lr_mult: 1.0
1090 | decay_mult: 1.0
1091 | }
1092 | param {
1093 | lr_mult: 2.0
1094 | decay_mult: 0.0
1095 | }
1096 | convolution_param {
1097 | num_output: 64
1098 | kernel_size: 1
1099 | weight_filler {
1100 | type: "msra"
1101 | }
1102 | bias_filler {
1103 | type: "constant"
1104 | value: 0.0
1105 | }
1106 | }
1107 | }
1108 | layer {
1109 | name: "conv17_1/relu"
1110 | type: "ReLU"
1111 | bottom: "conv17_1"
1112 | top: "conv17_1"
1113 | }
1114 | layer {
1115 | name: "conv17_2"
1116 | type: "Convolution"
1117 | bottom: "conv17_1"
1118 | top: "conv17_2"
1119 | param {
1120 | lr_mult: 1.0
1121 | decay_mult: 1.0
1122 | }
1123 | param {
1124 | lr_mult: 2.0
1125 | decay_mult: 0.0
1126 | }
1127 | convolution_param {
1128 | num_output: 128
1129 | pad: 1
1130 | kernel_size: 3
1131 | stride: 2
1132 | weight_filler {
1133 | type: "msra"
1134 | }
1135 | bias_filler {
1136 | type: "constant"
1137 | value: 0.0
1138 | }
1139 | }
1140 | }
1141 | layer {
1142 | name: "conv17_2/relu"
1143 | type: "ReLU"
1144 | bottom: "conv17_2"
1145 | top: "conv17_2"
1146 | }
1147 | layer {
1148 | name: "conv11_mbox_loc"
1149 | type: "Convolution"
1150 | bottom: "conv11"
1151 | top: "conv11_mbox_loc"
1152 | param {
1153 | lr_mult: 1.0
1154 | decay_mult: 1.0
1155 | }
1156 | param {
1157 | lr_mult: 2.0
1158 | decay_mult: 0.0
1159 | }
1160 | convolution_param {
1161 | num_output: 12
1162 | kernel_size: 1
1163 | weight_filler {
1164 | type: "msra"
1165 | }
1166 | bias_filler {
1167 | type: "constant"
1168 | value: 0.0
1169 | }
1170 | }
1171 | }
1172 | layer {
1173 | name: "conv11_mbox_loc_perm"
1174 | type: "Permute"
1175 | bottom: "conv11_mbox_loc"
1176 | top: "conv11_mbox_loc_perm"
1177 | permute_param {
1178 | order: 0
1179 | order: 2
1180 | order: 3
1181 | order: 1
1182 | }
1183 | }
1184 | layer {
1185 | name: "conv11_mbox_loc_flat"
1186 | type: "Flatten"
1187 | bottom: "conv11_mbox_loc_perm"
1188 | top: "conv11_mbox_loc_flat"
1189 | flatten_param {
1190 | axis: 1
1191 | }
1192 | }
1193 | layer {
1194 | name: "conv11_mbox_conf"
1195 | type: "Convolution"
1196 | bottom: "conv11"
1197 | top: "conv11_mbox_conf"
1198 | param {
1199 | lr_mult: 1.0
1200 | decay_mult: 1.0
1201 | }
1202 | param {
1203 | lr_mult: 2.0
1204 | decay_mult: 0.0
1205 | }
1206 | convolution_param {
1207 | num_output: 63
1208 | kernel_size: 1
1209 | weight_filler {
1210 | type: "msra"
1211 | }
1212 | bias_filler {
1213 | type: "constant"
1214 | value: 0.0
1215 | }
1216 | }
1217 | }
1218 | layer {
1219 | name: "conv11_mbox_conf_perm"
1220 | type: "Permute"
1221 | bottom: "conv11_mbox_conf"
1222 | top: "conv11_mbox_conf_perm"
1223 | permute_param {
1224 | order: 0
1225 | order: 2
1226 | order: 3
1227 | order: 1
1228 | }
1229 | }
1230 | layer {
1231 | name: "conv11_mbox_conf_flat"
1232 | type: "Flatten"
1233 | bottom: "conv11_mbox_conf_perm"
1234 | top: "conv11_mbox_conf_flat"
1235 | flatten_param {
1236 | axis: 1
1237 | }
1238 | }
1239 | layer {
1240 | name: "conv11_mbox_priorbox"
1241 | type: "PriorBox"
1242 | bottom: "conv11"
1243 | bottom: "data"
1244 | top: "conv11_mbox_priorbox"
1245 | prior_box_param {
1246 | min_size: 60.0
1247 | aspect_ratio: 2.0
1248 | flip: true
1249 | clip: false
1250 | variance: 0.1
1251 | variance: 0.1
1252 | variance: 0.2
1253 | variance: 0.2
1254 | offset: 0.5
1255 | }
1256 | }
1257 | layer {
1258 | name: "conv13_mbox_loc"
1259 | type: "Convolution"
1260 | bottom: "conv13"
1261 | top: "conv13_mbox_loc"
1262 | param {
1263 | lr_mult: 1.0
1264 | decay_mult: 1.0
1265 | }
1266 | param {
1267 | lr_mult: 2.0
1268 | decay_mult: 0.0
1269 | }
1270 | convolution_param {
1271 | num_output: 24
1272 | kernel_size: 1
1273 | weight_filler {
1274 | type: "msra"
1275 | }
1276 | bias_filler {
1277 | type: "constant"
1278 | value: 0.0
1279 | }
1280 | }
1281 | }
1282 | layer {
1283 | name: "conv13_mbox_loc_perm"
1284 | type: "Permute"
1285 | bottom: "conv13_mbox_loc"
1286 | top: "conv13_mbox_loc_perm"
1287 | permute_param {
1288 | order: 0
1289 | order: 2
1290 | order: 3
1291 | order: 1
1292 | }
1293 | }
1294 | layer {
1295 | name: "conv13_mbox_loc_flat"
1296 | type: "Flatten"
1297 | bottom: "conv13_mbox_loc_perm"
1298 | top: "conv13_mbox_loc_flat"
1299 | flatten_param {
1300 | axis: 1
1301 | }
1302 | }
1303 | layer {
1304 | name: "conv13_mbox_conf"
1305 | type: "Convolution"
1306 | bottom: "conv13"
1307 | top: "conv13_mbox_conf"
1308 | param {
1309 | lr_mult: 1.0
1310 | decay_mult: 1.0
1311 | }
1312 | param {
1313 | lr_mult: 2.0
1314 | decay_mult: 0.0
1315 | }
1316 | convolution_param {
1317 | num_output: 126
1318 | kernel_size: 1
1319 | weight_filler {
1320 | type: "msra"
1321 | }
1322 | bias_filler {
1323 | type: "constant"
1324 | value: 0.0
1325 | }
1326 | }
1327 | }
1328 | layer {
1329 | name: "conv13_mbox_conf_perm"
1330 | type: "Permute"
1331 | bottom: "conv13_mbox_conf"
1332 | top: "conv13_mbox_conf_perm"
1333 | permute_param {
1334 | order: 0
1335 | order: 2
1336 | order: 3
1337 | order: 1
1338 | }
1339 | }
1340 | layer {
1341 | name: "conv13_mbox_conf_flat"
1342 | type: "Flatten"
1343 | bottom: "conv13_mbox_conf_perm"
1344 | top: "conv13_mbox_conf_flat"
1345 | flatten_param {
1346 | axis: 1
1347 | }
1348 | }
1349 | layer {
1350 | name: "conv13_mbox_priorbox"
1351 | type: "PriorBox"
1352 | bottom: "conv13"
1353 | bottom: "data"
1354 | top: "conv13_mbox_priorbox"
1355 | prior_box_param {
1356 | min_size: 105.0
1357 | max_size: 150.0
1358 | aspect_ratio: 2.0
1359 | aspect_ratio: 3.0
1360 | flip: true
1361 | clip: false
1362 | variance: 0.1
1363 | variance: 0.1
1364 | variance: 0.2
1365 | variance: 0.2
1366 | offset: 0.5
1367 | }
1368 | }
1369 | layer {
1370 | name: "conv14_2_mbox_loc"
1371 | type: "Convolution"
1372 | bottom: "conv14_2"
1373 | top: "conv14_2_mbox_loc"
1374 | param {
1375 | lr_mult: 1.0
1376 | decay_mult: 1.0
1377 | }
1378 | param {
1379 | lr_mult: 2.0
1380 | decay_mult: 0.0
1381 | }
1382 | convolution_param {
1383 | num_output: 24
1384 | kernel_size: 1
1385 | weight_filler {
1386 | type: "msra"
1387 | }
1388 | bias_filler {
1389 | type: "constant"
1390 | value: 0.0
1391 | }
1392 | }
1393 | }
1394 | layer {
1395 | name: "conv14_2_mbox_loc_perm"
1396 | type: "Permute"
1397 | bottom: "conv14_2_mbox_loc"
1398 | top: "conv14_2_mbox_loc_perm"
1399 | permute_param {
1400 | order: 0
1401 | order: 2
1402 | order: 3
1403 | order: 1
1404 | }
1405 | }
1406 | layer {
1407 | name: "conv14_2_mbox_loc_flat"
1408 | type: "Flatten"
1409 | bottom: "conv14_2_mbox_loc_perm"
1410 | top: "conv14_2_mbox_loc_flat"
1411 | flatten_param {
1412 | axis: 1
1413 | }
1414 | }
1415 | layer {
1416 | name: "conv14_2_mbox_conf"
1417 | type: "Convolution"
1418 | bottom: "conv14_2"
1419 | top: "conv14_2_mbox_conf"
1420 | param {
1421 | lr_mult: 1.0
1422 | decay_mult: 1.0
1423 | }
1424 | param {
1425 | lr_mult: 2.0
1426 | decay_mult: 0.0
1427 | }
1428 | convolution_param {
1429 | num_output: 126
1430 | kernel_size: 1
1431 | weight_filler {
1432 | type: "msra"
1433 | }
1434 | bias_filler {
1435 | type: "constant"
1436 | value: 0.0
1437 | }
1438 | }
1439 | }
1440 | layer {
1441 | name: "conv14_2_mbox_conf_perm"
1442 | type: "Permute"
1443 | bottom: "conv14_2_mbox_conf"
1444 | top: "conv14_2_mbox_conf_perm"
1445 | permute_param {
1446 | order: 0
1447 | order: 2
1448 | order: 3
1449 | order: 1
1450 | }
1451 | }
1452 | layer {
1453 | name: "conv14_2_mbox_conf_flat"
1454 | type: "Flatten"
1455 | bottom: "conv14_2_mbox_conf_perm"
1456 | top: "conv14_2_mbox_conf_flat"
1457 | flatten_param {
1458 | axis: 1
1459 | }
1460 | }
1461 | layer {
1462 | name: "conv14_2_mbox_priorbox"
1463 | type: "PriorBox"
1464 | bottom: "conv14_2"
1465 | bottom: "data"
1466 | top: "conv14_2_mbox_priorbox"
1467 | prior_box_param {
1468 | min_size: 150.0
1469 | max_size: 195.0
1470 | aspect_ratio: 2.0
1471 | aspect_ratio: 3.0
1472 | flip: true
1473 | clip: false
1474 | variance: 0.1
1475 | variance: 0.1
1476 | variance: 0.2
1477 | variance: 0.2
1478 | offset: 0.5
1479 | }
1480 | }
1481 | layer {
1482 | name: "conv15_2_mbox_loc"
1483 | type: "Convolution"
1484 | bottom: "conv15_2"
1485 | top: "conv15_2_mbox_loc"
1486 | param {
1487 | lr_mult: 1.0
1488 | decay_mult: 1.0
1489 | }
1490 | param {
1491 | lr_mult: 2.0
1492 | decay_mult: 0.0
1493 | }
1494 | convolution_param {
1495 | num_output: 24
1496 | kernel_size: 1
1497 | weight_filler {
1498 | type: "msra"
1499 | }
1500 | bias_filler {
1501 | type: "constant"
1502 | value: 0.0
1503 | }
1504 | }
1505 | }
1506 | layer {
1507 | name: "conv15_2_mbox_loc_perm"
1508 | type: "Permute"
1509 | bottom: "conv15_2_mbox_loc"
1510 | top: "conv15_2_mbox_loc_perm"
1511 | permute_param {
1512 | order: 0
1513 | order: 2
1514 | order: 3
1515 | order: 1
1516 | }
1517 | }
1518 | layer {
1519 | name: "conv15_2_mbox_loc_flat"
1520 | type: "Flatten"
1521 | bottom: "conv15_2_mbox_loc_perm"
1522 | top: "conv15_2_mbox_loc_flat"
1523 | flatten_param {
1524 | axis: 1
1525 | }
1526 | }
1527 | layer {
1528 | name: "conv15_2_mbox_conf"
1529 | type: "Convolution"
1530 | bottom: "conv15_2"
1531 | top: "conv15_2_mbox_conf"
1532 | param {
1533 | lr_mult: 1.0
1534 | decay_mult: 1.0
1535 | }
1536 | param {
1537 | lr_mult: 2.0
1538 | decay_mult: 0.0
1539 | }
1540 | convolution_param {
1541 | num_output: 126
1542 | kernel_size: 1
1543 | weight_filler {
1544 | type: "msra"
1545 | }
1546 | bias_filler {
1547 | type: "constant"
1548 | value: 0.0
1549 | }
1550 | }
1551 | }
1552 | layer {
1553 | name: "conv15_2_mbox_conf_perm"
1554 | type: "Permute"
1555 | bottom: "conv15_2_mbox_conf"
1556 | top: "conv15_2_mbox_conf_perm"
1557 | permute_param {
1558 | order: 0
1559 | order: 2
1560 | order: 3
1561 | order: 1
1562 | }
1563 | }
1564 | layer {
1565 | name: "conv15_2_mbox_conf_flat"
1566 | type: "Flatten"
1567 | bottom: "conv15_2_mbox_conf_perm"
1568 | top: "conv15_2_mbox_conf_flat"
1569 | flatten_param {
1570 | axis: 1
1571 | }
1572 | }
1573 | layer {
1574 | name: "conv15_2_mbox_priorbox"
1575 | type: "PriorBox"
1576 | bottom: "conv15_2"
1577 | bottom: "data"
1578 | top: "conv15_2_mbox_priorbox"
1579 | prior_box_param {
1580 | min_size: 195.0
1581 | max_size: 240.0
1582 | aspect_ratio: 2.0
1583 | aspect_ratio: 3.0
1584 | flip: true
1585 | clip: false
1586 | variance: 0.1
1587 | variance: 0.1
1588 | variance: 0.2
1589 | variance: 0.2
1590 | offset: 0.5
1591 | }
1592 | }
1593 | layer {
1594 | name: "conv16_2_mbox_loc"
1595 | type: "Convolution"
1596 | bottom: "conv16_2"
1597 | top: "conv16_2_mbox_loc"
1598 | param {
1599 | lr_mult: 1.0
1600 | decay_mult: 1.0
1601 | }
1602 | param {
1603 | lr_mult: 2.0
1604 | decay_mult: 0.0
1605 | }
1606 | convolution_param {
1607 | num_output: 24
1608 | kernel_size: 1
1609 | weight_filler {
1610 | type: "msra"
1611 | }
1612 | bias_filler {
1613 | type: "constant"
1614 | value: 0.0
1615 | }
1616 | }
1617 | }
1618 | layer {
1619 | name: "conv16_2_mbox_loc_perm"
1620 | type: "Permute"
1621 | bottom: "conv16_2_mbox_loc"
1622 | top: "conv16_2_mbox_loc_perm"
1623 | permute_param {
1624 | order: 0
1625 | order: 2
1626 | order: 3
1627 | order: 1
1628 | }
1629 | }
1630 | layer {
1631 | name: "conv16_2_mbox_loc_flat"
1632 | type: "Flatten"
1633 | bottom: "conv16_2_mbox_loc_perm"
1634 | top: "conv16_2_mbox_loc_flat"
1635 | flatten_param {
1636 | axis: 1
1637 | }
1638 | }
1639 | layer {
1640 | name: "conv16_2_mbox_conf"
1641 | type: "Convolution"
1642 | bottom: "conv16_2"
1643 | top: "conv16_2_mbox_conf"
1644 | param {
1645 | lr_mult: 1.0
1646 | decay_mult: 1.0
1647 | }
1648 | param {
1649 | lr_mult: 2.0
1650 | decay_mult: 0.0
1651 | }
1652 | convolution_param {
1653 | num_output: 126
1654 | kernel_size: 1
1655 | weight_filler {
1656 | type: "msra"
1657 | }
1658 | bias_filler {
1659 | type: "constant"
1660 | value: 0.0
1661 | }
1662 | }
1663 | }
1664 | layer {
1665 | name: "conv16_2_mbox_conf_perm"
1666 | type: "Permute"
1667 | bottom: "conv16_2_mbox_conf"
1668 | top: "conv16_2_mbox_conf_perm"
1669 | permute_param {
1670 | order: 0
1671 | order: 2
1672 | order: 3
1673 | order: 1
1674 | }
1675 | }
1676 | layer {
1677 | name: "conv16_2_mbox_conf_flat"
1678 | type: "Flatten"
1679 | bottom: "conv16_2_mbox_conf_perm"
1680 | top: "conv16_2_mbox_conf_flat"
1681 | flatten_param {
1682 | axis: 1
1683 | }
1684 | }
1685 | layer {
1686 | name: "conv16_2_mbox_priorbox"
1687 | type: "PriorBox"
1688 | bottom: "conv16_2"
1689 | bottom: "data"
1690 | top: "conv16_2_mbox_priorbox"
1691 | prior_box_param {
1692 | min_size: 240.0
1693 | max_size: 285.0
1694 | aspect_ratio: 2.0
1695 | aspect_ratio: 3.0
1696 | flip: true
1697 | clip: false
1698 | variance: 0.1
1699 | variance: 0.1
1700 | variance: 0.2
1701 | variance: 0.2
1702 | offset: 0.5
1703 | }
1704 | }
1705 | layer {
1706 | name: "conv17_2_mbox_loc"
1707 | type: "Convolution"
1708 | bottom: "conv17_2"
1709 | top: "conv17_2_mbox_loc"
1710 | param {
1711 | lr_mult: 1.0
1712 | decay_mult: 1.0
1713 | }
1714 | param {
1715 | lr_mult: 2.0
1716 | decay_mult: 0.0
1717 | }
1718 | convolution_param {
1719 | num_output: 24
1720 | kernel_size: 1
1721 | weight_filler {
1722 | type: "msra"
1723 | }
1724 | bias_filler {
1725 | type: "constant"
1726 | value: 0.0
1727 | }
1728 | }
1729 | }
1730 | layer {
1731 | name: "conv17_2_mbox_loc_perm"
1732 | type: "Permute"
1733 | bottom: "conv17_2_mbox_loc"
1734 | top: "conv17_2_mbox_loc_perm"
1735 | permute_param {
1736 | order: 0
1737 | order: 2
1738 | order: 3
1739 | order: 1
1740 | }
1741 | }
1742 | layer {
1743 | name: "conv17_2_mbox_loc_flat"
1744 | type: "Flatten"
1745 | bottom: "conv17_2_mbox_loc_perm"
1746 | top: "conv17_2_mbox_loc_flat"
1747 | flatten_param {
1748 | axis: 1
1749 | }
1750 | }
1751 | layer {
1752 | name: "conv17_2_mbox_conf"
1753 | type: "Convolution"
1754 | bottom: "conv17_2"
1755 | top: "conv17_2_mbox_conf"
1756 | param {
1757 | lr_mult: 1.0
1758 | decay_mult: 1.0
1759 | }
1760 | param {
1761 | lr_mult: 2.0
1762 | decay_mult: 0.0
1763 | }
1764 | convolution_param {
1765 | num_output: 126
1766 | kernel_size: 1
1767 | weight_filler {
1768 | type: "msra"
1769 | }
1770 | bias_filler {
1771 | type: "constant"
1772 | value: 0.0
1773 | }
1774 | }
1775 | }
1776 | layer {
1777 | name: "conv17_2_mbox_conf_perm"
1778 | type: "Permute"
1779 | bottom: "conv17_2_mbox_conf"
1780 | top: "conv17_2_mbox_conf_perm"
1781 | permute_param {
1782 | order: 0
1783 | order: 2
1784 | order: 3
1785 | order: 1
1786 | }
1787 | }
1788 | layer {
1789 | name: "conv17_2_mbox_conf_flat"
1790 | type: "Flatten"
1791 | bottom: "conv17_2_mbox_conf_perm"
1792 | top: "conv17_2_mbox_conf_flat"
1793 | flatten_param {
1794 | axis: 1
1795 | }
1796 | }
1797 | layer {
1798 | name: "conv17_2_mbox_priorbox"
1799 | type: "PriorBox"
1800 | bottom: "conv17_2"
1801 | bottom: "data"
1802 | top: "conv17_2_mbox_priorbox"
1803 | prior_box_param {
1804 | min_size: 285.0
1805 | max_size: 300.0
1806 | aspect_ratio: 2.0
1807 | aspect_ratio: 3.0
1808 | flip: true
1809 | clip: false
1810 | variance: 0.1
1811 | variance: 0.1
1812 | variance: 0.2
1813 | variance: 0.2
1814 | offset: 0.5
1815 | }
1816 | }
1817 | layer {
1818 | name: "mbox_loc"
1819 | type: "Concat"
1820 | bottom: "conv11_mbox_loc_flat"
1821 | bottom: "conv13_mbox_loc_flat"
1822 | bottom: "conv14_2_mbox_loc_flat"
1823 | bottom: "conv15_2_mbox_loc_flat"
1824 | bottom: "conv16_2_mbox_loc_flat"
1825 | bottom: "conv17_2_mbox_loc_flat"
1826 | top: "mbox_loc"
1827 | concat_param {
1828 | axis: 1
1829 | }
1830 | }
1831 | layer {
1832 | name: "mbox_conf"
1833 | type: "Concat"
1834 | bottom: "conv11_mbox_conf_flat"
1835 | bottom: "conv13_mbox_conf_flat"
1836 | bottom: "conv14_2_mbox_conf_flat"
1837 | bottom: "conv15_2_mbox_conf_flat"
1838 | bottom: "conv16_2_mbox_conf_flat"
1839 | bottom: "conv17_2_mbox_conf_flat"
1840 | top: "mbox_conf"
1841 | concat_param {
1842 | axis: 1
1843 | }
1844 | }
1845 | layer {
1846 | name: "mbox_priorbox"
1847 | type: "Concat"
1848 | bottom: "conv11_mbox_priorbox"
1849 | bottom: "conv13_mbox_priorbox"
1850 | bottom: "conv14_2_mbox_priorbox"
1851 | bottom: "conv15_2_mbox_priorbox"
1852 | bottom: "conv16_2_mbox_priorbox"
1853 | bottom: "conv17_2_mbox_priorbox"
1854 | top: "mbox_priorbox"
1855 | concat_param {
1856 | axis: 2
1857 | }
1858 | }
1859 | layer {
1860 | name: "mbox_conf_reshape"
1861 | type: "Reshape"
1862 | bottom: "mbox_conf"
1863 | top: "mbox_conf_reshape"
1864 | reshape_param {
1865 | shape {
1866 | dim: 0
1867 | dim: -1
1868 | dim: 21
1869 | }
1870 | }
1871 | }
1872 | layer {
1873 | name: "mbox_conf_softmax"
1874 | type: "Softmax"
1875 | bottom: "mbox_conf_reshape"
1876 | top: "mbox_conf_softmax"
1877 | softmax_param {
1878 | axis: 2
1879 | }
1880 | }
1881 | layer {
1882 | name: "mbox_conf_flatten"
1883 | type: "Flatten"
1884 | bottom: "mbox_conf_softmax"
1885 | top: "mbox_conf_flatten"
1886 | flatten_param {
1887 | axis: 1
1888 | }
1889 | }
1890 | layer {
1891 | name: "detection_out"
1892 | type: "DetectionOutput"
1893 | bottom: "mbox_loc"
1894 | bottom: "mbox_conf_flatten"
1895 | bottom: "mbox_priorbox"
1896 | top: "detection_out"
1897 | include {
1898 | phase: TEST
1899 | }
1900 | detection_output_param {
1901 | num_classes: 21
1902 | share_location: true
1903 | background_label_id: 0
1904 | nms_param {
1905 | nms_threshold: 0.45
1906 | top_k: 100
1907 | }
1908 | code_type: CENTER_SIZE
1909 | keep_top_k: 100
1910 | confidence_threshold: 0.25
1911 | }
1912 | }
1913 |
--------------------------------------------------------------------------------
/Social_distancing/__pycache__/centroidtracker.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Social_distancing/__pycache__/centroidtracker.cpython-38.pyc
--------------------------------------------------------------------------------
/Social_distancing/centroidtracker.py:
--------------------------------------------------------------------------------
1 | # import the necessary packages
2 | from scipy.spatial import distance as dist
3 | from collections import OrderedDict
4 | import numpy as np
5 |
6 |
7 | class CentroidTracker:
8 | def __init__(self, maxDisappeared=50, maxDistance=50):
9 | # initialize the next unique object ID along with two ordered
10 | # dictionaries used to keep track of mapping a given object
11 | # ID to its centroid and number of consecutive frames it has
12 | # been marked as "disappeared", respectively
13 | self.nextObjectID = 0
14 | self.objects = OrderedDict()
15 | self.disappeared = OrderedDict()
16 | self.bbox = OrderedDict() # CHANGE
17 |
18 | # store the number of maximum consecutive frames a given
19 | # object is allowed to be marked as "disappeared" until we
20 | # need to deregister the object from tracking
21 | self.maxDisappeared = maxDisappeared
22 |
23 | # store the maximum distance between centroids to associate
24 | # an object -- if the distance is larger than this maximum
25 | # distance we'll start to mark the object as "disappeared"
26 | self.maxDistance = maxDistance
27 |
28 | def register(self, centroid, inputRect):
29 | # when registering an object we use the next available object
30 | # ID to store the centroid
31 | self.objects[self.nextObjectID] = centroid
32 | self.bbox[self.nextObjectID] = inputRect # CHANGE
33 | self.disappeared[self.nextObjectID] = 0
34 | self.nextObjectID += 1
35 |
36 | def deregister(self, objectID):
37 | # to deregister an object ID we delete the object ID from
38 | # both of our respective dictionaries
39 | del self.objects[objectID]
40 | del self.disappeared[objectID]
41 | del self.bbox[objectID] # CHANGE
42 |
43 | def update(self, rects):
44 | # check to see if the list of input bounding box rectangles
45 | # is empty
46 | if len(rects) == 0:
47 | # loop over any existing tracked objects and mark them
48 | # as disappeared
49 | for objectID in list(self.disappeared.keys()):
50 | self.disappeared[objectID] += 1
51 |
52 | # if we have reached a maximum number of consecutive
53 | # frames where a given object has been marked as
54 | # missing, deregister it
55 | if self.disappeared[objectID] > self.maxDisappeared:
56 | self.deregister(objectID)
57 |
58 | # return early as there are no centroids or tracking info
59 | # to update
60 | # return self.objects
61 | return self.bbox
62 |
63 | # initialize an array of input centroids for the current frame
64 | inputCentroids = np.zeros((len(rects), 2), dtype="int")
65 | inputRects = []
66 | # loop over the bounding box rectangles
67 | for (i, (startX, startY, endX, endY)) in enumerate(rects):
68 | # use the bounding box coordinates to derive the centroid
69 | cX = int((startX + endX) / 2.0)
70 | cY = int((startY + endY) / 2.0)
71 | inputCentroids[i] = (cX, cY)
72 | inputRects.append(rects[i]) # CHANGE
73 |
74 | # if we are currently not tracking any objects take the input
75 | # centroids and register each of them
76 | if len(self.objects) == 0:
77 | for i in range(0, len(inputCentroids)):
78 | self.register(inputCentroids[i], inputRects[i]) # CHANGE
79 |
80 | # otherwise, are are currently tracking objects so we need to
81 | # try to match the input centroids to existing object
82 | # centroids
83 | else:
84 | # grab the set of object IDs and corresponding centroids
85 | objectIDs = list(self.objects.keys())
86 | objectCentroids = list(self.objects.values())
87 |
88 | # compute the distance between each pair of object
89 | # centroids and input centroids, respectively -- our
90 | # goal will be to match an input centroid to an existing
91 | # object centroid
92 | D = dist.cdist(np.array(objectCentroids), inputCentroids)
93 |
94 | # in order to perform this matching we must (1) find the
95 | # smallest value in each row and then (2) sort the row
96 | # indexes based on their minimum values so that the row
97 | # with the smallest value as at the *front* of the index
98 | # list
99 | rows = D.min(axis=1).argsort()
100 |
101 | # next, we perform a similar process on the columns by
102 | # finding the smallest value in each column and then
103 | # sorting using the previously computed row index list
104 | cols = D.argmin(axis=1)[rows]
105 |
106 | # in order to determine if we need to update, register,
107 | # or deregister an object we need to keep track of which
108 | # of the rows and column indexes we have already examined
109 | usedRows = set()
110 | usedCols = set()
111 |
112 | # loop over the combination of the (row, column) index
113 | # tuples
114 | for (row, col) in zip(rows, cols):
115 | # if we have already examined either the row or
116 | # column value before, ignore it
117 | if row in usedRows or col in usedCols:
118 | continue
119 |
120 | # if the distance between centroids is greater than
121 | # the maximum distance, do not associate the two
122 | # centroids to the same object
123 | if D[row, col] > self.maxDistance:
124 | continue
125 |
126 | # otherwise, grab the object ID for the current row,
127 | # set its new centroid, and reset the disappeared
128 | # counter
129 | objectID = objectIDs[row]
130 | self.objects[objectID] = inputCentroids[col]
131 | self.bbox[objectID] = inputRects[col] # CHANGE
132 | self.disappeared[objectID] = 0
133 |
134 | # indicate that we have examined each of the row and
135 | # column indexes, respectively
136 | usedRows.add(row)
137 | usedCols.add(col)
138 |
139 | # compute both the row and column index we have NOT yet
140 | # examined
141 | unusedRows = set(range(0, D.shape[0])).difference(usedRows)
142 | unusedCols = set(range(0, D.shape[1])).difference(usedCols)
143 |
144 | # in the event that the number of object centroids is
145 | # equal or greater than the number of input centroids
146 | # we need to check and see if some of these objects have
147 | # potentially disappeared
148 | if D.shape[0] >= D.shape[1]:
149 | # loop over the unused row indexes
150 | for row in unusedRows:
151 | # grab the object ID for the corresponding row
152 | # index and increment the disappeared counter
153 | objectID = objectIDs[row]
154 | self.disappeared[objectID] += 1
155 |
156 | # check to see if the number of consecutive
157 | # frames the object has been marked "disappeared"
158 | # for warrants deregistering the object
159 | if self.disappeared[objectID] > self.maxDisappeared:
160 | self.deregister(objectID)
161 |
162 | # otherwise, if the number of input centroids is greater
163 | # than the number of existing object centroids we need to
164 | # register each new input centroid as a trackable object
165 | else:
166 | for col in unusedCols:
167 | self.register(inputCentroids[col], inputRects[col])
168 |
169 | # return the set of trackable objects
170 | # return self.objects
171 | return self.bbox
172 |
173 |
--------------------------------------------------------------------------------
/Social_distancing/social_distancing.py:
--------------------------------------------------------------------------------
1 | #Before runnig this file make sure you have Pretrained model and classes folder
2 | #you can get all thing via my github link i will mention below
3 | #It will depend on CPU performance if your cpu performance is good the video will process fast
4 | #i have not good cpu performacnce to that why its processing quite low
5 | import cv2
6 | import datetime
7 | import imutils
8 | import numpy as np
9 | from centroidtracker import CentroidTracker
10 | from itertools import combinations
11 | import math
12 | #THE model and prototype files are here
13 | protopath = "MobileNetSSD_deploy.prototxt"
14 | modelpath = "MobileNetSSD_deploy.caffemodel"
15 | detector = cv2.dnn.readNetFromCaffe(prototxt=protopath, caffeModel=modelpath)
16 |
17 | #mention num of classes here
18 | CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",
19 | "bottle", "bus", "car", "cat", "chair", "cow", "diningtable",
20 | "dog", "horse", "motorbike", "person", "pottedplant", "sheep",
21 | "sofa", "train", "tvmonitor"]
22 |
23 | tracker = CentroidTracker(maxDisappeared=40, maxDistance=50)
24 |
25 |
26 | def non_max_suppression_fast(boxes, overlapThresh):
27 | try:
28 | if len(boxes) == 0:
29 | return []
30 |
31 | if boxes.dtype.kind == "i":
32 | boxes = boxes.astype("float")
33 |
34 | pick = []
35 |
36 | x1 = boxes[:, 0]
37 | y1 = boxes[:, 1]
38 | x2 = boxes[:, 2]
39 | y2 = boxes[:, 3]
40 |
41 | area = (x2 - x1 + 1) * (y2 - y1 + 1)
42 | idxs = np.argsort(y2)
43 |
44 | while len(idxs) > 0:
45 | last = len(idxs) - 1
46 | i = idxs[last]
47 | pick.append(i)
48 |
49 | xx1 = np.maximum(x1[i], x1[idxs[:last]])
50 | yy1 = np.maximum(y1[i], y1[idxs[:last]])
51 | xx2 = np.minimum(x2[i], x2[idxs[:last]])
52 | yy2 = np.minimum(y2[i], y2[idxs[:last]])
53 |
54 | w = np.maximum(0, xx2 - xx1 + 1)
55 | h = np.maximum(0, yy2 - yy1 + 1)
56 |
57 | overlap = (w * h) / area[idxs[:last]]
58 |
59 | idxs = np.delete(idxs, np.concatenate(([last],
60 | np.where(overlap > overlapThresh)[0])))
61 |
62 | return boxes[pick].astype("int")
63 | except Exception as e:
64 | print("Exception occurred in non_max_suppression : {}".format(e))
65 | #Pass the video link here
66 |
67 | def main():
68 | cap = cv2.VideoCapture('Social_Distance.mp4')
69 |
70 | fps_start_time = datetime.datetime.now()
71 | fps = 0
72 | total_frames = 0
73 |
74 | while True:
75 | ret, frame = cap.read()
76 | frame = imutils.resize(frame, width=600)
77 | total_frames = total_frames + 1
78 |
79 | (H, W) = frame.shape[:2]
80 |
81 | blob = cv2.dnn.blobFromImage(frame, 0.007843, (W, H), 127.5)
82 |
83 | detector.setInput(blob)
84 | person_detections = detector.forward()
85 | rects = []
86 | for i in np.arange(0, person_detections.shape[2]):
87 | confidence = person_detections[0, 0, i, 2]
88 | if confidence > 0.5:
89 | idx = int(person_detections[0, 0, i, 1])
90 |
91 | if CLASSES[idx] != "person":
92 | continue
93 |
94 | person_box = person_detections[0, 0, i, 3:7] * np.array([W, H, W, H])
95 | (startX, startY, endX, endY) = person_box.astype("int")
96 | rects.append(person_box)
97 |
98 | boundingboxes = np.array(rects)
99 | boundingboxes = boundingboxes.astype(int)
100 | rects = non_max_suppression_fast(boundingboxes, 0.3)
101 | centroid_dict = dict()
102 | objects = tracker.update(rects)
103 | for (objectId, bbox) in objects.items():
104 | x1, y1, x2, y2 = bbox
105 | x1 = int(x1)
106 | y1 = int(y1)
107 | x2 = int(x2)
108 | y2 = int(y2)
109 | cX = int((x1 + x2) / 2.0)
110 | cY = int((y1 + y2) / 2.0)
111 |
112 |
113 | centroid_dict[objectId] = (cX, cY, x1, y1, x2, y2)
114 |
115 | # text = "ID: {}".format(objectId)
116 | # cv2.putText(frame, text, (x1, y1-5), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 0, 255), 1)
117 |
118 | red_zone_list = []
119 | for (id1, p1), (id2, p2) in combinations(centroid_dict.items(), 2):
120 | dx, dy = p1[0] - p2[0], p1[1] - p2[1]
121 | distance = math.sqrt(dx * dx + dy * dy)
122 | if distance < 75.0:
123 | if id1 not in red_zone_list:
124 | red_zone_list.append(id1)
125 | if id2 not in red_zone_list:
126 | red_zone_list.append(id2)
127 |
128 | for id, box in centroid_dict.items():
129 | if id in red_zone_list:
130 | cv2.rectangle(frame, (box[2], box[3]), (box[4], box[5]), (0, 0, 255), 2)
131 | else:
132 | cv2.rectangle(frame, (box[2], box[3]), (box[4], box[5]), (0, 255, 0), 2)
133 |
134 |
135 | fps_end_time = datetime.datetime.now()
136 | time_diff = fps_end_time - fps_start_time
137 | if time_diff.seconds == 0:
138 | fps = 0.0
139 | else:
140 | fps = (total_frames / time_diff.seconds)
141 |
142 | fps_text = "FPS: {:.2f}".format(fps)
143 |
144 | cv2.putText(frame, fps_text, (5, 30), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 0, 255), 1)
145 |
146 | cv2.imshow("Social_Distancing", frame)
147 | key = cv2.waitKey(1)
148 | if key == ord('q'):
149 | break
150 |
151 | cv2.destroyAllWindows()
152 |
153 | main()
--------------------------------------------------------------------------------
/Yolo_Object_Detection/input/file.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/noumannahmad/Computer-Vision/f0a0b00074105eca695ce292d109cfac245fa956/Yolo_Object_Detection/input/file.mp4
--------------------------------------------------------------------------------
/Yolo_Object_Detection/yolo-coco/coco.names:
--------------------------------------------------------------------------------
1 | person
2 | bicycle
3 | car
4 | motorbike
5 | aeroplane
6 | bus
7 | train
8 | truck
9 | boat
10 | traffic light
11 | fire hydrant
12 | stop sign
13 | parking meter
14 | bench
15 | bird
16 | cat
17 | dog
18 | horse
19 | sheep
20 | cow
21 | elephant
22 | bear
23 | zebra
24 | giraffe
25 | backpack
26 | umbrella
27 | handbag
28 | tie
29 | suitcase
30 | frisbee
31 | skis
32 | snowboard
33 | sports ball
34 | kite
35 | baseball bat
36 | baseball glove
37 | skateboard
38 | surfboard
39 | tennis racket
40 | bottle
41 | wine glass
42 | cup
43 | fork
44 | knife
45 | spoon
46 | bowl
47 | banana
48 | apple
49 | sandwich
50 | orange
51 | broccoli
52 | carrot
53 | hot dog
54 | pizza
55 | donut
56 | cake
57 | chair
58 | sofa
59 | pottedplant
60 | bed
61 | diningtable
62 | toilet
63 | tvmonitor
64 | laptop
65 | mouse
66 | remote
67 | keyboard
68 | cell phone
69 | microwave
70 | oven
71 | toaster
72 | sink
73 | refrigerator
74 | book
75 | clock
76 | vase
77 | scissors
78 | teddy bear
79 | hair drier
80 | toothbrush
--------------------------------------------------------------------------------
/Yolo_Object_Detection/yolo-coco/yolov3.cfg:
--------------------------------------------------------------------------------
1 | [net]
2 | # Testing
3 | batch=1
4 | subdivisions=1
5 | # Training
6 | #batch=64
7 | #subdivisions=16
8 | width=608
9 | height=608
10 | channels=3
11 | momentum=0.9
12 | decay=0.0005
13 | angle=0
14 | saturation = 1.5
15 | exposure = 1.5
16 | hue=.1
17 |
18 | learning_rate=0.001
19 | burn_in=1000
20 | max_batches = 500200
21 | policy=steps
22 | steps=400000,450000
23 | scales=.1,.1
24 |
25 | [convolutional]
26 | batch_normalize=1
27 | filters=32
28 | size=3
29 | stride=1
30 | pad=1
31 | activation=leaky
32 |
33 | # Downsample
34 |
35 | [convolutional]
36 | batch_normalize=1
37 | filters=64
38 | size=3
39 | stride=2
40 | pad=1
41 | activation=leaky
42 |
43 | [convolutional]
44 | batch_normalize=1
45 | filters=32
46 | size=1
47 | stride=1
48 | pad=1
49 | activation=leaky
50 |
51 | [convolutional]
52 | batch_normalize=1
53 | filters=64
54 | size=3
55 | stride=1
56 | pad=1
57 | activation=leaky
58 |
59 | [shortcut]
60 | from=-3
61 | activation=linear
62 |
63 | # Downsample
64 |
65 | [convolutional]
66 | batch_normalize=1
67 | filters=128
68 | size=3
69 | stride=2
70 | pad=1
71 | activation=leaky
72 |
73 | [convolutional]
74 | batch_normalize=1
75 | filters=64
76 | size=1
77 | stride=1
78 | pad=1
79 | activation=leaky
80 |
81 | [convolutional]
82 | batch_normalize=1
83 | filters=128
84 | size=3
85 | stride=1
86 | pad=1
87 | activation=leaky
88 |
89 | [shortcut]
90 | from=-3
91 | activation=linear
92 |
93 | [convolutional]
94 | batch_normalize=1
95 | filters=64
96 | size=1
97 | stride=1
98 | pad=1
99 | activation=leaky
100 |
101 | [convolutional]
102 | batch_normalize=1
103 | filters=128
104 | size=3
105 | stride=1
106 | pad=1
107 | activation=leaky
108 |
109 | [shortcut]
110 | from=-3
111 | activation=linear
112 |
113 | # Downsample
114 |
115 | [convolutional]
116 | batch_normalize=1
117 | filters=256
118 | size=3
119 | stride=2
120 | pad=1
121 | activation=leaky
122 |
123 | [convolutional]
124 | batch_normalize=1
125 | filters=128
126 | size=1
127 | stride=1
128 | pad=1
129 | activation=leaky
130 |
131 | [convolutional]
132 | batch_normalize=1
133 | filters=256
134 | size=3
135 | stride=1
136 | pad=1
137 | activation=leaky
138 |
139 | [shortcut]
140 | from=-3
141 | activation=linear
142 |
143 | [convolutional]
144 | batch_normalize=1
145 | filters=128
146 | size=1
147 | stride=1
148 | pad=1
149 | activation=leaky
150 |
151 | [convolutional]
152 | batch_normalize=1
153 | filters=256
154 | size=3
155 | stride=1
156 | pad=1
157 | activation=leaky
158 |
159 | [shortcut]
160 | from=-3
161 | activation=linear
162 |
163 | [convolutional]
164 | batch_normalize=1
165 | filters=128
166 | size=1
167 | stride=1
168 | pad=1
169 | activation=leaky
170 |
171 | [convolutional]
172 | batch_normalize=1
173 | filters=256
174 | size=3
175 | stride=1
176 | pad=1
177 | activation=leaky
178 |
179 | [shortcut]
180 | from=-3
181 | activation=linear
182 |
183 | [convolutional]
184 | batch_normalize=1
185 | filters=128
186 | size=1
187 | stride=1
188 | pad=1
189 | activation=leaky
190 |
191 | [convolutional]
192 | batch_normalize=1
193 | filters=256
194 | size=3
195 | stride=1
196 | pad=1
197 | activation=leaky
198 |
199 | [shortcut]
200 | from=-3
201 | activation=linear
202 |
203 |
204 | [convolutional]
205 | batch_normalize=1
206 | filters=128
207 | size=1
208 | stride=1
209 | pad=1
210 | activation=leaky
211 |
212 | [convolutional]
213 | batch_normalize=1
214 | filters=256
215 | size=3
216 | stride=1
217 | pad=1
218 | activation=leaky
219 |
220 | [shortcut]
221 | from=-3
222 | activation=linear
223 |
224 | [convolutional]
225 | batch_normalize=1
226 | filters=128
227 | size=1
228 | stride=1
229 | pad=1
230 | activation=leaky
231 |
232 | [convolutional]
233 | batch_normalize=1
234 | filters=256
235 | size=3
236 | stride=1
237 | pad=1
238 | activation=leaky
239 |
240 | [shortcut]
241 | from=-3
242 | activation=linear
243 |
244 | [convolutional]
245 | batch_normalize=1
246 | filters=128
247 | size=1
248 | stride=1
249 | pad=1
250 | activation=leaky
251 |
252 | [convolutional]
253 | batch_normalize=1
254 | filters=256
255 | size=3
256 | stride=1
257 | pad=1
258 | activation=leaky
259 |
260 | [shortcut]
261 | from=-3
262 | activation=linear
263 |
264 | [convolutional]
265 | batch_normalize=1
266 | filters=128
267 | size=1
268 | stride=1
269 | pad=1
270 | activation=leaky
271 |
272 | [convolutional]
273 | batch_normalize=1
274 | filters=256
275 | size=3
276 | stride=1
277 | pad=1
278 | activation=leaky
279 |
280 | [shortcut]
281 | from=-3
282 | activation=linear
283 |
284 | # Downsample
285 |
286 | [convolutional]
287 | batch_normalize=1
288 | filters=512
289 | size=3
290 | stride=2
291 | pad=1
292 | activation=leaky
293 |
294 | [convolutional]
295 | batch_normalize=1
296 | filters=256
297 | size=1
298 | stride=1
299 | pad=1
300 | activation=leaky
301 |
302 | [convolutional]
303 | batch_normalize=1
304 | filters=512
305 | size=3
306 | stride=1
307 | pad=1
308 | activation=leaky
309 |
310 | [shortcut]
311 | from=-3
312 | activation=linear
313 |
314 |
315 | [convolutional]
316 | batch_normalize=1
317 | filters=256
318 | size=1
319 | stride=1
320 | pad=1
321 | activation=leaky
322 |
323 | [convolutional]
324 | batch_normalize=1
325 | filters=512
326 | size=3
327 | stride=1
328 | pad=1
329 | activation=leaky
330 |
331 | [shortcut]
332 | from=-3
333 | activation=linear
334 |
335 |
336 | [convolutional]
337 | batch_normalize=1
338 | filters=256
339 | size=1
340 | stride=1
341 | pad=1
342 | activation=leaky
343 |
344 | [convolutional]
345 | batch_normalize=1
346 | filters=512
347 | size=3
348 | stride=1
349 | pad=1
350 | activation=leaky
351 |
352 | [shortcut]
353 | from=-3
354 | activation=linear
355 |
356 |
357 | [convolutional]
358 | batch_normalize=1
359 | filters=256
360 | size=1
361 | stride=1
362 | pad=1
363 | activation=leaky
364 |
365 | [convolutional]
366 | batch_normalize=1
367 | filters=512
368 | size=3
369 | stride=1
370 | pad=1
371 | activation=leaky
372 |
373 | [shortcut]
374 | from=-3
375 | activation=linear
376 |
377 | [convolutional]
378 | batch_normalize=1
379 | filters=256
380 | size=1
381 | stride=1
382 | pad=1
383 | activation=leaky
384 |
385 | [convolutional]
386 | batch_normalize=1
387 | filters=512
388 | size=3
389 | stride=1
390 | pad=1
391 | activation=leaky
392 |
393 | [shortcut]
394 | from=-3
395 | activation=linear
396 |
397 |
398 | [convolutional]
399 | batch_normalize=1
400 | filters=256
401 | size=1
402 | stride=1
403 | pad=1
404 | activation=leaky
405 |
406 | [convolutional]
407 | batch_normalize=1
408 | filters=512
409 | size=3
410 | stride=1
411 | pad=1
412 | activation=leaky
413 |
414 | [shortcut]
415 | from=-3
416 | activation=linear
417 |
418 |
419 | [convolutional]
420 | batch_normalize=1
421 | filters=256
422 | size=1
423 | stride=1
424 | pad=1
425 | activation=leaky
426 |
427 | [convolutional]
428 | batch_normalize=1
429 | filters=512
430 | size=3
431 | stride=1
432 | pad=1
433 | activation=leaky
434 |
435 | [shortcut]
436 | from=-3
437 | activation=linear
438 |
439 | [convolutional]
440 | batch_normalize=1
441 | filters=256
442 | size=1
443 | stride=1
444 | pad=1
445 | activation=leaky
446 |
447 | [convolutional]
448 | batch_normalize=1
449 | filters=512
450 | size=3
451 | stride=1
452 | pad=1
453 | activation=leaky
454 |
455 | [shortcut]
456 | from=-3
457 | activation=linear
458 |
459 | # Downsample
460 |
461 | [convolutional]
462 | batch_normalize=1
463 | filters=1024
464 | size=3
465 | stride=2
466 | pad=1
467 | activation=leaky
468 |
469 | [convolutional]
470 | batch_normalize=1
471 | filters=512
472 | size=1
473 | stride=1
474 | pad=1
475 | activation=leaky
476 |
477 | [convolutional]
478 | batch_normalize=1
479 | filters=1024
480 | size=3
481 | stride=1
482 | pad=1
483 | activation=leaky
484 |
485 | [shortcut]
486 | from=-3
487 | activation=linear
488 |
489 | [convolutional]
490 | batch_normalize=1
491 | filters=512
492 | size=1
493 | stride=1
494 | pad=1
495 | activation=leaky
496 |
497 | [convolutional]
498 | batch_normalize=1
499 | filters=1024
500 | size=3
501 | stride=1
502 | pad=1
503 | activation=leaky
504 |
505 | [shortcut]
506 | from=-3
507 | activation=linear
508 |
509 | [convolutional]
510 | batch_normalize=1
511 | filters=512
512 | size=1
513 | stride=1
514 | pad=1
515 | activation=leaky
516 |
517 | [convolutional]
518 | batch_normalize=1
519 | filters=1024
520 | size=3
521 | stride=1
522 | pad=1
523 | activation=leaky
524 |
525 | [shortcut]
526 | from=-3
527 | activation=linear
528 |
529 | [convolutional]
530 | batch_normalize=1
531 | filters=512
532 | size=1
533 | stride=1
534 | pad=1
535 | activation=leaky
536 |
537 | [convolutional]
538 | batch_normalize=1
539 | filters=1024
540 | size=3
541 | stride=1
542 | pad=1
543 | activation=leaky
544 |
545 | [shortcut]
546 | from=-3
547 | activation=linear
548 |
549 | ######################
550 |
551 | [convolutional]
552 | batch_normalize=1
553 | filters=512
554 | size=1
555 | stride=1
556 | pad=1
557 | activation=leaky
558 |
559 | [convolutional]
560 | batch_normalize=1
561 | size=3
562 | stride=1
563 | pad=1
564 | filters=1024
565 | activation=leaky
566 |
567 | [convolutional]
568 | batch_normalize=1
569 | filters=512
570 | size=1
571 | stride=1
572 | pad=1
573 | activation=leaky
574 |
575 | [convolutional]
576 | batch_normalize=1
577 | size=3
578 | stride=1
579 | pad=1
580 | filters=1024
581 | activation=leaky
582 |
583 | [convolutional]
584 | batch_normalize=1
585 | filters=512
586 | size=1
587 | stride=1
588 | pad=1
589 | activation=leaky
590 |
591 | [convolutional]
592 | batch_normalize=1
593 | size=3
594 | stride=1
595 | pad=1
596 | filters=1024
597 | activation=leaky
598 |
599 | [convolutional]
600 | size=1
601 | stride=1
602 | pad=1
603 | filters=255
604 | activation=linear
605 |
606 |
607 | [yolo]
608 | mask = 6,7,8
609 | anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
610 | classes=80
611 | num=9
612 | jitter=.3
613 | ignore_thresh = .7
614 | truth_thresh = 1
615 | random=1
616 |
617 |
618 | [route]
619 | layers = -4
620 |
621 | [convolutional]
622 | batch_normalize=1
623 | filters=256
624 | size=1
625 | stride=1
626 | pad=1
627 | activation=leaky
628 |
629 | [upsample]
630 | stride=2
631 |
632 | [route]
633 | layers = -1, 61
634 |
635 |
636 |
637 | [convolutional]
638 | batch_normalize=1
639 | filters=256
640 | size=1
641 | stride=1
642 | pad=1
643 | activation=leaky
644 |
645 | [convolutional]
646 | batch_normalize=1
647 | size=3
648 | stride=1
649 | pad=1
650 | filters=512
651 | activation=leaky
652 |
653 | [convolutional]
654 | batch_normalize=1
655 | filters=256
656 | size=1
657 | stride=1
658 | pad=1
659 | activation=leaky
660 |
661 | [convolutional]
662 | batch_normalize=1
663 | size=3
664 | stride=1
665 | pad=1
666 | filters=512
667 | activation=leaky
668 |
669 | [convolutional]
670 | batch_normalize=1
671 | filters=256
672 | size=1
673 | stride=1
674 | pad=1
675 | activation=leaky
676 |
677 | [convolutional]
678 | batch_normalize=1
679 | size=3
680 | stride=1
681 | pad=1
682 | filters=512
683 | activation=leaky
684 |
685 | [convolutional]
686 | size=1
687 | stride=1
688 | pad=1
689 | filters=255
690 | activation=linear
691 |
692 |
693 | [yolo]
694 | mask = 3,4,5
695 | anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
696 | classes=80
697 | num=9
698 | jitter=.3
699 | ignore_thresh = .7
700 | truth_thresh = 1
701 | random=1
702 |
703 |
704 |
705 | [route]
706 | layers = -4
707 |
708 | [convolutional]
709 | batch_normalize=1
710 | filters=128
711 | size=1
712 | stride=1
713 | pad=1
714 | activation=leaky
715 |
716 | [upsample]
717 | stride=2
718 |
719 | [route]
720 | layers = -1, 36
721 |
722 |
723 |
724 | [convolutional]
725 | batch_normalize=1
726 | filters=128
727 | size=1
728 | stride=1
729 | pad=1
730 | activation=leaky
731 |
732 | [convolutional]
733 | batch_normalize=1
734 | size=3
735 | stride=1
736 | pad=1
737 | filters=256
738 | activation=leaky
739 |
740 | [convolutional]
741 | batch_normalize=1
742 | filters=128
743 | size=1
744 | stride=1
745 | pad=1
746 | activation=leaky
747 |
748 | [convolutional]
749 | batch_normalize=1
750 | size=3
751 | stride=1
752 | pad=1
753 | filters=256
754 | activation=leaky
755 |
756 | [convolutional]
757 | batch_normalize=1
758 | filters=128
759 | size=1
760 | stride=1
761 | pad=1
762 | activation=leaky
763 |
764 | [convolutional]
765 | batch_normalize=1
766 | size=3
767 | stride=1
768 | pad=1
769 | filters=256
770 | activation=leaky
771 |
772 | [convolutional]
773 | size=1
774 | stride=1
775 | pad=1
776 | filters=255
777 | activation=linear
778 |
779 |
780 | [yolo]
781 | mask = 0,1,2
782 | anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
783 | classes=80
784 | num=9
785 | jitter=.3
786 | ignore_thresh = .7
787 | truth_thresh = 1
788 | random=1
--------------------------------------------------------------------------------
/Yolo_Object_Detection/yolo_img.py:
--------------------------------------------------------------------------------
1 | # import the necessary packages
2 | import numpy as np
3 | import argparse
4 | import time
5 | import cv2
6 | import os
7 |
8 | # construct the argument parse and parse the arguments
9 |
10 |
11 | yolo_path='yolo-coco'
12 | # load the COCO class labels our YOLO model was trained on
13 | labelsPath =(yolo_path+"/coco.names")
14 | LABELS = open(labelsPath).read().strip().split("\n")
15 |
16 | # initialize a list of colors to represent each possible class label
17 | np.random.seed(42)
18 | COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),
19 | dtype="uint8")
20 |
21 | # derive the paths to the YOLO weights and model configuration
22 | weightsPath = (yolo_path+"/yolov3.weights")
23 | configPath = (yolo_path+"/yolov3.cfg")
24 |
25 | # load our YOLO object detector trained on COCO dataset (80 classes)
26 | print("[INFO] loading YOLO from disk...")
27 | net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
28 |
29 | # load our input image and grab its spatial dimensions
30 | image = cv2.imread('aluterus_scriptus_1.jpg')
31 | (H, W) = image.shape[:2]
32 |
33 | # determine only the *output* layer names that we need from YOLO
34 | ln = net.getLayerNames()
35 | ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
36 |
37 | # construct a blob from the input image and then perform a forward
38 | # pass of the YOLO object detector, giving us our bounding boxes and
39 | # associated probabilities
40 | blob = cv2.dnn.blobFromImage(image, 1 / 255.0, (416, 416),
41 | swapRB=True, crop=False)
42 | net.setInput(blob)
43 | start = time.time()
44 | layerOutputs = net.forward(ln)
45 | end = time.time()
46 |
47 | # show timing information on YOLO
48 | print("[INFO] YOLO took {:.6f} seconds".format(end - start))
49 |
50 | # initialize our lists of detected bounding boxes, confidences, and class IDs, respectively
51 | boxes = []
52 | confidences = []
53 | classIDs = []
54 |
55 | # loop over each of the layer outputs
56 | for output in layerOutputs:
57 | # loop over each of the detections
58 | for detection in output:
59 | # extract the class ID and confidence (i.e., probability) of
60 | # the current object detection
61 | scores = detection[5:]
62 | classID = np.argmax(scores)
63 | confidence = scores[classID]
64 |
65 | # filter out weak predictions by ensuring the detected
66 | # probability is greater than the minimum probability
67 | if confidence > 0.5:
68 | # scale the bounding box coordinates back relative to the
69 | # size of the image, keeping in mind that YOLO actually
70 | # returns the center (x, y)-coordinates of the bounding
71 | # box followed by the boxes' width and height
72 | box = detection[0:4] * np.array([W, H, W, H])
73 | (centerX, centerY, width, height) = box.astype("int")
74 |
75 | # use the center (x, y)-coordinates to derive the top and
76 | # and left corner of the bounding box
77 | x = int(centerX - (width / 2))
78 | y = int(centerY - (height / 2))
79 |
80 | # update our list of bounding box coordinates, confidences,
81 | # and class IDs
82 | boxes.append([x, y, int(width), int(height)])
83 | confidences.append(float(confidence))
84 | classIDs.append(classID)
85 |
86 | # apply non-maxima suppression to suppress weak, overlapping bounding
87 | # boxes
88 | idxs = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.3)
89 |
90 | # ensure at least one detection exists
91 | if len(idxs) > 0:
92 | # loop over the indexes we are keeping
93 | for i in idxs.flatten():
94 | # extract the bounding box coordinates
95 | (x, y) = (boxes[i][0], boxes[i][1])
96 | (w, h) = (boxes[i][2], boxes[i][3])
97 |
98 | # draw a bounding box rectangle and label on the image
99 | color = [int(c) for c in COLORS[classIDs[i]]]
100 | cv2.rectangle(image, (x, y), (x + w, y + h), color, 2)
101 | text = "{}: {:.4f}".format(LABELS[classIDs[i]], confidences[i])
102 | cv2.putText(image, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX,
103 | 0.5, color, 2)
104 |
105 | # show the output image
106 | cv2.imshow("Image", image)
107 | cv2.waitKey(0)
--------------------------------------------------------------------------------
/Yolo_Object_Detection/yolo_video.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Created on Sun Jan 24 21:37:32 2021
4 |
5 | @author: Nouman ahmad
6 | """
7 |
8 | # USAGE
9 |
10 |
11 | # import the necessary packages
12 | import numpy as np
13 | import imutils
14 | import time
15 | import cv2
16 |
17 | # construct the argument parse and parse the arguments
18 |
19 |
20 | yolo_path='yolo-coco'
21 | # load the COCO class labels our YOLO model was trained on
22 | labelsPath =(yolo_path+"/coco.names")
23 | LABELS = open(labelsPath).read().strip().split("\n")
24 |
25 | # initialize a list of colors to represent each possible class label
26 | np.random.seed(42)
27 | COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),
28 | dtype="uint8")
29 |
30 |
31 |
32 | # derive the paths to the YOLO weights and model configuration
33 | weightsPath = (yolo_path+"/yolov3.weights")
34 | configPath = (yolo_path+"/yolov3.cfg")
35 |
36 | # load our YOLO object detector trained on COCO dataset (80 classes)
37 | # and determine only the *output* layer names that we need from YOLO
38 | print("[INFO] loading YOLO from disk...")
39 | net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
40 | ln = net.getLayerNames()
41 | ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
42 |
43 | # initialize the video stream, pointer to output video file, and
44 | # frame dimensions
45 | vs = cv2.VideoCapture(0)
46 |
47 | (W, H) = (None, None)
48 |
49 | # try to determine the total number of frames in the video file
50 | try:
51 | prop = cv2.cv.CV_CAP_PROP_FRAME_COUNT if imutils.is_cv2() \
52 | else cv2.CAP_PROP_FRAME_COUNT
53 | total = int(vs.get(prop))
54 | print("[INFO] {} total frames in video".format(total))
55 |
56 | # an error occurred while trying to determine the total
57 | # number of frames in the video file
58 | except:
59 | print("[INFO] could not determine # of frames in video")
60 | print("[INFO] no approx. completion time can be provided")
61 | total = -1
62 |
63 | # loop over frames from the video file stream
64 | while True:
65 | # read the next frame from the file
66 | (grabbed, frame) = vs.read()
67 |
68 | # if the frame was not grabbed, then we have reached the end
69 | # of the stream
70 | if not grabbed:
71 | break
72 |
73 | # if the frame dimensions are empty, grab them
74 | if W is None or H is None:
75 | (H, W) = frame.shape[:2]
76 |
77 | # construct a blob from the input frame and then perform a forward
78 | # pass of the YOLO object detector, giving us our bounding boxes
79 | # and associated probabilities
80 | blob = cv2.dnn.blobFromImage(frame, 1 / 255.0, (416, 416),
81 | swapRB=True, crop=False)
82 | net.setInput(blob)
83 | start = time.time()
84 | layerOutputs = net.forward(ln)
85 | end = time.time()
86 |
87 | # initialize our lists of detected bounding boxes, confidences,
88 | # and class IDs, respectively
89 | boxes = []
90 | confidences = []
91 | classIDs = []
92 |
93 | # loop over each of the layer outputs
94 | for output in layerOutputs:
95 | # loop over each of the detections
96 | for detection in output:
97 | # extract the class ID and confidence (i.e., probability)
98 | # of the current object detection
99 | scores = detection[5:]
100 | classID = np.argmax(scores)
101 | confidence = scores[classID]
102 |
103 | # filter out weak predictions by ensuring the detected
104 | # probability is greater than the minimum probability
105 | if confidence > 0.5:
106 | # scale the bounding box coordinates back relative to
107 | # the size of the image, keeping in mind that YOLO
108 | # actually returns the center (x, y)-coordinates of
109 | # the bounding box followed by the boxes' width and
110 | # height
111 | box = detection[0:4] * np.array([W, H, W, H])
112 | (centerX, centerY, width, height) = box.astype("int")
113 |
114 | # use the center (x, y)-coordinates to derive the top
115 | # and and left corner of the bounding box
116 | x = int(centerX - (width / 2))
117 | y = int(centerY - (height / 2))
118 |
119 | # update our list of bounding box coordinates,
120 | # confidences, and class IDs
121 | boxes.append([x, y, int(width), int(height)])
122 | confidences.append(float(confidence))
123 | classIDs.append(classID)
124 |
125 | # apply non-maxima suppression to suppress weak, overlapping
126 | # bounding boxes
127 | idxs = cv2.dnn.NMSBoxes(boxes, confidences, 0.5,
128 | 0.3)
129 |
130 | # ensure at least one detection exists
131 | if len(idxs) > 0:
132 | # loop over the indexes we are keeping
133 | for i in idxs.flatten():
134 | # extract the bounding box coordinates
135 | (x, y) = (boxes[i][0], boxes[i][1])
136 | (w, h) = (boxes[i][2], boxes[i][3])
137 |
138 | # draw a bounding box rectangle and label on the frame
139 | color = [int(c) for c in COLORS[classIDs[i]]]
140 | cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2)
141 | text = "{}: {:.4f}".format(LABELS[classIDs[i]],
142 | confidences[i])
143 | cv2.putText(frame, text, (x, y - 5),cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
144 | frameresize=cv2.resize(frame,(960,520))
145 | cv2.imshow("Application", frameresize)
146 | key = cv2.waitKey(1)
147 | if key == ord('q'):
148 | break
149 |
150 |
151 | # release the file pointers
152 | cv2.destroyAllWindows()
153 | vs.release()
--------------------------------------------------------------------------------