├── .coveragerc ├── .floydexpt ├── .floydignore ├── .gitattributes ├── .gitignore ├── .travis.yml ├── GooMPy ├── LICENSE.md ├── README.md ├── example.py ├── goompy.png ├── goompy │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-36.pyc │ └── key.py └── setup.py ├── LICENSE ├── README.md ├── alarm.mp3 ├── cfg ├── .DS_Store ├── coco.names ├── extraction.cfg ├── extraction.conv.cfg ├── tiny-yolo-1c.cfg ├── tiny-yolo-2c.cfg ├── tiny-yolo-4c.cfg ├── tiny-yolo-voc-10c.cfg ├── tiny-yolo-voc-7c.cfg ├── tiny-yolo-voc.cfg ├── tiny-yolo-voc27.cfg ├── tiny-yolo.cfg ├── v1.1 │ ├── person-bottle.cfg │ ├── tiny-coco.cfg │ ├── tiny-yolo-4c.cfg │ ├── tiny-yolov1.cfg │ ├── yolo-coco.cfg │ └── yolov1.cfg ├── v1 │ ├── tiny-old.profile │ ├── tiny.profile │ ├── yolo-2c.cfg │ ├── yolo-4c.cfg │ ├── yolo-full.cfg │ ├── yolo-small.cfg │ ├── yolo-tiny-extract.cfg │ ├── yolo-tiny-extract_.cfg │ ├── yolo-tiny.cfg │ └── yolo-tiny4c.cfg ├── yolo-voc.2.0.cfg ├── yolo-voc.cfg ├── yolo.cfg ├── yolo9000.cfg ├── yolo_2class_box11.cfg └── yolov3.cfg ├── cvm1.py ├── darkflow ├── .DS_Store ├── __init__.py ├── cli.py ├── cython_utils │ ├── .DS_Store │ ├── __init__.py │ ├── cy_yolo2_findboxes.cpython-35m-darwin.so │ ├── cy_yolo2_findboxes.pyx │ ├── cy_yolo_findboxes.cpython-35m-darwin.so │ ├── cy_yolo_findboxes.pyx │ ├── nms.cpython-35m-darwin.so │ ├── nms.pxd │ └── nms.pyx ├── dark │ ├── .DS_Store │ ├── __init__.py │ ├── connected.py │ ├── convolution.py │ ├── darknet.py │ ├── darkop.py │ └── layer.py ├── defaults.py ├── net │ ├── .DS_Store │ ├── __init__.py │ ├── build.py │ ├── flow.py │ ├── framework.py │ ├── help.py │ ├── mnist │ │ └── run.py │ ├── ops │ │ ├── .DS_Store │ │ ├── __init__.py │ │ ├── baseop.py │ │ ├── convolution.py │ │ └── simple.py │ ├── vanilla │ │ ├── .DS_Store │ │ ├── __init__.py │ │ └── train.py │ ├── yolo │ │ ├── .DS_Store │ │ ├── __init__.py │ │ ├── data.py │ │ ├── misc.py │ │ ├── predict.py │ │ └── train.py │ └── yolov2 │ │ ├── .DS_Store │ │ ├── __init__.py │ │ ├── data.py │ │ ├── predict.py │ │ └── train.py ├── utils │ ├── .DS_Store │ ├── __init__.py │ ├── box.py │ ├── im_transform.py │ ├── loader.py │ ├── pascal_voc_clean_xml.py │ └── process.py └── version.py ├── dista.py ├── fatigue.py ├── flow ├── guilat.py ├── guir.py ├── icons ├── advt.png ├── advt1.jpg ├── back.png ├── humid.png ├── offline.jpg ├── temperature.png ├── top.png └── windspeed.png ├── images ├── Screen Shot 2018-03-31 at 5.08.08 pm.png ├── Screen Shot 2018-03-31 at 5.55.32 pm.png └── Screen Shot 2018-03-31 at 5.56.00 pm.png ├── main.py ├── mapscache ├── 18.267420_71.158887_10_roadmap_640_640.jpg ├── 18.267420_72.037794_10_roadmap_640_640.jpg ├── 18.267420_72.916700_10_roadmap_640_640.jpg ├── 18.267420_73.795606_10_roadmap_640_640.jpg ├── 19.099189_72.914983_20_roadmap_640_640.jpg ├── 19.099189_72.915842_20_roadmap_640_640.jpg ├── 19.099189_72.916700_20_roadmap_640_640.jpg ├── 19.099189_72.917558_20_roadmap_640_640.jpg ├── 19.100000_71.158887_10_roadmap_640_640.jpg ├── 19.100000_72.037794_10_roadmap_640_640.jpg ├── 19.100000_72.914983_20_roadmap_640_640.jpg ├── 19.100000_72.915842_20_roadmap_640_640.jpg ├── 19.100000_72.916700_10_roadmap_640_640.jpg ├── 19.100000_72.916700_20_roadmap_640_640.jpg ├── 19.100000_72.917558_20_roadmap_640_640.jpg ├── 19.100000_73.795606_10_roadmap_640_640.jpg ├── 19.100811_72.914983_20_roadmap_640_640.jpg ├── 19.100811_72.915842_20_roadmap_640_640.jpg ├── 19.100811_72.916700_20_roadmap_640_640.jpg ├── 19.100811_72.917558_20_roadmap_640_640.jpg ├── 19.101622_72.914983_20_roadmap_640_640.jpg ├── 19.101622_72.915842_20_roadmap_640_640.jpg ├── 19.101622_72.916700_20_roadmap_640_640.jpg ├── 19.101622_72.917558_20_roadmap_640_640.jpg ├── 19.928412_71.158887_10_roadmap_640_640.jpg ├── 19.928412_72.037794_10_roadmap_640_640.jpg ├── 19.928412_72.916700_10_roadmap_640_640.jpg ├── 19.928412_73.795606_10_roadmap_640_640.jpg ├── 20.752504_71.158887_10_roadmap_640_640.jpg ├── 20.752504_72.037794_10_roadmap_640_640.jpg ├── 20.752504_72.916700_10_roadmap_640_640.jpg └── 20.752504_73.795606_10_roadmap_640_640.jpg ├── ses.py ├── setup.py ├── sounds ├── .DS_Store ├── stop_bn.mp3 ├── stop_en.mp3 ├── stop_hi.mp3 ├── stop_mh.mp3 ├── tl_bn.mp3 ├── tl_en.mp3 ├── tl_hi.mp3 ├── tl_mh.mp3 ├── tr_bn.mp3 ├── tr_en.mp3 ├── tr_hi.mp3 ├── tr_mh.mp3 ├── vehicle_ahead_bn.mp3 ├── vehicle_ahead_en.mp3 ├── vehicle_ahead_hi.mp3 └── vehicle_ahead_mh.mp3 ├── tai.py ├── tapi.py ├── test ├── .DS_Store ├── requirements-testing.txt ├── test_darkflow.py └── training │ ├── annotations │ ├── 1.xml │ └── 2.xml │ └── images │ ├── 1.jpg │ └── 2.jpg ├── turnr.py └── yolov2.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = test/* -------------------------------------------------------------------------------- /.floydexpt: -------------------------------------------------------------------------------- 1 | {"family_id": "w9ctTcnn7uaGTLSYGveeTU", "namespace": "asbasti", "name": "cv"} -------------------------------------------------------------------------------- /.floydignore: -------------------------------------------------------------------------------- 1 | 2 | # Directories and files to ignore when uploading code to floyd 3 | 4 | .git 5 | .eggs 6 | eggs 7 | lib 8 | lib64 9 | parts 10 | sdist 11 | var 12 | *.pyc 13 | *.swp 14 | .DS_Store 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Python bytecode 3 | *.pyc 4 | 5 | # Weight files 6 | bin/ 7 | 8 | # Sample image data 9 | sample_img/*.jpg 10 | !sample_img/sample_*.jpg 11 | sample_img/out/* 12 | 13 | # Annotated test results 14 | results/ 15 | 16 | # Intermediate training data 17 | backup/ 18 | tfnet/yolo/parse-history.txt 19 | tfnet/yolo/*.parsed 20 | *.txt 21 | !requirements*.txt 22 | *.pb 23 | /profile 24 | /test.py 25 | 26 | # Built cython files 27 | darkflow/cython_utils/*.pyd 28 | darkflow/cython_utils/*.c 29 | 30 | #egg-info 31 | darkflow.egg-info/ 32 | 33 | #Other build stuff 34 | build/ 35 | 36 | #TensorBoard logs 37 | summary/ 38 | 39 | #Built graphs 40 | built_graph/ 41 | 42 | #Training checkpoints 43 | ckpt/* 44 | 45 | #pytest cache 46 | .cache/ 47 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | 4 | language: python 5 | python: 6 | - "3.6" 7 | 8 | cache: 9 | directories: 10 | - bin #cache .weights files 11 | 12 | # command to install dependencies 13 | install: 14 | - pip install -r test/requirements-testing.txt 15 | - pip install -e . 16 | 17 | # command to run tests 18 | script: pytest -x --cov=./ 19 | 20 | #Upload code coverage statistics 21 | after_success: 22 | - codecov -------------------------------------------------------------------------------- /GooMPy/README.md: -------------------------------------------------------------------------------- 1 | # GooMPy 2 | 3 | 4 | 5 | Interactive Google Maps for Python. Tested with Python2.7 and Python3.6. 6 | 7 | GooMPy provides a Python interface to the Google Static Maps API, automatically 8 | downloading and stitching together map tiles into a single image that you can 9 | zoom and pan dynamically in your Python program. To support using maps when 10 | you don't have an internet connection, GooMPY provides a pre-fetching function 11 | that stores the tiles in a caching folder. To keep the amount of 12 | tile-downloading to a minimum, GooMPy doesn't have functions for adding 13 | waypoints or other annotations to the map through Google's API. 14 | 15 | To run GooMPy you'll need the Python Image Library (PIL) or equivalent (Pillow 16 | for Windows and OS X) installed on your computer. The repository includes an 17 | example using Tkinter, though you should be able to use GooMPy with other 18 | toolkits like wx and Qt. 19 | 20 | Because Google limits the number of tiles that you can download during a given 21 | time period, we recommend setting up an API key as described here: 22 | 23 | https://developers.google.com/maps/documentation/staticmaps/#api\_key 24 | 25 | Once you have your key, put it in the file goompy/key.py, and GooMPy will use 26 | it in fetching map tiles. If you run out of downloads, the tiles will be black 27 | with a "capacity exceeded" image in them. 28 | 29 | -------------------------------------------------------------------------------- /GooMPy/example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | ''' 3 | Example of using GooMPy with Tkinter 4 | 5 | Copyright (C) 2015 Alec Singer and Simon D. Levy 6 | 7 | This code is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as 9 | published by the Free Software Foundation, either version 3 of the 10 | License, or (at your option) any later version. 11 | This code is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with this code. If not, see . 17 | ''' 18 | 19 | import sys 20 | 21 | if sys.version_info[0] == 2: 22 | import Tkinter as tk 23 | else: 24 | import tkinter as tk 25 | 26 | from PIL import ImageTk 27 | 28 | from goompy import GooMPy 29 | 30 | WIDTH = 800 31 | HEIGHT = 500 32 | 33 | LATITUDE = 37.7913838 34 | LONGITUDE = -79.44398934 35 | ZOOM = 15 36 | MAPTYPE = 'roadmap' 37 | 38 | class UI(tk.Tk): 39 | 40 | def __init__(self): 41 | 42 | tk.Tk.__init__(self) 43 | 44 | self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT)) 45 | self.title('GooMPy') 46 | 47 | self.canvas = tk.Canvas(self, width=WIDTH, height=HEIGHT) 48 | 49 | self.canvas.pack() 50 | 51 | self.bind("", self.check_quit) 52 | self.bind('', self.drag) 53 | self.bind('', self.click) 54 | 55 | self.label = tk.Label(self.canvas) 56 | 57 | self.radiogroup = tk.Frame(self.canvas) 58 | self.radiovar = tk.IntVar() 59 | self.maptypes = ['roadmap', 'terrain', 'satellite', 'hybrid'] 60 | self.add_radio_button('Road Map', 0) 61 | self.add_radio_button('Terrain', 1) 62 | self.add_radio_button('Satellite', 2) 63 | self.add_radio_button('Hybrid', 3) 64 | 65 | self.zoom_in_button = self.add_zoom_button('+', +1) 66 | self.zoom_out_button = self.add_zoom_button('-', -1) 67 | 68 | self.zoomlevel = ZOOM 69 | 70 | maptype_index = 0 71 | self.radiovar.set(maptype_index) 72 | 73 | self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE) 74 | 75 | self.restart() 76 | 77 | def add_zoom_button(self, text, sign): 78 | 79 | button = tk.Button(self.canvas, text=text, width=1, command=lambda:self.zoom(sign)) 80 | return button 81 | 82 | def reload(self): 83 | 84 | self.coords = None 85 | self.redraw() 86 | 87 | self['cursor'] = '' 88 | 89 | 90 | def restart(self): 91 | 92 | # A little trick to get a watch cursor along with loading 93 | self['cursor'] = 'watch' 94 | self.after(1, self.reload) 95 | 96 | def add_radio_button(self, text, index): 97 | 98 | maptype = self.maptypes[index] 99 | tk.Radiobutton(self.radiogroup, text=maptype, variable=self.radiovar, value=index, 100 | command=lambda:self.usemap(maptype)).grid(row=0, column=index) 101 | 102 | def click(self, event): 103 | 104 | self.coords = event.x, event.y 105 | 106 | def drag(self, event): 107 | 108 | self.goompy.move(self.coords[0]-event.x, self.coords[1]-event.y) 109 | self.image = self.goompy.getImage() 110 | self.redraw() 111 | self.coords = event.x, event.y 112 | 113 | def redraw(self): 114 | 115 | self.image = self.goompy.getImage() 116 | self.image_tk = ImageTk.PhotoImage(self.image) 117 | self.label['image'] = self.image_tk 118 | 119 | self.label.place(x=0, y=0, width=WIDTH, height=HEIGHT) 120 | 121 | self.radiogroup.place(x=0,y=0) 122 | 123 | x = int(self.canvas['width']) - 50 124 | y = int(self.canvas['height']) - 80 125 | 126 | self.zoom_in_button.place(x= x, y=y) 127 | self.zoom_out_button.place(x= x, y=y+30) 128 | 129 | def usemap(self, maptype): 130 | 131 | self.goompy.useMaptype(maptype) 132 | self.restart() 133 | 134 | def zoom(self, sign): 135 | 136 | newlevel = self.zoomlevel + sign 137 | if newlevel > 0 and newlevel < 22: 138 | self.zoomlevel = newlevel 139 | self.goompy.useZoom(newlevel) 140 | self.restart() 141 | 142 | def check_quit(self, event): 143 | 144 | if ord(event.char) == 27: # ESC 145 | exit(0) 146 | 147 | UI().mainloop() 148 | -------------------------------------------------------------------------------- /GooMPy/goompy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/GooMPy/goompy.png -------------------------------------------------------------------------------- /GooMPy/goompy/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/GooMPy/goompy/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /GooMPy/goompy/key.py: -------------------------------------------------------------------------------- 1 | 2 | ''' 3 | GooMPy: Google Maps for Python 4 | Copyright (C) 2015 Alec Singer and Simon D. Levy 5 | This code is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as 7 | published by the Free Software Foundation, either version 3 of the 8 | License, or (at your option) any later version. 9 | This code is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this code. If not, see . 15 | ''' 16 | 17 | # Get a key from https://developers.google.com/maps/documentation/staticmaps/#api_key and put it between the 18 | # quotation marks below: 19 | _KEY = '' 20 | 21 | -------------------------------------------------------------------------------- /GooMPy/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ''' 4 | setup.py - Python distutils setup file for GooMPy package. 5 | 6 | Copyright (C) 2015 Alec Singer and Simon D. Levy 7 | This code is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as 9 | published by the Free Software Foundation, either version 3 of the 10 | License, or (at your option) any later version. 11 | This code is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with this code. If not, see . 17 | ''' 18 | 19 | from distutils.core import setup 20 | 21 | setup (name = 'GooMPy', 22 | version = '0.1', 23 | install_requires = ['PIL'], 24 | description = 'Google Maps for Python', 25 | packages = ['goompy',], 26 | author='Alec Singer and Simon D. Levy', 27 | author_email='simon.d.levy@gmail.com', 28 | license='LGPL', 29 | platforms='Linux; Windows; OS X' 30 | ) 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Traffic Sign and Object Detection using YOLO Algorithm 2 | 3 | We attempt to make Traffic Sign and Object detection using YOLO(You-Only-Look-Once) Algorithm. The reason behind choosing of YOLO is because of the high speed of detection with reasonable amount of accuracy(~74%). YOLO Algorithm is popular due to its Real-Time Object detection capability. 4 | 5 | - More About YOLO: [Darknet/YOLO](https://pjreddie.com/darknet/yolo/) 6 | - GitHub: [thtrieu/darkflow](https://github.com/thtrieu/darkflow) 7 | 8 | This Project was submitted in **Smart India Hackathon 2018** under team name: 6_Pixels. 9 | 10 | Along with Object Detection our model has been designed with easy to use and navigate interface (User Interface) using PYGAME library of Python. The Model also has the capability to notify user about the Traffic Signs and Vehicles using Speech. The speech is available in 4 Languages at the moment namely: English, Hindi, Bangali, Marathi. 11 | 12 | Also we have attempted to add the feature of Fatigue detection of the driver based on closing of eye using HaarCascades of OpenCV. If the driver's eyes remain closed for a long time, the alarm starts to ring to wake the driver up. 13 | 14 | The model also has the capability to estimate the distance of vehicle in front of it thus setting a stepping stone towards self-driving cars. Also you can view Map and Weather Condition in the User Interface. Below are some results and Screenshots of the final project. 15 | 16 | # Usage 17 | 18 | Clone the repository to your local machine 19 | 20 | `git clone https://github.com/dark-archerx/Traffic-Signs-and-Object-Detection` 21 | 22 | Navigate to the Directory 23 | 24 | `cd Traffic-Signs-and-Object-Detection` 25 | 26 | Install all the Requirements given below. 27 | 28 | Download pre-trained `weights` or train your own and add them to `main.py` and also add the `cfg` file to your `main.py` file. 29 | 30 | Execute main.py file! 31 | 32 | 33 | # Requirements 34 | 35 | * Darkflow - https://github.com/thtrieu/darkflow 36 | * Tensorflow - https://tensorflow.org 37 | * Numpy - https://numpy.org 38 | * OpenCV - https://opencv.org 39 | * Pygame - https://pygame.org 40 | * Geocoder: 41 | `pip3 install geocoder` 42 | * playsound: 43 | `pip3 install playsound` 44 | * GooMPy: 45 | `git clone https://github.com/simondlevy/GooMPy` 46 | * PyOwm Weather API: 47 | `pip3 install pyowm` 48 | 49 | After instllation of pyowm, You would require an API Key which can be generated from the [Official Website](https://home.openweathermap.org/users/sign_up) For more information on PyOwm check out [csparpa/pyown](https://github.com/csparpa/pyowm). Paste the generated API Key in Line 127 of `main.py` 50 | 51 | # ScreenShots 52 | ![Stop Sign Detection](https://github.com/dark-archerx/Traffic-Signs-and-Object-Detection/blob/master/images/Screen%20Shot%202018-03-31%20at%205.08.08%20pm.png) 53 | ![Traffic Light](https://github.com/dark-archerx/Traffic-Signs-and-Object-Detection/blob/master/images/Screen%20Shot%202018-03-31%20at%205.55.32%20pm.png) 54 | ![Car Detection](https://github.com/dark-archerx/Traffic-Signs-and-Object-Detection/blob/master/images/Screen%20Shot%202018-03-31%20at%205.56.00%20pm.png) 55 | -------------------------------------------------------------------------------- /alarm.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/alarm.mp3 -------------------------------------------------------------------------------- /cfg/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/cfg/.DS_Store -------------------------------------------------------------------------------- /cfg/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 81 | -------------------------------------------------------------------------------- /cfg/extraction.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=128 3 | subdivisions=1 4 | height=224 5 | width=224 6 | max_crop=320 7 | channels=3 8 | momentum=0.9 9 | decay=0.0005 10 | 11 | learning_rate=0.1 12 | policy=poly 13 | power=4 14 | max_batches=1600000 15 | 16 | [convolutional] 17 | batch_normalize=1 18 | filters=64 19 | size=7 20 | stride=2 21 | pad=1 22 | activation=leaky 23 | 24 | [maxpool] 25 | size=2 26 | stride=2 27 | 28 | [convolutional] 29 | batch_normalize=1 30 | filters=192 31 | size=3 32 | stride=1 33 | pad=1 34 | activation=leaky 35 | 36 | [maxpool] 37 | size=2 38 | stride=2 39 | 40 | [convolutional] 41 | batch_normalize=1 42 | filters=128 43 | size=1 44 | stride=1 45 | pad=1 46 | activation=leaky 47 | 48 | [convolutional] 49 | batch_normalize=1 50 | filters=256 51 | size=3 52 | stride=1 53 | pad=1 54 | activation=leaky 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=256 59 | size=1 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [convolutional] 65 | batch_normalize=1 66 | filters=512 67 | size=3 68 | stride=1 69 | pad=1 70 | activation=leaky 71 | 72 | [maxpool] 73 | size=2 74 | stride=2 75 | 76 | [convolutional] 77 | batch_normalize=1 78 | filters=256 79 | size=1 80 | stride=1 81 | pad=1 82 | activation=leaky 83 | 84 | [convolutional] 85 | batch_normalize=1 86 | filters=512 87 | size=3 88 | stride=1 89 | pad=1 90 | activation=leaky 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | filters=256 95 | size=1 96 | stride=1 97 | pad=1 98 | activation=leaky 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | filters=512 103 | size=3 104 | stride=1 105 | pad=1 106 | activation=leaky 107 | 108 | [convolutional] 109 | batch_normalize=1 110 | filters=256 111 | size=1 112 | stride=1 113 | pad=1 114 | activation=leaky 115 | 116 | [convolutional] 117 | batch_normalize=1 118 | filters=512 119 | size=3 120 | stride=1 121 | pad=1 122 | activation=leaky 123 | 124 | [convolutional] 125 | batch_normalize=1 126 | filters=256 127 | size=1 128 | stride=1 129 | pad=1 130 | activation=leaky 131 | 132 | [convolutional] 133 | batch_normalize=1 134 | filters=512 135 | size=3 136 | stride=1 137 | pad=1 138 | activation=leaky 139 | 140 | [convolutional] 141 | batch_normalize=1 142 | filters=512 143 | size=1 144 | stride=1 145 | pad=1 146 | activation=leaky 147 | 148 | [convolutional] 149 | batch_normalize=1 150 | filters=1024 151 | size=3 152 | stride=1 153 | pad=1 154 | activation=leaky 155 | 156 | [maxpool] 157 | size=2 158 | stride=2 159 | 160 | [convolutional] 161 | batch_normalize=1 162 | filters=512 163 | size=1 164 | stride=1 165 | pad=1 166 | activation=leaky 167 | 168 | [convolutional] 169 | batch_normalize=1 170 | filters=1024 171 | size=3 172 | stride=1 173 | pad=1 174 | activation=leaky 175 | 176 | [convolutional] 177 | batch_normalize=1 178 | filters=512 179 | size=1 180 | stride=1 181 | pad=1 182 | activation=leaky 183 | 184 | [convolutional] 185 | batch_normalize=1 186 | filters=1024 187 | size=3 188 | stride=1 189 | pad=1 190 | activation=leaky 191 | 192 | [convolutional] 193 | filters=1000 194 | size=1 195 | stride=1 196 | pad=1 197 | activation=leaky 198 | 199 | [avgpool] 200 | 201 | [softmax] 202 | groups=1 203 | 204 | [cost] 205 | type=sse 206 | 207 | -------------------------------------------------------------------------------- /cfg/extraction.conv.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=1 3 | subdivisions=1 4 | height=256 5 | width=256 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.5 11 | policy=poly 12 | power=6 13 | max_batches=500000 14 | 15 | [convolutional] 16 | filters=64 17 | size=7 18 | stride=2 19 | pad=1 20 | activation=leaky 21 | 22 | [maxpool] 23 | size=2 24 | stride=2 25 | 26 | [convolutional] 27 | filters=192 28 | size=3 29 | stride=1 30 | pad=1 31 | activation=leaky 32 | 33 | [maxpool] 34 | size=2 35 | stride=2 36 | 37 | [convolutional] 38 | filters=128 39 | size=1 40 | stride=1 41 | pad=1 42 | activation=leaky 43 | 44 | [convolutional] 45 | filters=256 46 | size=3 47 | stride=1 48 | pad=1 49 | activation=leaky 50 | 51 | [convolutional] 52 | filters=256 53 | size=1 54 | stride=1 55 | pad=1 56 | activation=leaky 57 | 58 | [convolutional] 59 | filters=512 60 | size=3 61 | stride=1 62 | pad=1 63 | activation=leaky 64 | 65 | [maxpool] 66 | size=2 67 | stride=2 68 | 69 | [convolutional] 70 | filters=256 71 | size=1 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [convolutional] 77 | filters=512 78 | size=3 79 | stride=1 80 | pad=1 81 | activation=leaky 82 | 83 | [convolutional] 84 | filters=256 85 | size=1 86 | stride=1 87 | pad=1 88 | activation=leaky 89 | 90 | [convolutional] 91 | filters=512 92 | size=3 93 | stride=1 94 | pad=1 95 | activation=leaky 96 | 97 | [convolutional] 98 | filters=256 99 | size=1 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [convolutional] 105 | filters=512 106 | size=3 107 | stride=1 108 | pad=1 109 | activation=leaky 110 | 111 | [convolutional] 112 | filters=256 113 | size=1 114 | stride=1 115 | pad=1 116 | activation=leaky 117 | 118 | [convolutional] 119 | filters=512 120 | size=3 121 | stride=1 122 | pad=1 123 | activation=leaky 124 | 125 | [convolutional] 126 | filters=512 127 | size=1 128 | stride=1 129 | pad=1 130 | activation=leaky 131 | 132 | [convolutional] 133 | filters=1024 134 | size=3 135 | stride=1 136 | pad=1 137 | activation=leaky 138 | 139 | [maxpool] 140 | size=2 141 | stride=2 142 | 143 | [convolutional] 144 | filters=512 145 | size=1 146 | stride=1 147 | pad=1 148 | activation=leaky 149 | 150 | [convolutional] 151 | filters=1024 152 | size=3 153 | stride=1 154 | pad=1 155 | activation=leaky 156 | 157 | [convolutional] 158 | filters=512 159 | size=1 160 | stride=1 161 | pad=1 162 | activation=leaky 163 | 164 | [convolutional] 165 | filters=1024 166 | size=3 167 | stride=1 168 | pad=1 169 | activation=leaky 170 | 171 | [avgpool] 172 | 173 | [connected] 174 | output=1000 175 | activation=leaky 176 | 177 | [softmax] 178 | groups=1 179 | 180 | -------------------------------------------------------------------------------- /cfg/tiny-yolo-1c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | # Training 3 | # batch=64 4 | # subdivisions=2 5 | # Testing 6 | batch=1 7 | subdivisions=1 8 | width=416 9 | height=416 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=16 28 | size=3 29 | stride=1 30 | pad=1 31 | activation=leaky 32 | 33 | [maxpool] 34 | size=2 35 | stride=2 36 | 37 | [convolutional] 38 | batch_normalize=1 39 | filters=32 40 | size=3 41 | stride=1 42 | pad=1 43 | activation=leaky 44 | 45 | [maxpool] 46 | size=2 47 | stride=2 48 | 49 | [convolutional] 50 | batch_normalize=1 51 | filters=64 52 | size=3 53 | stride=1 54 | pad=1 55 | activation=leaky 56 | 57 | [maxpool] 58 | size=2 59 | stride=2 60 | 61 | [convolutional] 62 | batch_normalize=1 63 | filters=128 64 | size=3 65 | stride=1 66 | pad=1 67 | activation=leaky 68 | 69 | [maxpool] 70 | size=2 71 | stride=2 72 | 73 | [convolutional] 74 | batch_normalize=1 75 | filters=256 76 | size=3 77 | stride=1 78 | pad=1 79 | activation=leaky 80 | 81 | [maxpool] 82 | size=2 83 | stride=2 84 | 85 | [convolutional] 86 | batch_normalize=1 87 | filters=512 88 | size=3 89 | stride=1 90 | pad=1 91 | activation=leaky 92 | 93 | [maxpool] 94 | size=2 95 | stride=1 96 | 97 | [convolutional] 98 | batch_normalize=1 99 | filters=1024 100 | size=3 101 | stride=1 102 | pad=1 103 | activation=leaky 104 | 105 | ########### 106 | 107 | [convolutional] 108 | batch_normalize=1 109 | size=3 110 | stride=1 111 | pad=1 112 | filters=512 113 | activation=leaky 114 | 115 | [convolutional] 116 | size=1 117 | stride=1 118 | pad=1 119 | filters=425 120 | activation=linear 121 | 122 | [region] 123 | anchors = 0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828 124 | bias_match=1 125 | classes=80 126 | coords=4 127 | num=5 128 | softmax=1 129 | jitter=.2 130 | rescore=0 131 | 132 | object_scale=5 133 | noobject_scale=1 134 | class_scale=1 135 | coord_scale=1 136 | 137 | absolute=1 138 | thresh = .6 139 | random=1 140 | -------------------------------------------------------------------------------- /cfg/tiny-yolo-2c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=2 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | saturation=.75 11 | exposure=.75 12 | hue = .1 13 | 14 | learning_rate=0.0005 15 | policy=steps 16 | steps=200,400,600,800,20000,30000 17 | scales=2.5,2,2,2,.1,.1 18 | max_batches = 40000 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=2 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | size=3 95 | stride=1 96 | pad=1 97 | filters=1024 98 | activation=leaky 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | size=3 103 | stride=1 104 | pad=1 105 | filters=256 106 | activation=leaky 107 | 108 | [connected] 109 | output= 1470 110 | activation=linear 111 | 112 | [detection] 113 | classes=20 114 | coords=4 115 | rescore=1 116 | side=7 117 | num=2 118 | softmax=0 119 | sqrt=1 120 | jitter=.2 121 | 122 | object_scale=1 123 | noobject_scale=.5 124 | class_scale=1 125 | coord_scale=5 126 | 127 | -------------------------------------------------------------------------------- /cfg/tiny-yolo-4c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | width=416 5 | height=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.001 15 | max_batches = 40100 16 | policy=steps 17 | steps=-1,100,20000,30000 18 | scales=.1,10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=1 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | filters=1024 95 | size=3 96 | stride=1 97 | pad=1 98 | activation=leaky 99 | 100 | ########### 101 | 102 | [convolutional] 103 | batch_normalize=1 104 | size=3 105 | stride=1 106 | pad=1 107 | filters=1024 108 | activation=leaky 109 | 110 | [convolutional] 111 | size=1 112 | stride=1 113 | pad=1 114 | filters=45 115 | activation=linear 116 | 117 | [region] 118 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 119 | bias_match=1 120 | classes=4 121 | coords=4 122 | num=5 123 | softmax=1 124 | jitter=.2 125 | rescore=1 126 | 127 | object_scale=5 128 | noobject_scale=1 129 | class_scale=1 130 | coord_scale=1 131 | 132 | absolute=1 133 | thresh=.6 134 | random=1 135 | -------------------------------------------------------------------------------- /cfg/tiny-yolo-voc-10c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | width=416 5 | height=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.001 15 | max_batches = 40200 16 | policy=steps 17 | steps=-1,100,20000,30000 18 | scales=.1,10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=1 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | filters=1024 95 | size=3 96 | stride=1 97 | pad=1 98 | activation=leaky 99 | 100 | ########### 101 | 102 | [convolutional] 103 | batch_normalize=1 104 | size=3 105 | stride=1 106 | pad=1 107 | filters=1024 108 | activation=leaky 109 | 110 | [convolutional] 111 | size=1 112 | stride=1 113 | pad=1 114 | filters=240 115 | activation=linear 116 | 117 | [region] 118 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 119 | bias_match=1 120 | classes=43 121 | coords=4 122 | num=5 123 | softmax=1 124 | jitter=.2 125 | rescore=1 126 | 127 | object_scale=5 128 | noobject_scale=1 129 | class_scale=1 130 | coord_scale=1 131 | 132 | absolute=1 133 | thresh = .6 134 | random=1 -------------------------------------------------------------------------------- /cfg/tiny-yolo-voc-7c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | height=416 5 | width=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.001 15 | max_batches = 45000 16 | policy=steps 17 | steps=100,25000,35000 18 | scales=10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=32 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=64 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=128 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [convolutional] 53 | batch_normalize=1 54 | filters=64 55 | size=1 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | batch_normalize=1 62 | filters=128 63 | size=3 64 | stride=1 65 | pad=1 66 | activation=leaky 67 | 68 | [maxpool] 69 | size=2 70 | stride=2 71 | 72 | [convolutional] 73 | batch_normalize=1 74 | filters=256 75 | size=3 76 | stride=1 77 | pad=1 78 | activation=leaky 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=128 83 | size=1 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [convolutional] 89 | batch_normalize=1 90 | filters=256 91 | size=3 92 | stride=1 93 | pad=1 94 | activation=leaky 95 | 96 | [maxpool] 97 | size=2 98 | stride=2 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | filters=512 103 | size=3 104 | stride=1 105 | pad=1 106 | activation=leaky 107 | 108 | [convolutional] 109 | batch_normalize=1 110 | filters=256 111 | size=1 112 | stride=1 113 | pad=1 114 | activation=leaky 115 | 116 | [convolutional] 117 | batch_normalize=1 118 | filters=512 119 | size=3 120 | stride=1 121 | pad=1 122 | activation=leaky 123 | 124 | [convolutional] 125 | batch_normalize=1 126 | filters=256 127 | size=1 128 | stride=1 129 | pad=1 130 | activation=leaky 131 | 132 | [convolutional] 133 | batch_normalize=1 134 | filters=512 135 | size=3 136 | stride=1 137 | pad=1 138 | activation=leaky 139 | 140 | [maxpool] 141 | size=2 142 | stride=2 143 | 144 | [convolutional] 145 | batch_normalize=1 146 | filters=1024 147 | size=3 148 | stride=1 149 | pad=1 150 | activation=leaky 151 | 152 | [convolutional] 153 | batch_normalize=1 154 | filters=512 155 | size=1 156 | stride=1 157 | pad=1 158 | activation=leaky 159 | 160 | [convolutional] 161 | batch_normalize=1 162 | filters=1024 163 | size=3 164 | stride=1 165 | pad=1 166 | activation=leaky 167 | 168 | [convolutional] 169 | batch_normalize=1 170 | filters=512 171 | size=1 172 | stride=1 173 | pad=1 174 | activation=leaky 175 | 176 | [convolutional] 177 | batch_normalize=1 178 | filters=1024 179 | size=3 180 | stride=1 181 | pad=1 182 | activation=leaky 183 | 184 | 185 | ####### 186 | 187 | [convolutional] 188 | batch_normalize=1 189 | size=3 190 | stride=1 191 | pad=1 192 | filters=1024 193 | activation=leaky 194 | 195 | [convolutional] 196 | batch_normalize=1 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [route] 204 | layers=-9 205 | 206 | [reorg] 207 | stride=2 208 | 209 | [route] 210 | layers=-1,-3 211 | 212 | [convolutional] 213 | batch_normalize=1 214 | size=3 215 | stride=1 216 | pad=1 217 | filters=1024 218 | activation=leaky 219 | 220 | [convolutional] 221 | size=1 222 | stride=1 223 | pad=1 224 | filters=60 225 | activation=linear 226 | 227 | [region] 228 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 229 | bias_match=1 230 | classes=7 231 | coords=4 232 | num=5 233 | softmax=1 234 | jitter=.2 235 | rescore=1 236 | 237 | object_scale=5 238 | noobject_scale=1 239 | class_scale=1 240 | coord_scale=1 241 | 242 | absolute=1 243 | thresh = .6 244 | random=0 245 | -------------------------------------------------------------------------------- /cfg/tiny-yolo-voc.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | width=416 5 | height=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.001 15 | max_batches = 40200 16 | policy=steps 17 | steps=-1,100,20000,30000 18 | scales=.1,10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=1 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | filters=1024 95 | size=3 96 | stride=1 97 | pad=1 98 | activation=leaky 99 | 100 | ########### 101 | 102 | [convolutional] 103 | batch_normalize=1 104 | size=3 105 | stride=1 106 | pad=1 107 | filters=1024 108 | activation=leaky 109 | 110 | [convolutional] 111 | size=1 112 | stride=1 113 | pad=1 114 | filters=125 115 | activation=linear 116 | 117 | [region] 118 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 119 | bias_match=1 120 | classes=20 121 | coords=4 122 | num=5 123 | softmax=1 124 | jitter=.2 125 | rescore=1 126 | 127 | object_scale=5 128 | noobject_scale=1 129 | class_scale=1 130 | coord_scale=1 131 | 132 | absolute=1 133 | thresh = .6 134 | random=1 135 | -------------------------------------------------------------------------------- /cfg/tiny-yolo-voc27.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | width=416 5 | height=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.001 15 | max_batches = 40100 16 | policy=steps 17 | steps=-1,100,20000,30000 18 | scales=.1,10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=1 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | filters=1024 95 | size=3 96 | stride=1 97 | pad=1 98 | activation=leaky 99 | 100 | ########### 101 | 102 | [convolutional] 103 | batch_normalize=1 104 | size=3 105 | stride=1 106 | pad=1 107 | filters=1024 108 | activation=leaky 109 | 110 | [convolutional] 111 | size=1 112 | stride=1 113 | pad=1 114 | filters=160 115 | activation=linear 116 | 117 | [region] 118 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 119 | bias_match=1 120 | classes=27 121 | coords=4 122 | num=5 123 | softmax=1 124 | jitter=.2 125 | rescore=1 126 | 127 | object_scale=5 128 | noobject_scale=1 129 | class_scale=1 130 | coord_scale=1 131 | 132 | absolute=1 133 | thresh = .5 134 | random=1 135 | -------------------------------------------------------------------------------- /cfg/tiny-yolo.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | # Training 3 | # batch=64 4 | # subdivisions=2 5 | # Testing 6 | batch=1 7 | subdivisions=1 8 | width=416 9 | height=416 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=16 28 | size=3 29 | stride=1 30 | pad=1 31 | activation=leaky 32 | 33 | [maxpool] 34 | size=2 35 | stride=2 36 | 37 | [convolutional] 38 | batch_normalize=1 39 | filters=32 40 | size=3 41 | stride=1 42 | pad=1 43 | activation=leaky 44 | 45 | [maxpool] 46 | size=2 47 | stride=2 48 | 49 | [convolutional] 50 | batch_normalize=1 51 | filters=64 52 | size=3 53 | stride=1 54 | pad=1 55 | activation=leaky 56 | 57 | [maxpool] 58 | size=2 59 | stride=2 60 | 61 | [convolutional] 62 | batch_normalize=1 63 | filters=128 64 | size=3 65 | stride=1 66 | pad=1 67 | activation=leaky 68 | 69 | [maxpool] 70 | size=2 71 | stride=2 72 | 73 | [convolutional] 74 | batch_normalize=1 75 | filters=256 76 | size=3 77 | stride=1 78 | pad=1 79 | activation=leaky 80 | 81 | [maxpool] 82 | size=2 83 | stride=2 84 | 85 | [convolutional] 86 | batch_normalize=1 87 | filters=512 88 | size=3 89 | stride=1 90 | pad=1 91 | activation=leaky 92 | 93 | [maxpool] 94 | size=2 95 | stride=1 96 | 97 | [convolutional] 98 | batch_normalize=1 99 | filters=1024 100 | size=3 101 | stride=1 102 | pad=1 103 | activation=leaky 104 | 105 | ########### 106 | 107 | [convolutional] 108 | batch_normalize=1 109 | size=3 110 | stride=1 111 | pad=1 112 | filters=512 113 | activation=leaky 114 | 115 | [convolutional] 116 | size=1 117 | stride=1 118 | pad=1 119 | filters=425 120 | activation=linear 121 | 122 | [region] 123 | anchors = 0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828 124 | bias_match=1 125 | classes=80 126 | coords=4 127 | num=5 128 | softmax=1 129 | jitter=.2 130 | rescore=0 131 | 132 | object_scale=5 133 | noobject_scale=1 134 | class_scale=1 135 | coord_scale=1 136 | 137 | absolute=1 138 | thresh = .6 139 | random=1 -------------------------------------------------------------------------------- /cfg/v1.1/person-bottle.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=2 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | saturation=.75 11 | exposure=.75 12 | hue = .1 13 | 14 | learning_rate=0.0005 15 | policy=steps 16 | steps=200,400,600,800,20000,30000 17 | scales=2.5,2,2,2,.1,.1 18 | max_batches = 40000 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=2 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | size=3 95 | stride=1 96 | pad=1 97 | filters=1024 98 | activation=leaky 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | size=3 103 | stride=1 104 | pad=1 105 | filters=256 106 | activation=leaky 107 | 108 | [select] 109 | old_output=1470 110 | keep=4,14/20 111 | bins=49 112 | output=588 113 | activation=linear 114 | 115 | [detection] 116 | classes=2 117 | coords=4 118 | rescore=1 119 | side=7 120 | num=2 121 | softmax=0 122 | sqrt=1 123 | jitter=.2 124 | 125 | object_scale=1 126 | noobject_scale=.5 127 | class_scale=1 128 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1.1/tiny-coco.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=2 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | hue = .1 11 | saturation=.75 12 | exposure=.75 13 | 14 | learning_rate=0.0005 15 | policy=steps 16 | steps=200,400,600,800,100000,150000 17 | scales=2.5,2,2,2,.1,.1 18 | max_batches = 200000 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=2 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | size=3 95 | stride=1 96 | pad=1 97 | filters=1024 98 | activation=leaky 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | size=3 103 | stride=1 104 | pad=1 105 | filters=256 106 | activation=leaky 107 | 108 | [connected] 109 | output= 4655 110 | activation=linear 111 | 112 | [detection] 113 | classes=80 114 | coords=4 115 | rescore=1 116 | side=7 117 | num=3 118 | softmax=0 119 | sqrt=1 120 | jitter=.2 121 | 122 | object_scale=1 123 | noobject_scale=.5 124 | class_scale=1 125 | coord_scale=5 126 | -------------------------------------------------------------------------------- /cfg/v1.1/tiny-yolo-4c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=2 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | saturation=.75 11 | exposure=.75 12 | hue = .1 13 | 14 | learning_rate=0.0005 15 | policy=steps 16 | steps=200,400,600,800,20000,30000 17 | scales=2.5,2,2,2,.1,.1 18 | max_batches = 40000 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=2 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | size=3 95 | stride=1 96 | pad=1 97 | filters=1024 98 | activation=leaky 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | size=3 103 | stride=1 104 | pad=1 105 | filters=256 106 | activation=leaky 107 | 108 | [select] 109 | old_output=1470 110 | keep=8,14,15,19/20 111 | bins=49 112 | output=686 113 | activation=linear 114 | 115 | [detection] 116 | classes=4 117 | coords=4 118 | rescore=1 119 | side=7 120 | num=2 121 | softmax=0 122 | sqrt=1 123 | jitter=.2 124 | 125 | object_scale=1 126 | noobject_scale=.5 127 | class_scale=1 128 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1.1/tiny-yolov1.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=2 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | saturation=.75 11 | exposure=.75 12 | hue = .1 13 | 14 | learning_rate=0.0005 15 | policy=steps 16 | steps=200,400,600,800,20000,30000 17 | scales=2.5,2,2,2,.1,.1 18 | max_batches = 40000 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=16 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=32 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=64 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [maxpool] 53 | size=2 54 | stride=2 55 | 56 | [convolutional] 57 | batch_normalize=1 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=256 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=512 83 | size=3 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [maxpool] 89 | size=2 90 | stride=2 91 | 92 | [convolutional] 93 | batch_normalize=1 94 | size=3 95 | stride=1 96 | pad=1 97 | filters=1024 98 | activation=leaky 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | size=3 103 | stride=1 104 | pad=1 105 | filters=256 106 | activation=leaky 107 | 108 | [connected] 109 | output= 1470 110 | activation=linear 111 | 112 | [detection] 113 | classes=20 114 | coords=4 115 | rescore=1 116 | side=7 117 | num=2 118 | softmax=0 119 | sqrt=1 120 | jitter=.2 121 | 122 | object_scale=1 123 | noobject_scale=.5 124 | class_scale=1 125 | coord_scale=5 126 | 127 | -------------------------------------------------------------------------------- /cfg/v1.1/yolo-coco.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=4 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | hue = .1 11 | saturation=.75 12 | exposure=.75 13 | 14 | learning_rate=0.0005 15 | policy=steps 16 | steps=200,400,600,800,100000,150000 17 | scales=2.5,2,2,2,.1,.1 18 | max_batches = 200000 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=64 23 | size=7 24 | stride=2 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=192 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=128 47 | size=1 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [convolutional] 53 | batch_normalize=1 54 | filters=256 55 | size=3 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | batch_normalize=1 62 | filters=256 63 | size=1 64 | stride=1 65 | pad=1 66 | activation=leaky 67 | 68 | [convolutional] 69 | batch_normalize=1 70 | filters=512 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=256 83 | size=1 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [convolutional] 89 | batch_normalize=1 90 | filters=512 91 | size=3 92 | stride=1 93 | pad=1 94 | activation=leaky 95 | 96 | [convolutional] 97 | batch_normalize=1 98 | filters=256 99 | size=1 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [convolutional] 105 | batch_normalize=1 106 | filters=512 107 | size=3 108 | stride=1 109 | pad=1 110 | activation=leaky 111 | 112 | [convolutional] 113 | batch_normalize=1 114 | filters=256 115 | size=1 116 | stride=1 117 | pad=1 118 | activation=leaky 119 | 120 | [convolutional] 121 | batch_normalize=1 122 | filters=512 123 | size=3 124 | stride=1 125 | pad=1 126 | activation=leaky 127 | 128 | [convolutional] 129 | batch_normalize=1 130 | filters=256 131 | size=1 132 | stride=1 133 | pad=1 134 | activation=leaky 135 | 136 | [convolutional] 137 | batch_normalize=1 138 | filters=512 139 | size=3 140 | stride=1 141 | pad=1 142 | activation=leaky 143 | 144 | [convolutional] 145 | batch_normalize=1 146 | filters=512 147 | size=1 148 | stride=1 149 | pad=1 150 | activation=leaky 151 | 152 | [convolutional] 153 | batch_normalize=1 154 | filters=1024 155 | size=3 156 | stride=1 157 | pad=1 158 | activation=leaky 159 | 160 | [maxpool] 161 | size=2 162 | stride=2 163 | 164 | [convolutional] 165 | batch_normalize=1 166 | filters=512 167 | size=1 168 | stride=1 169 | pad=1 170 | activation=leaky 171 | 172 | [convolutional] 173 | batch_normalize=1 174 | filters=1024 175 | size=3 176 | stride=1 177 | pad=1 178 | activation=leaky 179 | 180 | [convolutional] 181 | batch_normalize=1 182 | filters=512 183 | size=1 184 | stride=1 185 | pad=1 186 | activation=leaky 187 | 188 | [convolutional] 189 | batch_normalize=1 190 | filters=1024 191 | size=3 192 | stride=1 193 | pad=1 194 | activation=leaky 195 | 196 | ####### 197 | 198 | [convolutional] 199 | batch_normalize=1 200 | size=3 201 | stride=1 202 | pad=1 203 | filters=1024 204 | activation=leaky 205 | 206 | [convolutional] 207 | batch_normalize=1 208 | size=3 209 | stride=2 210 | pad=1 211 | filters=1024 212 | activation=leaky 213 | 214 | [convolutional] 215 | batch_normalize=1 216 | size=3 217 | stride=1 218 | pad=1 219 | filters=1024 220 | activation=leaky 221 | 222 | [convolutional] 223 | batch_normalize=1 224 | size=3 225 | stride=1 226 | pad=1 227 | filters=1024 228 | activation=leaky 229 | 230 | [local] 231 | size=3 232 | stride=1 233 | pad=1 234 | filters=256 235 | activation=leaky 236 | 237 | [connected] 238 | output= 4655 239 | activation=linear 240 | 241 | [detection] 242 | classes=80 243 | coords=4 244 | rescore=1 245 | side=7 246 | num=3 247 | softmax=0 248 | sqrt=1 249 | jitter=.2 250 | 251 | object_scale=1 252 | noobject_scale=.5 253 | class_scale=1 254 | coord_scale=5 255 | 256 | -------------------------------------------------------------------------------- /cfg/v1.1/yolov1.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=1 3 | subdivisions=1 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | saturation=1.5 10 | exposure=1.5 11 | hue=.1 12 | 13 | learning_rate=0.0005 14 | policy=steps 15 | steps=200,400,600,20000,30000 16 | scales=2.5,2,2,.1,.1 17 | max_batches = 40000 18 | 19 | [convolutional] 20 | batch_normalize=1 21 | filters=64 22 | size=7 23 | stride=2 24 | pad=1 25 | activation=leaky 26 | 27 | [maxpool] 28 | size=2 29 | stride=2 30 | 31 | [convolutional] 32 | batch_normalize=1 33 | filters=192 34 | size=3 35 | stride=1 36 | pad=1 37 | activation=leaky 38 | 39 | [maxpool] 40 | size=2 41 | stride=2 42 | 43 | [convolutional] 44 | batch_normalize=1 45 | filters=128 46 | size=1 47 | stride=1 48 | pad=1 49 | activation=leaky 50 | 51 | [convolutional] 52 | batch_normalize=1 53 | filters=256 54 | size=3 55 | stride=1 56 | pad=1 57 | activation=leaky 58 | 59 | [convolutional] 60 | batch_normalize=1 61 | filters=256 62 | size=1 63 | stride=1 64 | pad=1 65 | activation=leaky 66 | 67 | [convolutional] 68 | batch_normalize=1 69 | filters=512 70 | size=3 71 | stride=1 72 | pad=1 73 | activation=leaky 74 | 75 | [maxpool] 76 | size=2 77 | stride=2 78 | 79 | [convolutional] 80 | batch_normalize=1 81 | filters=256 82 | size=1 83 | stride=1 84 | pad=1 85 | activation=leaky 86 | 87 | [convolutional] 88 | batch_normalize=1 89 | filters=512 90 | size=3 91 | stride=1 92 | pad=1 93 | activation=leaky 94 | 95 | [convolutional] 96 | batch_normalize=1 97 | filters=256 98 | size=1 99 | stride=1 100 | pad=1 101 | activation=leaky 102 | 103 | [convolutional] 104 | batch_normalize=1 105 | filters=512 106 | size=3 107 | stride=1 108 | pad=1 109 | activation=leaky 110 | 111 | [convolutional] 112 | batch_normalize=1 113 | filters=256 114 | size=1 115 | stride=1 116 | pad=1 117 | activation=leaky 118 | 119 | [convolutional] 120 | batch_normalize=1 121 | filters=512 122 | size=3 123 | stride=1 124 | pad=1 125 | activation=leaky 126 | 127 | [convolutional] 128 | batch_normalize=1 129 | filters=256 130 | size=1 131 | stride=1 132 | pad=1 133 | activation=leaky 134 | 135 | [convolutional] 136 | batch_normalize=1 137 | filters=512 138 | size=3 139 | stride=1 140 | pad=1 141 | activation=leaky 142 | 143 | [convolutional] 144 | batch_normalize=1 145 | filters=512 146 | size=1 147 | stride=1 148 | pad=1 149 | activation=leaky 150 | 151 | [convolutional] 152 | batch_normalize=1 153 | filters=1024 154 | size=3 155 | stride=1 156 | pad=1 157 | activation=leaky 158 | 159 | [maxpool] 160 | size=2 161 | stride=2 162 | 163 | [convolutional] 164 | batch_normalize=1 165 | filters=512 166 | size=1 167 | stride=1 168 | pad=1 169 | activation=leaky 170 | 171 | [convolutional] 172 | batch_normalize=1 173 | filters=1024 174 | size=3 175 | stride=1 176 | pad=1 177 | activation=leaky 178 | 179 | [convolutional] 180 | batch_normalize=1 181 | filters=512 182 | size=1 183 | stride=1 184 | pad=1 185 | activation=leaky 186 | 187 | [convolutional] 188 | batch_normalize=1 189 | filters=1024 190 | size=3 191 | stride=1 192 | pad=1 193 | activation=leaky 194 | 195 | ####### 196 | 197 | [convolutional] 198 | batch_normalize=1 199 | size=3 200 | stride=1 201 | pad=1 202 | filters=1024 203 | activation=leaky 204 | 205 | [convolutional] 206 | batch_normalize=1 207 | size=3 208 | stride=2 209 | pad=1 210 | filters=1024 211 | activation=leaky 212 | 213 | [convolutional] 214 | batch_normalize=1 215 | size=3 216 | stride=1 217 | pad=1 218 | filters=1024 219 | activation=leaky 220 | 221 | [convolutional] 222 | batch_normalize=1 223 | size=3 224 | stride=1 225 | pad=1 226 | filters=1024 227 | activation=leaky 228 | 229 | [local] 230 | size=3 231 | stride=1 232 | pad=1 233 | filters=256 234 | activation=leaky 235 | 236 | [dropout] 237 | probability=.5 238 | 239 | [connected] 240 | output= 1715 241 | activation=linear 242 | 243 | [detection] 244 | classes=20 245 | coords=4 246 | rescore=1 247 | side=7 248 | num=3 249 | softmax=0 250 | sqrt=1 251 | jitter=.2 252 | 253 | object_scale=1 254 | noobject_scale=.5 255 | class_scale=1 256 | coord_scale=5 257 | 258 | -------------------------------------------------------------------------------- /cfg/v1/tiny-old.profile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/cfg/v1/tiny-old.profile -------------------------------------------------------------------------------- /cfg/v1/tiny.profile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/cfg/v1/tiny.profile -------------------------------------------------------------------------------- /cfg/v1/yolo-2c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.0001 11 | policy=steps 12 | steps=20,40,60,80,20000,30000 13 | scales=5,5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=16 26 | size=3 27 | stride=1 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=32 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=64 48 | size=3 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [maxpool] 54 | size=2 55 | stride=2 56 | 57 | [convolutional] 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | filters=256 70 | size=3 71 | stride=1 72 | pad=1 73 | activation=leaky 74 | 75 | [maxpool] 76 | size=2 77 | stride=2 78 | 79 | [convolutional] 80 | filters=512 81 | size=3 82 | stride=1 83 | pad=1 84 | activation=leaky 85 | 86 | [maxpool] 87 | size=2 88 | stride=2 89 | 90 | [convolutional] 91 | filters=1024 92 | size=3 93 | stride=1 94 | pad=1 95 | activation=leaky 96 | 97 | [convolutional] 98 | filters=1024 99 | size=3 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [convolutional] 105 | filters=1024 106 | size=3 107 | stride=1 108 | pad=1 109 | activation=leaky 110 | 111 | [connected] 112 | output=256 113 | activation=linear 114 | 115 | [connected] 116 | output=4096 117 | activation=leaky 118 | 119 | [dropout] 120 | probability=.5 121 | 122 | [select] 123 | old_output=1470 124 | keep=14,19/20 125 | bins=49 126 | output=588 127 | activation=linear 128 | 129 | [detection] 130 | classes=2 131 | coords=4 132 | rescore=1 133 | side=7 134 | num=2 135 | softmax=0 136 | sqrt=1 137 | jitter=.2 138 | object_scale=1 139 | noobject_scale=.5 140 | class_scale=1 141 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1/yolo-4c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.001 11 | policy=steps 12 | steps=200,400,600,20000,30000 13 | scales=2.5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=64 26 | size=7 27 | stride=2 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=192 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=128 48 | size=1 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [convolutional] 54 | filters=256 55 | size=3 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | filters=256 62 | size=1 63 | stride=1 64 | pad=1 65 | activation=leaky 66 | 67 | [convolutional] 68 | filters=512 69 | size=3 70 | stride=1 71 | pad=1 72 | activation=leaky 73 | 74 | [maxpool] 75 | size=2 76 | stride=2 77 | 78 | [convolutional] 79 | filters=256 80 | size=1 81 | stride=1 82 | pad=1 83 | activation=leaky 84 | 85 | [convolutional] 86 | filters=512 87 | size=3 88 | stride=1 89 | pad=1 90 | activation=leaky 91 | 92 | [convolutional] 93 | filters=256 94 | size=1 95 | stride=1 96 | pad=1 97 | activation=leaky 98 | 99 | [convolutional] 100 | filters=512 101 | size=3 102 | stride=1 103 | pad=1 104 | activation=leaky 105 | 106 | [convolutional] 107 | filters=256 108 | size=1 109 | stride=1 110 | pad=1 111 | activation=leaky 112 | 113 | [convolutional] 114 | filters=512 115 | size=3 116 | stride=1 117 | pad=1 118 | activation=leaky 119 | 120 | [convolutional] 121 | filters=256 122 | size=1 123 | stride=1 124 | pad=1 125 | activation=leaky 126 | 127 | [convolutional] 128 | filters=512 129 | size=3 130 | stride=1 131 | pad=1 132 | activation=leaky 133 | 134 | [convolutional] 135 | filters=512 136 | size=1 137 | stride=1 138 | pad=1 139 | activation=leaky 140 | 141 | [convolutional] 142 | filters=1024 143 | size=3 144 | stride=1 145 | pad=1 146 | activation=leaky 147 | 148 | [maxpool] 149 | size=2 150 | stride=2 151 | 152 | [convolutional] 153 | filters=512 154 | size=1 155 | stride=1 156 | pad=1 157 | activation=leaky 158 | 159 | [convolutional] 160 | filters=1024 161 | size=3 162 | stride=1 163 | pad=1 164 | activation=leaky 165 | 166 | [convolutional] 167 | filters=512 168 | size=1 169 | stride=1 170 | pad=1 171 | activation=leaky 172 | 173 | [convolutional] 174 | filters=1024 175 | size=3 176 | stride=1 177 | pad=1 178 | activation=leaky 179 | 180 | ####### 181 | 182 | [convolutional] 183 | size=3 184 | stride=1 185 | pad=1 186 | filters=1024 187 | activation=leaky 188 | 189 | [convolutional] 190 | size=3 191 | stride=2 192 | pad=1 193 | filters=1024 194 | activation=leaky 195 | 196 | [convolutional] 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [convolutional] 204 | size=3 205 | stride=1 206 | pad=1 207 | filters=1024 208 | activation=leaky 209 | 210 | [connected] 211 | output=4096 212 | activation=leaky 213 | 214 | [dropout] 215 | probability=.5 216 | 217 | [select] 218 | old_output=1470 219 | keep=8,14,15,19/20 220 | bins=49 221 | output=686 222 | activation=linear 223 | 224 | [detection] 225 | classes=4 226 | coords=4 227 | rescore=1 228 | side=7 229 | num=2 230 | softmax=0 231 | sqrt=1 232 | jitter=.2 233 | 234 | object_scale=1 235 | noobject_scale=.5 236 | class_scale=1 237 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1/yolo-full.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.001 11 | policy=steps 12 | steps=200,400,600,20000,30000 13 | scales=2.5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=64 26 | size=7 27 | stride=2 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=192 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=128 48 | size=1 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [convolutional] 54 | filters=256 55 | size=3 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | filters=256 62 | size=1 63 | stride=1 64 | pad=1 65 | activation=leaky 66 | 67 | [convolutional] 68 | filters=512 69 | size=3 70 | stride=1 71 | pad=1 72 | activation=leaky 73 | 74 | [maxpool] 75 | size=2 76 | stride=2 77 | 78 | [convolutional] 79 | filters=256 80 | size=1 81 | stride=1 82 | pad=1 83 | activation=leaky 84 | 85 | [convolutional] 86 | filters=512 87 | size=3 88 | stride=1 89 | pad=1 90 | activation=leaky 91 | 92 | [convolutional] 93 | filters=256 94 | size=1 95 | stride=1 96 | pad=1 97 | activation=leaky 98 | 99 | [convolutional] 100 | filters=512 101 | size=3 102 | stride=1 103 | pad=1 104 | activation=leaky 105 | 106 | [convolutional] 107 | filters=256 108 | size=1 109 | stride=1 110 | pad=1 111 | activation=leaky 112 | 113 | [convolutional] 114 | filters=512 115 | size=3 116 | stride=1 117 | pad=1 118 | activation=leaky 119 | 120 | [convolutional] 121 | filters=256 122 | size=1 123 | stride=1 124 | pad=1 125 | activation=leaky 126 | 127 | [convolutional] 128 | filters=512 129 | size=3 130 | stride=1 131 | pad=1 132 | activation=leaky 133 | 134 | [convolutional] 135 | filters=512 136 | size=1 137 | stride=1 138 | pad=1 139 | activation=leaky 140 | 141 | [convolutional] 142 | filters=1024 143 | size=3 144 | stride=1 145 | pad=1 146 | activation=leaky 147 | 148 | [maxpool] 149 | size=2 150 | stride=2 151 | 152 | [convolutional] 153 | filters=512 154 | size=1 155 | stride=1 156 | pad=1 157 | activation=leaky 158 | 159 | [convolutional] 160 | filters=1024 161 | size=3 162 | stride=1 163 | pad=1 164 | activation=leaky 165 | 166 | [convolutional] 167 | filters=512 168 | size=1 169 | stride=1 170 | pad=1 171 | activation=leaky 172 | 173 | [convolutional] 174 | filters=1024 175 | size=3 176 | stride=1 177 | pad=1 178 | activation=leaky 179 | 180 | ####### 181 | 182 | [convolutional] 183 | size=3 184 | stride=1 185 | pad=1 186 | filters=1024 187 | activation=leaky 188 | 189 | [convolutional] 190 | size=3 191 | stride=2 192 | pad=1 193 | filters=1024 194 | activation=leaky 195 | 196 | [convolutional] 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [convolutional] 204 | size=3 205 | stride=1 206 | pad=1 207 | filters=1024 208 | activation=leaky 209 | 210 | [connected] 211 | output=4096 212 | activation=leaky 213 | 214 | [dropout] 215 | probability=.5 216 | 217 | [connected] 218 | output= 1470 219 | activation=linear 220 | 221 | [detection] 222 | classes=20 223 | coords=4 224 | rescore=1 225 | side=7 226 | num=2 227 | softmax=0 228 | sqrt=1 229 | jitter=.2 230 | 231 | object_scale=1 232 | noobject_scale=.5 233 | class_scale=1 234 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1/yolo-small.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.001 11 | policy=steps 12 | steps=200,400,600,20000,30000 13 | scales=2.5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=64 26 | size=7 27 | stride=2 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=192 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=128 48 | size=1 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [convolutional] 54 | filters=256 55 | size=3 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | filters=256 62 | size=1 63 | stride=1 64 | pad=1 65 | activation=leaky 66 | 67 | [convolutional] 68 | filters=512 69 | size=3 70 | stride=1 71 | pad=1 72 | activation=leaky 73 | 74 | [maxpool] 75 | size=2 76 | stride=2 77 | 78 | [convolutional] 79 | filters=256 80 | size=1 81 | stride=1 82 | pad=1 83 | activation=leaky 84 | 85 | [convolutional] 86 | filters=512 87 | size=3 88 | stride=1 89 | pad=1 90 | activation=leaky 91 | 92 | [convolutional] 93 | filters=256 94 | size=1 95 | stride=1 96 | pad=1 97 | activation=leaky 98 | 99 | [convolutional] 100 | filters=512 101 | size=3 102 | stride=1 103 | pad=1 104 | activation=leaky 105 | 106 | [convolutional] 107 | filters=256 108 | size=1 109 | stride=1 110 | pad=1 111 | activation=leaky 112 | 113 | [convolutional] 114 | filters=512 115 | size=3 116 | stride=1 117 | pad=1 118 | activation=leaky 119 | 120 | [convolutional] 121 | filters=256 122 | size=1 123 | stride=1 124 | pad=1 125 | activation=leaky 126 | 127 | [convolutional] 128 | filters=512 129 | size=3 130 | stride=1 131 | pad=1 132 | activation=leaky 133 | 134 | [convolutional] 135 | filters=512 136 | size=1 137 | stride=1 138 | pad=1 139 | activation=leaky 140 | 141 | [convolutional] 142 | filters=1024 143 | size=3 144 | stride=1 145 | pad=1 146 | activation=leaky 147 | 148 | [maxpool] 149 | size=2 150 | stride=2 151 | 152 | [convolutional] 153 | filters=512 154 | size=1 155 | stride=1 156 | pad=1 157 | activation=leaky 158 | 159 | [convolutional] 160 | filters=1024 161 | size=3 162 | stride=1 163 | pad=1 164 | activation=leaky 165 | 166 | [convolutional] 167 | filters=512 168 | size=1 169 | stride=1 170 | pad=1 171 | activation=leaky 172 | 173 | [convolutional] 174 | filters=1024 175 | size=3 176 | stride=1 177 | pad=1 178 | activation=leaky 179 | 180 | ####### 181 | 182 | [convolutional] 183 | size=3 184 | stride=1 185 | pad=1 186 | filters=1024 187 | activation=leaky 188 | 189 | [convolutional] 190 | size=3 191 | stride=2 192 | pad=1 193 | filters=1024 194 | activation=leaky 195 | 196 | [convolutional] 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [convolutional] 204 | size=3 205 | stride=1 206 | pad=1 207 | filters=1024 208 | activation=leaky 209 | 210 | [connected] 211 | output=512 212 | activation=leaky 213 | 214 | [connected] 215 | output=4096 216 | activation=leaky 217 | 218 | [dropout] 219 | probability=.5 220 | 221 | [connected] 222 | output= 1470 223 | activation=linear 224 | 225 | [detection] 226 | classes=20 227 | coords=4 228 | rescore=1 229 | side=7 230 | num=2 231 | softmax=0 232 | sqrt=1 233 | jitter=.2 234 | 235 | object_scale=1 236 | noobject_scale=.5 237 | class_scale=1 238 | coord_scale=5 239 | 240 | -------------------------------------------------------------------------------- /cfg/v1/yolo-tiny-extract.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.0001 11 | policy=steps 12 | steps=20,40,60,80,20000,30000 13 | scales=5,5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [conv-extract] 25 | profile=cfg/v1/tiny.profile 26 | input=-1 27 | output=0 28 | filters=16 29 | size=3 30 | stride=1 31 | pad=1 32 | activation=leaky 33 | 34 | [maxpool] 35 | size=2 36 | stride=2 37 | 38 | [conv-extract] 39 | profile=cfg/v1/tiny.profile 40 | input=0 41 | output=1 42 | filters=32 43 | size=3 44 | stride=1 45 | pad=1 46 | activation=leaky 47 | 48 | [maxpool] 49 | size=2 50 | stride=2 51 | 52 | [conv-extract] 53 | profile=cfg/v1/tiny.profile 54 | input=1 55 | output=2 56 | filters=64 57 | size=3 58 | stride=1 59 | pad=1 60 | activation=leaky 61 | 62 | [maxpool] 63 | size=2 64 | stride=2 65 | 66 | [conv-extract] 67 | profile=cfg/v1/tiny.profile 68 | input=2 69 | output=3 70 | filters=128 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [conv-extract] 81 | profile=cfg/v1/tiny.profile 82 | input=3 83 | output=4 84 | filters=256 85 | size=3 86 | stride=1 87 | pad=1 88 | activation=leaky 89 | 90 | [maxpool] 91 | size=2 92 | stride=2 93 | 94 | [conv-extract] 95 | profile=cfg/v1/tiny.profile 96 | input=4 97 | output=5 98 | filters=512 99 | size=3 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [maxpool] 105 | size=2 106 | stride=2 107 | 108 | [conv-extract] 109 | profile=cfg/v1/tiny.profile 110 | input=5 111 | output=6 112 | filters=1024 113 | size=3 114 | stride=1 115 | pad=1 116 | activation=leaky 117 | 118 | [conv-extract] 119 | profile=cfg/v1/tiny.profile 120 | input=6 121 | output=7 122 | filters=1024 123 | size=3 124 | stride=1 125 | pad=1 126 | activation=leaky 127 | 128 | [conv-extract] 129 | profile=cfg/v1/tiny.profile 130 | input=7 131 | output=8 132 | filters=1024 133 | size=3 134 | stride=1 135 | pad=1 136 | activation=leaky 137 | 138 | [extract] 139 | profile=cfg/v1/tiny.profile 140 | input=8 141 | output=9 142 | old=7,7,1024,256 143 | activation=linear 144 | 145 | [extract] 146 | profile=cfg/v1/tiny.profile 147 | input=9 148 | output=10 149 | old=256,4096 150 | activation=leaky 151 | 152 | [dropout] 153 | probability=1. 154 | 155 | [select] 156 | input=cfg/v1/tiny.profile,10 157 | old_output=1470 158 | keep=8,14,15,19/20 159 | bins=49 160 | output=686 161 | activation=linear 162 | 163 | [detection] 164 | classes=4 165 | coords=4 166 | rescore=1 167 | side=7 168 | num=2 169 | softmax=0 170 | sqrt=1 171 | jitter=.2 172 | object_scale=1 173 | noobject_scale=.5 174 | class_scale=1 175 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1/yolo-tiny-extract_.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.0001 11 | policy=steps 12 | steps=20,40,60,80,20000,30000 13 | scales=5,5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [conv-extract] 25 | profile=cfg/v1/tiny-old.profile 26 | input=-1 27 | output=0 28 | filters=16 29 | size=3 30 | stride=1 31 | pad=1 32 | activation=leaky 33 | 34 | [maxpool] 35 | size=2 36 | stride=2 37 | 38 | [conv-extract] 39 | profile=cfg/v1/tiny-old.profile 40 | input=0 41 | output=1 42 | filters=32 43 | size=3 44 | stride=1 45 | pad=1 46 | activation=leaky 47 | 48 | [maxpool] 49 | size=2 50 | stride=2 51 | 52 | [conv-extract] 53 | profile=cfg/v1/tiny-old.profile 54 | input=1 55 | output=2 56 | filters=64 57 | size=3 58 | stride=1 59 | pad=1 60 | activation=leaky 61 | 62 | [maxpool] 63 | size=2 64 | stride=2 65 | 66 | [conv-extract] 67 | profile=cfg/v1/tiny-old.profile 68 | input=2 69 | output=3 70 | filters=128 71 | size=3 72 | stride=1 73 | pad=1 74 | activation=leaky 75 | 76 | [maxpool] 77 | size=2 78 | stride=2 79 | 80 | [conv-extract] 81 | profile=cfg/v1/tiny-old.profile 82 | input=3 83 | output=4 84 | filters=256 85 | size=3 86 | stride=1 87 | pad=1 88 | activation=leaky 89 | 90 | [maxpool] 91 | size=2 92 | stride=2 93 | 94 | [conv-extract] 95 | profile=cfg/v1/tiny-old.profile 96 | input=4 97 | output=5 98 | filters=512 99 | size=3 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [maxpool] 105 | size=2 106 | stride=2 107 | 108 | [conv-extract] 109 | profile=cfg/v1/tiny-old.profile 110 | input=5 111 | output=6 112 | filters=1024 113 | size=3 114 | stride=1 115 | pad=1 116 | activation=leaky 117 | 118 | [conv-extract] 119 | profile=cfg/v1/tiny-old.profile 120 | input=6 121 | output=7 122 | filters=1024 123 | size=3 124 | stride=1 125 | pad=1 126 | activation=leaky 127 | 128 | [conv-extract] 129 | profile=cfg/v1/tiny-old.profile 130 | input=7 131 | output=8 132 | filters=1024 133 | size=3 134 | stride=1 135 | pad=1 136 | activation=leaky 137 | 138 | [extract] 139 | profile=cfg/v1/tiny-old.profile 140 | input=8 141 | output=9 142 | old=7,7,1024,256 143 | activation=linear 144 | 145 | [extract] 146 | profile=cfg/v1/tiny-old.profile 147 | input=9 148 | output=10 149 | old=256,4096 150 | activation=leaky 151 | 152 | [dropout] 153 | probability=1. 154 | 155 | [select] 156 | input=cfg/v1/tiny-old.profile,10 157 | old_output=1470 158 | keep=8,14,15,19/20 159 | bins=49 160 | output=686 161 | activation=linear 162 | 163 | [detection] 164 | classes=4 165 | coords=4 166 | rescore=1 167 | side=7 168 | num=2 169 | softmax=0 170 | sqrt=1 171 | jitter=.2 172 | object_scale=2.5 173 | noobject_scale=2 174 | class_scale=2.5 175 | coord_scale=5 176 | 177 | save=11250 -------------------------------------------------------------------------------- /cfg/v1/yolo-tiny.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.0001 11 | policy=steps 12 | steps=20,40,60,80,20000,30000 13 | scales=5,5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=16 26 | size=3 27 | stride=1 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=32 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=64 48 | size=3 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [maxpool] 54 | size=2 55 | stride=2 56 | 57 | [convolutional] 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | filters=256 70 | size=3 71 | stride=1 72 | pad=1 73 | activation=leaky 74 | 75 | [maxpool] 76 | size=2 77 | stride=2 78 | 79 | [convolutional] 80 | filters=512 81 | size=3 82 | stride=1 83 | pad=1 84 | activation=leaky 85 | 86 | [maxpool] 87 | size=2 88 | stride=2 89 | 90 | [convolutional] 91 | filters=1024 92 | size=3 93 | stride=1 94 | pad=1 95 | activation=leaky 96 | 97 | [convolutional] 98 | filters=1024 99 | size=3 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [convolutional] 105 | filters=1024 106 | size=3 107 | stride=1 108 | pad=1 109 | activation=leaky 110 | 111 | [connected] 112 | output=256 113 | activation=linear 114 | 115 | [connected] 116 | output=4096 117 | activation=leaky 118 | 119 | [dropout] 120 | probability=.5 121 | 122 | [connected] 123 | output= 1470 124 | activation=linear 125 | 126 | [detection] 127 | classes=20 128 | coords=4 129 | rescore=1 130 | side=7 131 | num=2 132 | softmax=0 133 | sqrt=1 134 | jitter=.2 135 | object_scale=1 136 | noobject_scale=.5 137 | class_scale=1 138 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/v1/yolo-tiny4c.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=64 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.0001 11 | policy=steps 12 | steps=20,40,60,80,20000,30000 13 | scales=5,5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=16 26 | size=3 27 | stride=1 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=32 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=64 48 | size=3 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [maxpool] 54 | size=2 55 | stride=2 56 | 57 | [convolutional] 58 | filters=128 59 | size=3 60 | stride=1 61 | pad=1 62 | activation=leaky 63 | 64 | [maxpool] 65 | size=2 66 | stride=2 67 | 68 | [convolutional] 69 | filters=256 70 | size=3 71 | stride=1 72 | pad=1 73 | activation=leaky 74 | 75 | [maxpool] 76 | size=2 77 | stride=2 78 | 79 | [convolutional] 80 | filters=512 81 | size=3 82 | stride=1 83 | pad=1 84 | activation=leaky 85 | 86 | [maxpool] 87 | size=2 88 | stride=2 89 | 90 | [convolutional] 91 | filters=1024 92 | size=3 93 | stride=1 94 | pad=1 95 | activation=leaky 96 | 97 | [convolutional] 98 | filters=1024 99 | size=3 100 | stride=1 101 | pad=1 102 | activation=leaky 103 | 104 | [convolutional] 105 | filters=1024 106 | size=3 107 | stride=1 108 | pad=1 109 | activation=leaky 110 | 111 | [connected] 112 | output=256 113 | activation=linear 114 | 115 | [connected] 116 | output=4096 117 | activation=leaky 118 | 119 | [dropout] 120 | probability=.5 121 | 122 | [select] 123 | old_output=1470 124 | keep=8,14,15,19/20 125 | bins=49 126 | output=686 127 | activation=linear 128 | 129 | [detection] 130 | classes=4 131 | coords=4 132 | rescore=1 133 | side=7 134 | num=2 135 | softmax=0 136 | sqrt=1 137 | jitter=.2 138 | object_scale=1 139 | noobject_scale=.5 140 | class_scale=1 141 | coord_scale=5 -------------------------------------------------------------------------------- /cfg/yolo-voc.2.0.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | height=416 5 | width=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.0001 15 | max_batches = 45000 16 | policy=steps 17 | steps=100,25000,35000 18 | scales=10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=32 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=64 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=128 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [convolutional] 53 | batch_normalize=1 54 | filters=64 55 | size=1 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | batch_normalize=1 62 | filters=128 63 | size=3 64 | stride=1 65 | pad=1 66 | activation=leaky 67 | 68 | [maxpool] 69 | size=2 70 | stride=2 71 | 72 | [convolutional] 73 | batch_normalize=1 74 | filters=256 75 | size=3 76 | stride=1 77 | pad=1 78 | activation=leaky 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=128 83 | size=1 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [convolutional] 89 | batch_normalize=1 90 | filters=256 91 | size=3 92 | stride=1 93 | pad=1 94 | activation=leaky 95 | 96 | [maxpool] 97 | size=2 98 | stride=2 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | filters=512 103 | size=3 104 | stride=1 105 | pad=1 106 | activation=leaky 107 | 108 | [convolutional] 109 | batch_normalize=1 110 | filters=256 111 | size=1 112 | stride=1 113 | pad=1 114 | activation=leaky 115 | 116 | [convolutional] 117 | batch_normalize=1 118 | filters=512 119 | size=3 120 | stride=1 121 | pad=1 122 | activation=leaky 123 | 124 | [convolutional] 125 | batch_normalize=1 126 | filters=256 127 | size=1 128 | stride=1 129 | pad=1 130 | activation=leaky 131 | 132 | [convolutional] 133 | batch_normalize=1 134 | filters=512 135 | size=3 136 | stride=1 137 | pad=1 138 | activation=leaky 139 | 140 | [maxpool] 141 | size=2 142 | stride=2 143 | 144 | [convolutional] 145 | batch_normalize=1 146 | filters=1024 147 | size=3 148 | stride=1 149 | pad=1 150 | activation=leaky 151 | 152 | [convolutional] 153 | batch_normalize=1 154 | filters=512 155 | size=1 156 | stride=1 157 | pad=1 158 | activation=leaky 159 | 160 | [convolutional] 161 | batch_normalize=1 162 | filters=1024 163 | size=3 164 | stride=1 165 | pad=1 166 | activation=leaky 167 | 168 | [convolutional] 169 | batch_normalize=1 170 | filters=512 171 | size=1 172 | stride=1 173 | pad=1 174 | activation=leaky 175 | 176 | [convolutional] 177 | batch_normalize=1 178 | filters=1024 179 | size=3 180 | stride=1 181 | pad=1 182 | activation=leaky 183 | 184 | 185 | ####### 186 | 187 | [convolutional] 188 | batch_normalize=1 189 | size=3 190 | stride=1 191 | pad=1 192 | filters=1024 193 | activation=leaky 194 | 195 | [convolutional] 196 | batch_normalize=1 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [route] 204 | layers=-9 205 | 206 | [reorg] 207 | stride=2 208 | 209 | [route] 210 | layers=-1,-3 211 | 212 | [convolutional] 213 | batch_normalize=1 214 | size=3 215 | stride=1 216 | pad=1 217 | filters=1024 218 | activation=leaky 219 | 220 | [convolutional] 221 | size=1 222 | stride=1 223 | pad=1 224 | filters=75 225 | activation=linear 226 | 227 | [region] 228 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 229 | bias_match=1 230 | classes=10 231 | coords=4 232 | num=5 233 | softmax=1 234 | jitter=.2 235 | rescore=1 236 | 237 | object_scale=5 238 | noobject_scale=1 239 | class_scale=1 240 | coord_scale=1 241 | 242 | absolute=1 243 | thresh = .6 244 | random=0 245 | -------------------------------------------------------------------------------- /cfg/yolo-voc.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=8 4 | height=416 5 | width=416 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | angle=0 10 | saturation = 1.5 11 | exposure = 1.5 12 | hue=.1 13 | 14 | learning_rate=0.0001 15 | max_batches = 45000 16 | policy=steps 17 | steps=100,25000,35000 18 | scales=10,.1,.1 19 | 20 | [convolutional] 21 | batch_normalize=1 22 | filters=32 23 | size=3 24 | stride=1 25 | pad=1 26 | activation=leaky 27 | 28 | [maxpool] 29 | size=2 30 | stride=2 31 | 32 | [convolutional] 33 | batch_normalize=1 34 | filters=64 35 | size=3 36 | stride=1 37 | pad=1 38 | activation=leaky 39 | 40 | [maxpool] 41 | size=2 42 | stride=2 43 | 44 | [convolutional] 45 | batch_normalize=1 46 | filters=128 47 | size=3 48 | stride=1 49 | pad=1 50 | activation=leaky 51 | 52 | [convolutional] 53 | batch_normalize=1 54 | filters=64 55 | size=1 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | batch_normalize=1 62 | filters=128 63 | size=3 64 | stride=1 65 | pad=1 66 | activation=leaky 67 | 68 | [maxpool] 69 | size=2 70 | stride=2 71 | 72 | [convolutional] 73 | batch_normalize=1 74 | filters=256 75 | size=3 76 | stride=1 77 | pad=1 78 | activation=leaky 79 | 80 | [convolutional] 81 | batch_normalize=1 82 | filters=128 83 | size=1 84 | stride=1 85 | pad=1 86 | activation=leaky 87 | 88 | [convolutional] 89 | batch_normalize=1 90 | filters=256 91 | size=3 92 | stride=1 93 | pad=1 94 | activation=leaky 95 | 96 | [maxpool] 97 | size=2 98 | stride=2 99 | 100 | [convolutional] 101 | batch_normalize=1 102 | filters=512 103 | size=3 104 | stride=1 105 | pad=1 106 | activation=leaky 107 | 108 | [convolutional] 109 | batch_normalize=1 110 | filters=256 111 | size=1 112 | stride=1 113 | pad=1 114 | activation=leaky 115 | 116 | [convolutional] 117 | batch_normalize=1 118 | filters=512 119 | size=3 120 | stride=1 121 | pad=1 122 | activation=leaky 123 | 124 | [convolutional] 125 | batch_normalize=1 126 | filters=256 127 | size=1 128 | stride=1 129 | pad=1 130 | activation=leaky 131 | 132 | [convolutional] 133 | batch_normalize=1 134 | filters=512 135 | size=3 136 | stride=1 137 | pad=1 138 | activation=leaky 139 | 140 | [maxpool] 141 | size=2 142 | stride=2 143 | 144 | [convolutional] 145 | batch_normalize=1 146 | filters=1024 147 | size=3 148 | stride=1 149 | pad=1 150 | activation=leaky 151 | 152 | [convolutional] 153 | batch_normalize=1 154 | filters=512 155 | size=1 156 | stride=1 157 | pad=1 158 | activation=leaky 159 | 160 | [convolutional] 161 | batch_normalize=1 162 | filters=1024 163 | size=3 164 | stride=1 165 | pad=1 166 | activation=leaky 167 | 168 | [convolutional] 169 | batch_normalize=1 170 | filters=512 171 | size=1 172 | stride=1 173 | pad=1 174 | activation=leaky 175 | 176 | [convolutional] 177 | batch_normalize=1 178 | filters=1024 179 | size=3 180 | stride=1 181 | pad=1 182 | activation=leaky 183 | 184 | 185 | ####### 186 | 187 | [convolutional] 188 | batch_normalize=1 189 | size=3 190 | stride=1 191 | pad=1 192 | filters=1024 193 | activation=leaky 194 | 195 | [convolutional] 196 | batch_normalize=1 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [route] 204 | layers=-9 205 | 206 | [reorg] 207 | stride=2 208 | 209 | [route] 210 | layers=-1,-3 211 | 212 | [convolutional] 213 | batch_normalize=1 214 | size=3 215 | stride=1 216 | pad=1 217 | filters=1024 218 | activation=leaky 219 | 220 | [convolutional] 221 | size=1 222 | stride=1 223 | pad=1 224 | filters=125 225 | activation=linear 226 | 227 | [region] 228 | anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 229 | bias_match=1 230 | classes=20 231 | coords=4 232 | num=5 233 | softmax=1 234 | jitter=.2 235 | rescore=1 236 | 237 | object_scale=5 238 | noobject_scale=1 239 | class_scale=1 240 | coord_scale=1 241 | 242 | absolute=1 243 | thresh = .6 244 | random=0 245 | -------------------------------------------------------------------------------- /cfg/yolo.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | # Testing 3 | batch=1 4 | subdivisions=1 5 | # Training 6 | # batch=64 7 | # subdivisions=8 8 | width=416 9 | height=416 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 | [maxpool] 34 | size=2 35 | stride=2 36 | 37 | [convolutional] 38 | batch_normalize=1 39 | filters=64 40 | size=3 41 | stride=1 42 | pad=1 43 | activation=leaky 44 | 45 | [maxpool] 46 | size=2 47 | stride=2 48 | 49 | [convolutional] 50 | batch_normalize=1 51 | filters=128 52 | size=3 53 | stride=1 54 | pad=1 55 | activation=leaky 56 | 57 | [convolutional] 58 | batch_normalize=1 59 | filters=64 60 | size=1 61 | stride=1 62 | pad=1 63 | activation=leaky 64 | 65 | [convolutional] 66 | batch_normalize=1 67 | filters=128 68 | size=3 69 | stride=1 70 | pad=1 71 | activation=leaky 72 | 73 | [maxpool] 74 | size=2 75 | stride=2 76 | 77 | [convolutional] 78 | batch_normalize=1 79 | filters=256 80 | size=3 81 | stride=1 82 | pad=1 83 | activation=leaky 84 | 85 | [convolutional] 86 | batch_normalize=1 87 | filters=128 88 | size=1 89 | stride=1 90 | pad=1 91 | activation=leaky 92 | 93 | [convolutional] 94 | batch_normalize=1 95 | filters=256 96 | size=3 97 | stride=1 98 | pad=1 99 | activation=leaky 100 | 101 | [maxpool] 102 | size=2 103 | stride=2 104 | 105 | [convolutional] 106 | batch_normalize=1 107 | filters=512 108 | size=3 109 | stride=1 110 | pad=1 111 | activation=leaky 112 | 113 | [convolutional] 114 | batch_normalize=1 115 | filters=256 116 | size=1 117 | stride=1 118 | pad=1 119 | activation=leaky 120 | 121 | [convolutional] 122 | batch_normalize=1 123 | filters=512 124 | size=3 125 | stride=1 126 | pad=1 127 | activation=leaky 128 | 129 | [convolutional] 130 | batch_normalize=1 131 | filters=256 132 | size=1 133 | stride=1 134 | pad=1 135 | activation=leaky 136 | 137 | [convolutional] 138 | batch_normalize=1 139 | filters=512 140 | size=3 141 | stride=1 142 | pad=1 143 | activation=leaky 144 | 145 | [maxpool] 146 | size=2 147 | stride=2 148 | 149 | [convolutional] 150 | batch_normalize=1 151 | filters=1024 152 | size=3 153 | stride=1 154 | pad=1 155 | activation=leaky 156 | 157 | [convolutional] 158 | batch_normalize=1 159 | filters=512 160 | size=1 161 | stride=1 162 | pad=1 163 | activation=leaky 164 | 165 | [convolutional] 166 | batch_normalize=1 167 | filters=1024 168 | size=3 169 | stride=1 170 | pad=1 171 | activation=leaky 172 | 173 | [convolutional] 174 | batch_normalize=1 175 | filters=512 176 | size=1 177 | stride=1 178 | pad=1 179 | activation=leaky 180 | 181 | [convolutional] 182 | batch_normalize=1 183 | filters=1024 184 | size=3 185 | stride=1 186 | pad=1 187 | activation=leaky 188 | 189 | 190 | ####### 191 | 192 | [convolutional] 193 | batch_normalize=1 194 | size=3 195 | stride=1 196 | pad=1 197 | filters=1024 198 | activation=leaky 199 | 200 | [convolutional] 201 | batch_normalize=1 202 | size=3 203 | stride=1 204 | pad=1 205 | filters=1024 206 | activation=leaky 207 | 208 | [route] 209 | layers=-9 210 | 211 | [convolutional] 212 | batch_normalize=1 213 | size=1 214 | stride=1 215 | pad=1 216 | filters=64 217 | activation=leaky 218 | 219 | [reorg] 220 | stride=2 221 | 222 | [route] 223 | layers=-1,-4 224 | 225 | [convolutional] 226 | batch_normalize=1 227 | size=3 228 | stride=1 229 | pad=1 230 | filters=1024 231 | activation=leaky 232 | 233 | [convolutional] 234 | size=1 235 | stride=1 236 | pad=1 237 | filters=425 238 | activation=linear 239 | 240 | 241 | [region] 242 | anchors = 0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828 243 | bias_match=1 244 | classes=80 245 | coords=4 246 | num=5 247 | softmax=1 248 | jitter=.3 249 | rescore=1 250 | 251 | object_scale=5 252 | noobject_scale=1 253 | class_scale=1 254 | coord_scale=1 255 | 256 | absolute=1 257 | thresh = .6 258 | random=1 -------------------------------------------------------------------------------- /cfg/yolo9000.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | # Testing 3 | batch=1 4 | subdivisions=1 5 | # Training 6 | # batch=64 7 | # subdivisions=8 8 | batch=1 9 | subdivisions=1 10 | height=544 11 | width=544 12 | channels=3 13 | momentum=0.9 14 | decay=0.0005 15 | 16 | learning_rate=0.001 17 | burn_in=1000 18 | max_batches = 500200 19 | policy=steps 20 | steps=400000,450000 21 | scales=.1,.1 22 | 23 | hue=.1 24 | saturation=.75 25 | exposure=.75 26 | 27 | [convolutional] 28 | batch_normalize=1 29 | filters=32 30 | size=3 31 | stride=1 32 | pad=1 33 | activation=leaky 34 | 35 | [maxpool] 36 | size=2 37 | stride=2 38 | 39 | [convolutional] 40 | batch_normalize=1 41 | filters=64 42 | size=3 43 | stride=1 44 | pad=1 45 | activation=leaky 46 | 47 | [maxpool] 48 | size=2 49 | stride=2 50 | 51 | [convolutional] 52 | batch_normalize=1 53 | filters=128 54 | size=3 55 | stride=1 56 | pad=1 57 | activation=leaky 58 | 59 | [convolutional] 60 | batch_normalize=1 61 | filters=64 62 | size=1 63 | stride=1 64 | pad=1 65 | activation=leaky 66 | 67 | [convolutional] 68 | batch_normalize=1 69 | filters=128 70 | size=3 71 | stride=1 72 | pad=1 73 | activation=leaky 74 | 75 | [maxpool] 76 | size=2 77 | stride=2 78 | 79 | [convolutional] 80 | batch_normalize=1 81 | filters=256 82 | size=3 83 | stride=1 84 | pad=1 85 | activation=leaky 86 | 87 | [convolutional] 88 | batch_normalize=1 89 | filters=128 90 | size=1 91 | stride=1 92 | pad=1 93 | activation=leaky 94 | 95 | [convolutional] 96 | batch_normalize=1 97 | filters=256 98 | size=3 99 | stride=1 100 | pad=1 101 | activation=leaky 102 | 103 | [maxpool] 104 | size=2 105 | stride=2 106 | 107 | [convolutional] 108 | batch_normalize=1 109 | filters=512 110 | size=3 111 | stride=1 112 | pad=1 113 | activation=leaky 114 | 115 | [convolutional] 116 | batch_normalize=1 117 | filters=256 118 | size=1 119 | stride=1 120 | pad=1 121 | activation=leaky 122 | 123 | [convolutional] 124 | batch_normalize=1 125 | filters=512 126 | size=3 127 | stride=1 128 | pad=1 129 | activation=leaky 130 | 131 | [convolutional] 132 | batch_normalize=1 133 | filters=256 134 | size=1 135 | stride=1 136 | pad=1 137 | activation=leaky 138 | 139 | [convolutional] 140 | batch_normalize=1 141 | filters=512 142 | size=3 143 | stride=1 144 | pad=1 145 | activation=leaky 146 | 147 | [maxpool] 148 | size=2 149 | stride=2 150 | 151 | [convolutional] 152 | batch_normalize=1 153 | filters=1024 154 | size=3 155 | stride=1 156 | pad=1 157 | activation=leaky 158 | 159 | [convolutional] 160 | batch_normalize=1 161 | filters=512 162 | size=1 163 | stride=1 164 | pad=1 165 | activation=leaky 166 | 167 | [convolutional] 168 | batch_normalize=1 169 | filters=1024 170 | size=3 171 | stride=1 172 | pad=1 173 | activation=leaky 174 | 175 | [convolutional] 176 | batch_normalize=1 177 | filters=512 178 | size=1 179 | stride=1 180 | pad=1 181 | activation=leaky 182 | 183 | [convolutional] 184 | batch_normalize=1 185 | filters=1024 186 | size=3 187 | stride=1 188 | pad=1 189 | activation=leaky 190 | 191 | [convolutional] 192 | filters=28269 193 | size=1 194 | stride=1 195 | pad=1 196 | activation=linear 197 | 198 | [region] 199 | anchors = 0.77871, 1.14074, 3.00525, 4.31277, 9.22725, 9.61974 200 | bias_match=1 201 | classes=9418 202 | coords=4 203 | num=3 204 | softmax=1 205 | jitter=.2 206 | rescore=1 207 | 208 | object_scale=5 209 | noobject_scale=1 210 | class_scale=1 211 | coord_scale=1 212 | 213 | thresh = .6 214 | absolute=1 215 | random=1 216 | 217 | tree=data/9k.tree 218 | map = data/coco9k.map 219 | -------------------------------------------------------------------------------- /cfg/yolo_2class_box11.cfg: -------------------------------------------------------------------------------- 1 | [net] 2 | batch=64 3 | subdivisions=2 4 | height=448 5 | width=448 6 | channels=3 7 | momentum=0.9 8 | decay=0.0005 9 | 10 | learning_rate=0.0005 11 | policy=steps 12 | steps=200,400,600,20000,30000 13 | scales=2.5,2,2,.1,.1 14 | max_batches = 40000 15 | 16 | [crop] 17 | crop_width=448 18 | crop_height=448 19 | flip=0 20 | angle=0 21 | saturation = 1.5 22 | exposure = 1.5 23 | 24 | [convolutional] 25 | filters=64 26 | size=7 27 | stride=2 28 | pad=1 29 | activation=leaky 30 | 31 | [maxpool] 32 | size=2 33 | stride=2 34 | 35 | [convolutional] 36 | filters=192 37 | size=3 38 | stride=1 39 | pad=1 40 | activation=leaky 41 | 42 | [maxpool] 43 | size=2 44 | stride=2 45 | 46 | [convolutional] 47 | filters=128 48 | size=1 49 | stride=1 50 | pad=1 51 | activation=leaky 52 | 53 | [convolutional] 54 | filters=256 55 | size=3 56 | stride=1 57 | pad=1 58 | activation=leaky 59 | 60 | [convolutional] 61 | filters=256 62 | size=1 63 | stride=1 64 | pad=1 65 | activation=leaky 66 | 67 | [convolutional] 68 | filters=512 69 | size=3 70 | stride=1 71 | pad=1 72 | activation=leaky 73 | 74 | [maxpool] 75 | size=2 76 | stride=2 77 | 78 | [convolutional] 79 | filters=256 80 | size=1 81 | stride=1 82 | pad=1 83 | activation=leaky 84 | 85 | [convolutional] 86 | filters=512 87 | size=3 88 | stride=1 89 | pad=1 90 | activation=leaky 91 | 92 | [convolutional] 93 | filters=256 94 | size=1 95 | stride=1 96 | pad=1 97 | activation=leaky 98 | 99 | [convolutional] 100 | filters=512 101 | size=3 102 | stride=1 103 | pad=1 104 | activation=leaky 105 | 106 | [convolutional] 107 | filters=256 108 | size=1 109 | stride=1 110 | pad=1 111 | activation=leaky 112 | 113 | [convolutional] 114 | filters=512 115 | size=3 116 | stride=1 117 | pad=1 118 | activation=leaky 119 | 120 | [convolutional] 121 | filters=256 122 | size=1 123 | stride=1 124 | pad=1 125 | activation=leaky 126 | 127 | [convolutional] 128 | filters=512 129 | size=3 130 | stride=1 131 | pad=1 132 | activation=leaky 133 | 134 | [convolutional] 135 | filters=512 136 | size=1 137 | stride=1 138 | pad=1 139 | activation=leaky 140 | 141 | [convolutional] 142 | filters=1024 143 | size=3 144 | stride=1 145 | pad=1 146 | activation=leaky 147 | 148 | [maxpool] 149 | size=2 150 | stride=2 151 | 152 | [convolutional] 153 | filters=512 154 | size=1 155 | stride=1 156 | pad=1 157 | activation=leaky 158 | 159 | [convolutional] 160 | filters=1024 161 | size=3 162 | stride=1 163 | pad=1 164 | activation=leaky 165 | 166 | [convolutional] 167 | filters=512 168 | size=1 169 | stride=1 170 | pad=1 171 | activation=leaky 172 | 173 | [convolutional] 174 | filters=1024 175 | size=3 176 | stride=1 177 | pad=1 178 | activation=leaky 179 | 180 | ####### 181 | 182 | [convolutional] 183 | size=3 184 | stride=1 185 | pad=1 186 | filters=1024 187 | activation=leaky 188 | 189 | [convolutional] 190 | size=3 191 | stride=2 192 | pad=1 193 | filters=1024 194 | activation=leaky 195 | 196 | [convolutional] 197 | size=3 198 | stride=1 199 | pad=1 200 | filters=1024 201 | activation=leaky 202 | 203 | [convolutional] 204 | size=3 205 | stride=1 206 | pad=1 207 | filters=1024 208 | activation=leaky 209 | 210 | [connected] 211 | output=4096 212 | activation=leaky 213 | 214 | [dropout] 215 | probability=.5 216 | 217 | [connected] 218 | output= 1452 219 | activation=linear 220 | 221 | [detection] 222 | classes=2 223 | coords=4 224 | rescore=1 225 | side=11 226 | num=2 227 | softmax=0 228 | sqrt=1 229 | jitter=.2 230 | 231 | object_scale=1 232 | noobject_scale=.5 233 | class_scale=1 234 | coord_scale=5 235 | 236 | -------------------------------------------------------------------------------- /cvm1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from PySide.QtCore import * 4 | from PySide.QtGui import * 5 | import cv2 6 | import sys 7 | 8 | CASCADE_FILE = 'haarcascade_frontalface_default.xml' 9 | 10 | class MainWindow(QWidget): 11 | 12 | frame_changed = Signal(object) 13 | 14 | def __init__(self): 15 | QWidget.__init__(self) 16 | self.video_width = 320 17 | self.video_height = 240 18 | self.face_rect = None 19 | 20 | self.face_detector = FaceDetector() 21 | self.frame_changed.connect(self.face_detector.detect) 22 | self.face_detector.on_detect.connect(self.update_face_rect) 23 | 24 | self.fps_counter = FpsCounter() 25 | self.fps_counter.on_count.connect(self.update_status) 26 | self.frame_changed.connect(self.fps_counter.count_frame) 27 | 28 | self.setup_ui() 29 | self.face_detector.start() 30 | self.fps_counter.start() 31 | 32 | def closeEvent(self, event): 33 | self.face_detector.terminate() 34 | self.fps_counter.terminate() 35 | event.accept() 36 | 37 | def setup_ui(self): 38 | self.image_label = QLabel() 39 | self.setFixedWidth(self.video_width) 40 | self.setFixedHeight(self.video_height) 41 | 42 | self.blank = QPixmap(self.video_width, self.video_height) 43 | self.blank.fill(QColor(0,0,0)) 44 | self.image_label.setPixmap(self.blank) 45 | 46 | self.status_label = QLabel("Initializing camera...") 47 | 48 | self.detect_button = QPushButton("Detect Face") 49 | self.detect_button.setCheckable(True) 50 | self.detect_button.toggled.connect(self.face_detector.activate) 51 | 52 | self.quit_button = QPushButton("Quit") 53 | self.quit_button.clicked.connect(self.close) 54 | 55 | buttons_layout = QHBoxLayout() 56 | buttons_layout.addWidget(self.status_label) 57 | buttons_layout.addStretch() 58 | buttons_layout.addWidget(self.detect_button) 59 | buttons_layout.addWidget(self.quit_button) 60 | 61 | main_layout = QVBoxLayout() 62 | main_layout.addWidget(self.image_label) 63 | main_layout.addLayout(buttons_layout) 64 | 65 | self.setWindowTitle("Face Detection") 66 | self.setLayout(main_layout) 67 | self.show() 68 | 69 | self.timer = QTimer() 70 | self.timer.setSingleShot(True) 71 | self.timer.timeout.connect(self.setup_camera) 72 | self.timer.start(10) 73 | 74 | def setup_camera(self): 75 | self.capture = cv2.VideoCapture(0) 76 | self.capture.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, self.video_width) 77 | self.capture.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, self.video_height) 78 | 79 | self.timer = QTimer() 80 | self.timer.timeout.connect(self.display_camera_stream) 81 | self.timer.start(50) 82 | 83 | def display_camera_stream(self): 84 | val, frame = self.capture.read() 85 | 86 | frame = cv2.flip(frame, 1) 87 | self.frame_changed.emit(frame) 88 | 89 | frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 90 | if self.face_rect is not None: 91 | x, y, w, h = self.face_rect 92 | cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2) 93 | 94 | image = QImage(frame, frame.shape[1], frame.shape[0], frame.strides[0], QImage.Format_RGB888) 95 | self.image_label.setPixmap(QPixmap.fromImage(image)) 96 | 97 | @Slot(object) 98 | def update_face_rect(self, rect): 99 | self.face_rect = rect 100 | 101 | @Slot(str) 102 | def update_status(self, msg): 103 | self.status_label.setText(msg) 104 | 105 | class FaceDetector(QThread): 106 | 107 | on_detect = Signal(object) 108 | 109 | def __init__(self): 110 | QThread.__init__(self) 111 | self.stopped = True 112 | self.processing = False 113 | self.face_cascade = cv2.CascadeClassifier(CASCADE_FILE) 114 | 115 | @Slot() 116 | def activate(self, val): 117 | self.stopped = not val 118 | self.on_detect.emit(None) 119 | 120 | @Slot(object) 121 | def detect(self, frame): 122 | if not self.stopped and not self.processing: 123 | self.processing = True 124 | gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 125 | faces = self.face_cascade.detectMultiScale(gray, 1.1, 2) 126 | self.on_detect.emit(faces[0] if len(faces) else None) 127 | self.processing = False 128 | 129 | class FpsCounter(QThread): 130 | 131 | on_count = Signal(str) 132 | 133 | def __init__(self): 134 | QThread.__init__(self) 135 | self.num_frames = 0 136 | self.mutex = QMutex() 137 | self.timer = QTimer() 138 | self.timer.timeout.connect(self.timeout) 139 | self.timer.start(1000) 140 | 141 | @Slot() 142 | def count_frame(self): 143 | self.mutex.lock() 144 | self.num_frames += 1 145 | self.mutex.unlock() 146 | 147 | @Slot() 148 | def timeout(self): 149 | self.mutex.lock() 150 | self.on_count.emit("Camera: %d fps" % self.num_frames) 151 | self.num_frames = 0 152 | self.mutex.unlock() 153 | 154 | if __name__ == "__main__": 155 | app = QApplication(sys.argv) 156 | win = MainWindow() 157 | app.exec_() -------------------------------------------------------------------------------- /darkflow/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/.DS_Store -------------------------------------------------------------------------------- /darkflow/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/__init__.py -------------------------------------------------------------------------------- /darkflow/cli.py: -------------------------------------------------------------------------------- 1 | from .defaults import argHandler #Import the default arguments 2 | import os 3 | from .net.build import TFNet 4 | 5 | def cliHandler(args): 6 | FLAGS = argHandler() 7 | FLAGS.setDefaults() 8 | FLAGS.parseArgs(args) 9 | 10 | # make sure all necessary dirs exist 11 | def _get_dir(dirs): 12 | for d in dirs: 13 | this = os.path.abspath(os.path.join(os.path.curdir, d)) 14 | if not os.path.exists(this): os.makedirs(this) 15 | 16 | requiredDirectories = [FLAGS.imgdir, FLAGS.binary, FLAGS.backup, os.path.join(FLAGS.imgdir,'out')] 17 | if FLAGS.summary: 18 | requiredDirectories.append(FLAGS.summary) 19 | 20 | _get_dir(requiredDirectories) 21 | 22 | # fix FLAGS.load to appropriate type 23 | try: FLAGS.load = int(FLAGS.load) 24 | except: pass 25 | 26 | tfnet = TFNet(FLAGS) 27 | 28 | if FLAGS.demo: 29 | tfnet.camera() 30 | exit('Demo stopped, exit.') 31 | 32 | if FLAGS.train: 33 | print('Enter training ...'); tfnet.train() 34 | if not FLAGS.savepb: 35 | exit('Training finished, exit.') 36 | 37 | if FLAGS.savepb: 38 | print('Rebuild a constant version ...') 39 | tfnet.savepb(); exit('Done') 40 | 41 | tfnet.predict() 42 | -------------------------------------------------------------------------------- /darkflow/cython_utils/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/cython_utils/.DS_Store -------------------------------------------------------------------------------- /darkflow/cython_utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/cython_utils/__init__.py -------------------------------------------------------------------------------- /darkflow/cython_utils/cy_yolo2_findboxes.cpython-35m-darwin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/cython_utils/cy_yolo2_findboxes.cpython-35m-darwin.so -------------------------------------------------------------------------------- /darkflow/cython_utils/cy_yolo2_findboxes.pyx: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | cimport numpy as np 3 | cimport cython 4 | ctypedef np.float_t DTYPE_t 5 | from libc.math cimport exp 6 | from ..utils.box import BoundBox 7 | from nms cimport NMS 8 | 9 | #expit 10 | @cython.boundscheck(False) # turn off bounds-checking for entire function 11 | @cython.wraparound(False) # turn off negative index wrapping for entire function 12 | @cython.cdivision(True) 13 | cdef float expit_c(float x): 14 | cdef float y= 1/(1+exp(-x)) 15 | return y 16 | 17 | #MAX 18 | @cython.boundscheck(False) # turn off bounds-checking for entire function 19 | @cython.wraparound(False) # turn off negative index wrapping for entire function 20 | @cython.cdivision(True) 21 | cdef float max_c(float a, float b): 22 | if(a>b): 23 | return a 24 | return b 25 | 26 | """ 27 | #SOFTMAX! 28 | @cython.cdivision(True) 29 | @cython.boundscheck(False) # turn off bounds-checking for entire function 30 | @cython.wraparound(False) # turn off negative index wrapping for entire function 31 | cdef void _softmax_c(float* x, int classes): 32 | cdef: 33 | float sum = 0 34 | np.intp_t k 35 | float arr_max = 0 36 | for k in range(classes): 37 | arr_max = max(arr_max,x[k]) 38 | 39 | for k in range(classes): 40 | x[k] = exp(x[k]-arr_max) 41 | sum += x[k] 42 | 43 | for k in range(classes): 44 | x[k] = x[k]/sum 45 | """ 46 | 47 | 48 | 49 | #BOX CONSTRUCTOR 50 | @cython.cdivision(True) 51 | @cython.boundscheck(False) # turn off bounds-checking for entire function 52 | @cython.wraparound(False) # turn off negative index wrapping for entire function 53 | def box_constructor(meta,np.ndarray[float,ndim=3] net_out_in): 54 | cdef: 55 | np.intp_t H, W, _, C, B, row, col, box_loop, class_loop 56 | np.intp_t row1, col1, box_loop1,index,index2 57 | float threshold = meta['thresh'] 58 | float tempc,arr_max=0,sum=0 59 | double[:] anchors = np.asarray(meta['anchors']) 60 | list boxes = list() 61 | 62 | H, W, _ = meta['out_size'] 63 | C = meta['classes'] 64 | B = meta['num'] 65 | 66 | cdef: 67 | float[:, :, :, ::1] net_out = net_out_in.reshape([H, W, B, net_out_in.shape[2]/B]) 68 | float[:, :, :, ::1] Classes = net_out[:, :, :, 5:] 69 | float[:, :, :, ::1] Bbox_pred = net_out[:, :, :, :5] 70 | float[:, :, :, ::1] probs = np.zeros((H, W, B, C), dtype=np.float32) 71 | 72 | for row in range(H): 73 | for col in range(W): 74 | for box_loop in range(B): 75 | arr_max=0 76 | sum=0; 77 | Bbox_pred[row, col, box_loop, 4] = expit_c(Bbox_pred[row, col, box_loop, 4]) 78 | Bbox_pred[row, col, box_loop, 0] = (col + expit_c(Bbox_pred[row, col, box_loop, 0])) / W 79 | Bbox_pred[row, col, box_loop, 1] = (row + expit_c(Bbox_pred[row, col, box_loop, 1])) / H 80 | Bbox_pred[row, col, box_loop, 2] = exp(Bbox_pred[row, col, box_loop, 2]) * anchors[2 * box_loop + 0] / W 81 | Bbox_pred[row, col, box_loop, 3] = exp(Bbox_pred[row, col, box_loop, 3]) * anchors[2 * box_loop + 1] / H 82 | #SOFTMAX BLOCK, no more pointer juggling 83 | for class_loop in range(C): 84 | arr_max=max_c(arr_max,Classes[row,col,box_loop,class_loop]) 85 | 86 | for class_loop in range(C): 87 | Classes[row,col,box_loop,class_loop]=exp(Classes[row,col,box_loop,class_loop]-arr_max) 88 | sum+=Classes[row,col,box_loop,class_loop] 89 | 90 | for class_loop in range(C): 91 | tempc = Classes[row, col, box_loop, class_loop] * Bbox_pred[row, col, box_loop, 4]/sum 92 | if(tempc > threshold): 93 | probs[row, col, box_loop, class_loop] = tempc 94 | 95 | 96 | #NMS 97 | return NMS(np.ascontiguousarray(probs).reshape(H*W*B,C), np.ascontiguousarray(Bbox_pred).reshape(H*B*W,5)) 98 | -------------------------------------------------------------------------------- /darkflow/cython_utils/cy_yolo_findboxes.cpython-35m-darwin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/cython_utils/cy_yolo_findboxes.cpython-35m-darwin.so -------------------------------------------------------------------------------- /darkflow/cython_utils/cy_yolo_findboxes.pyx: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | cimport numpy as np 3 | cimport cython 4 | ctypedef np.float_t DTYPE_t 5 | from libc.math cimport exp 6 | from ..utils.box import BoundBox 7 | from nms cimport NMS 8 | 9 | 10 | 11 | @cython.cdivision(True) 12 | @cython.boundscheck(False) # turn off bounds-checking for entire function 13 | @cython.wraparound(False) # turn off negative index wrapping for entire function 14 | def yolo_box_constructor(meta,np.ndarray[float] net_out, float threshold): 15 | 16 | cdef: 17 | float sqrt 18 | int C,B,S 19 | int SS,prob_size,conf_size 20 | int grid, b 21 | int class_loop 22 | 23 | 24 | sqrt = meta['sqrt'] + 1 25 | C, B, S = meta['classes'], meta['num'], meta['side'] 26 | boxes = [] 27 | SS = S * S # number of grid cells 28 | prob_size = SS * C # class probabilities 29 | conf_size = SS * B # confidences for each grid cell 30 | 31 | cdef: 32 | float [:,::1] probs = np.ascontiguousarray(net_out[0 : prob_size]).reshape([SS,C]) 33 | float [:,::1] confs = np.ascontiguousarray(net_out[prob_size : (prob_size + conf_size)]).reshape([SS,B]) 34 | float [: , : ,::1] coords = np.ascontiguousarray(net_out[(prob_size + conf_size) : ]).reshape([SS, B, 4]) 35 | float [:,:,::1] final_probs = np.zeros([SS,B,C],dtype=np.float32) 36 | 37 | 38 | for grid in range(SS): 39 | for b in range(B): 40 | coords[grid, b, 0] = (coords[grid, b, 0] + grid % S) / S 41 | coords[grid, b, 1] = (coords[grid, b, 1] + grid // S) / S 42 | coords[grid, b, 2] = coords[grid, b, 2] ** sqrt 43 | coords[grid, b, 3] = coords[grid, b, 3] ** sqrt 44 | for class_loop in range(C): 45 | probs[grid, class_loop] = probs[grid, class_loop] * confs[grid, b] 46 | #print("PROBS",probs[grid,class_loop]) 47 | if(probs[grid,class_loop] > threshold ): 48 | final_probs[grid, b, class_loop] = probs[grid, class_loop] 49 | 50 | 51 | return NMS(np.ascontiguousarray(final_probs).reshape(SS*B, C) , np.ascontiguousarray(coords).reshape(SS*B, 4)) 52 | -------------------------------------------------------------------------------- /darkflow/cython_utils/nms.cpython-35m-darwin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/cython_utils/nms.cpython-35m-darwin.so -------------------------------------------------------------------------------- /darkflow/cython_utils/nms.pxd: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | cimport numpy as np 3 | cimport cython 4 | ctypedef np.float_t DTYPE_t 5 | from libc.math cimport exp 6 | from utils.box import BoundBox 7 | 8 | 9 | cdef NMS(float[:, ::1] , float[:, ::1] ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /darkflow/dark/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/dark/.DS_Store -------------------------------------------------------------------------------- /darkflow/dark/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/dark/__init__.py -------------------------------------------------------------------------------- /darkflow/dark/connected.py: -------------------------------------------------------------------------------- 1 | from .layer import Layer 2 | import numpy as np 3 | 4 | class extract_layer(Layer): 5 | def setup(self, old_inp, old_out, 6 | activation, inp, out): 7 | if inp is None: inp = range(old_inp) 8 | self.activation = activation 9 | self.old_inp = old_inp 10 | self.old_out = old_out 11 | self.inp = inp 12 | self.out = out 13 | self.wshape = { 14 | 'biases': [len(self.out)], 15 | 'weights': [len(self.inp), len(self.out)] 16 | } 17 | 18 | @property 19 | def signature(self): 20 | sig = ['connected'] 21 | sig += self._signature[1:-2] 22 | return sig 23 | 24 | def present(self): 25 | args = self.signature 26 | self.presenter = connected_layer(*args) 27 | 28 | def recollect(self, val): 29 | w = val['weights'] 30 | b = val['biases'] 31 | if w is None: self.w = val; return 32 | w = np.take(w, self.inp, 0) 33 | w = np.take(w, self.out, 1) 34 | b = np.take(b, self.out) 35 | assert1 = w.shape == tuple(self.wshape['weights']) 36 | assert2 = b.shape == tuple(self.wshape['biases']) 37 | assert assert1 and assert2, \ 38 | 'Dimension does not match in {} recollect'.format( 39 | self._signature) 40 | 41 | self.w['weights'] = w 42 | self.w['biases'] = b 43 | 44 | 45 | 46 | class select_layer(Layer): 47 | def setup(self, inp, old, 48 | activation, inp_idx, 49 | out, keep, train): 50 | self.old = old 51 | self.keep = keep 52 | self.train = train 53 | self.inp_idx = inp_idx 54 | self.activation = activation 55 | inp_dim = inp 56 | if inp_idx is not None: 57 | inp_dim = len(inp_idx) 58 | self.inp = inp_dim 59 | self.out = out 60 | self.wshape = { 61 | 'biases': [out], 62 | 'weights': [inp_dim, out] 63 | } 64 | 65 | @property 66 | def signature(self): 67 | sig = ['connected'] 68 | sig += self._signature[1:-4] 69 | return sig 70 | 71 | def present(self): 72 | args = self.signature 73 | self.presenter = connected_layer(*args) 74 | 75 | def recollect(self, val): 76 | w = val['weights'] 77 | b = val['biases'] 78 | if w is None: self.w = val; return 79 | if self.inp_idx is not None: 80 | w = np.take(w, self.inp_idx, 0) 81 | 82 | keep_b = np.take(b, self.keep) 83 | keep_w = np.take(w, self.keep, 1) 84 | train_b = b[self.train:] 85 | train_w = w[:, self.train:] 86 | self.w['biases'] = np.concatenate( 87 | (keep_b, train_b), axis = 0) 88 | self.w['weights'] = np.concatenate( 89 | (keep_w, train_w), axis = 1) 90 | 91 | 92 | class connected_layer(Layer): 93 | def setup(self, input_size, 94 | output_size, activation): 95 | self.activation = activation 96 | self.inp = input_size 97 | self.out = output_size 98 | self.wshape = { 99 | 'biases': [self.out], 100 | 'weights': [self.inp, self.out] 101 | } 102 | 103 | def finalize(self, transpose): 104 | weights = self.w['weights'] 105 | if weights is None: return 106 | shp = self.wshape['weights'] 107 | if not transpose: 108 | weights = weights.reshape(shp[::-1]) 109 | weights = weights.transpose([1,0]) 110 | else: weights = weights.reshape(shp) 111 | self.w['weights'] = weights -------------------------------------------------------------------------------- /darkflow/dark/darknet.py: -------------------------------------------------------------------------------- 1 | from ..utils.process import cfg_yielder 2 | from .darkop import create_darkop 3 | from ..utils import loader 4 | import warnings 5 | import time 6 | import os 7 | 8 | class Darknet(object): 9 | 10 | _EXT = '.weights' 11 | 12 | def __init__(self, FLAGS): 13 | self.get_weight_src(FLAGS) 14 | self.modify = False 15 | 16 | print('Parsing {}'.format(self.src_cfg)) 17 | src_parsed = self.parse_cfg(self.src_cfg, FLAGS) 18 | self.src_meta, self.src_layers = src_parsed 19 | 20 | if self.src_cfg == FLAGS.model: 21 | self.meta, self.layers = src_parsed 22 | else: 23 | print('Parsing {}'.format(FLAGS.model)) 24 | des_parsed = self.parse_cfg(FLAGS.model, FLAGS) 25 | self.meta, self.layers = des_parsed 26 | 27 | self.load_weights() 28 | 29 | def get_weight_src(self, FLAGS): 30 | """ 31 | analyse FLAGS.load to know where is the 32 | source binary and what is its config. 33 | can be: None, FLAGS.model, or some other 34 | """ 35 | self.src_bin = FLAGS.model + self._EXT 36 | self.src_bin = FLAGS.binary + self.src_bin 37 | self.src_bin = os.path.abspath(self.src_bin) 38 | exist = os.path.isfile(self.src_bin) 39 | 40 | if FLAGS.load == str(): FLAGS.load = int() 41 | if type(FLAGS.load) is int: 42 | self.src_cfg = FLAGS.model 43 | if FLAGS.load: self.src_bin = None 44 | elif not exist: self.src_bin = None 45 | else: 46 | assert os.path.isfile(FLAGS.load), \ 47 | '{} not found'.format(FLAGS.load) 48 | self.src_bin = FLAGS.load 49 | name = loader.model_name(FLAGS.load) 50 | cfg_path = os.path.join(FLAGS.config, name + '.cfg') 51 | if not os.path.isfile(cfg_path): 52 | warnings.warn( 53 | '{} not found, use {} instead'.format( 54 | cfg_path, FLAGS.model)) 55 | cfg_path = FLAGS.model 56 | self.src_cfg = cfg_path 57 | FLAGS.load = int() 58 | 59 | 60 | def parse_cfg(self, model, FLAGS): 61 | """ 62 | return a list of `layers` objects (darkop.py) 63 | given path to binaries/ and configs/ 64 | """ 65 | args = [model, FLAGS.binary] 66 | cfg_layers = cfg_yielder(*args) 67 | meta = dict(); layers = list() 68 | for i, info in enumerate(cfg_layers): 69 | if i == 0: meta = info; continue 70 | else: new = create_darkop(*info) 71 | layers.append(new) 72 | return meta, layers 73 | 74 | def load_weights(self): 75 | """ 76 | Use `layers` and Loader to load .weights file 77 | """ 78 | print('Loading {} ...'.format(self.src_bin)) 79 | start = time.time() 80 | 81 | args = [self.src_bin, self.src_layers] 82 | wgts_loader = loader.create_loader(*args) 83 | for layer in self.layers: layer.load(wgts_loader) 84 | 85 | stop = time.time() 86 | print('Finished in {}s'.format(stop - start)) -------------------------------------------------------------------------------- /darkflow/dark/darkop.py: -------------------------------------------------------------------------------- 1 | from .layer import Layer 2 | from .convolution import * 3 | from .connected import * 4 | 5 | class avgpool_layer(Layer): 6 | pass 7 | 8 | class crop_layer(Layer): 9 | pass 10 | 11 | class maxpool_layer(Layer): 12 | def setup(self, ksize, stride, pad): 13 | self.stride = stride 14 | self.ksize = ksize 15 | self.pad = pad 16 | 17 | class softmax_layer(Layer): 18 | def setup(self, groups): 19 | self.groups = groups 20 | 21 | class dropout_layer(Layer): 22 | def setup(self, p): 23 | self.h['pdrop'] = dict({ 24 | 'feed': p, # for training 25 | 'dfault': 1.0, # for testing 26 | 'shape': () 27 | }) 28 | 29 | class route_layer(Layer): 30 | def setup(self, routes): 31 | self.routes = routes 32 | 33 | class reorg_layer(Layer): 34 | def setup(self, stride): 35 | self.stride = stride 36 | 37 | """ 38 | Darkop Factory 39 | """ 40 | 41 | darkops = { 42 | 'dropout': dropout_layer, 43 | 'connected': connected_layer, 44 | 'maxpool': maxpool_layer, 45 | 'convolutional': convolutional_layer, 46 | 'avgpool': avgpool_layer, 47 | 'softmax': softmax_layer, 48 | 'crop': crop_layer, 49 | 'local': local_layer, 50 | 'select': select_layer, 51 | 'route': route_layer, 52 | 'reorg': reorg_layer, 53 | 'conv-select': conv_select_layer, 54 | 'conv-extract': conv_extract_layer, 55 | 'extract': extract_layer 56 | } 57 | 58 | def create_darkop(ltype, num, *args): 59 | op_class = darkops.get(ltype, Layer) 60 | return op_class(ltype, num, *args) -------------------------------------------------------------------------------- /darkflow/dark/layer.py: -------------------------------------------------------------------------------- 1 | from ..utils import loader 2 | import numpy as np 3 | 4 | class Layer(object): 5 | 6 | def __init__(self, *args): 7 | self._signature = list(args) 8 | self.type = list(args)[0] 9 | self.number = list(args)[1] 10 | 11 | self.w = dict() # weights 12 | self.h = dict() # placeholders 13 | self.wshape = dict() # weight shape 14 | self.wsize = dict() # weight size 15 | self.setup(*args[2:]) # set attr up 16 | self.present() 17 | for var in self.wshape: 18 | shp = self.wshape[var] 19 | size = np.prod(shp) 20 | self.wsize[var] = size 21 | 22 | def load(self, src_loader): 23 | var_lay = src_loader.VAR_LAYER 24 | if self.type not in var_lay: return 25 | 26 | src_type = type(src_loader) 27 | if src_type is loader.weights_loader: 28 | wdict = self.load_weights(src_loader) 29 | else: 30 | wdict = self.load_ckpt(src_loader) 31 | if wdict is not None: 32 | self.recollect(wdict) 33 | 34 | def load_weights(self, src_loader): 35 | val = src_loader([self.presenter]) 36 | if val is None: return None 37 | else: return val.w 38 | 39 | def load_ckpt(self, src_loader): 40 | result = dict() 41 | presenter = self.presenter 42 | for var in presenter.wshape: 43 | name = presenter.varsig(var) 44 | shape = presenter.wshape[var] 45 | key = [name, shape] 46 | val = src_loader(key) 47 | result[var] = val 48 | return result 49 | 50 | @property 51 | def signature(self): 52 | return self._signature 53 | 54 | # For comparing two layers 55 | def __eq__(self, other): 56 | return self.signature == other.signature 57 | def __ne__(self, other): 58 | return not self.__eq__(other) 59 | 60 | def varsig(self, var): 61 | if var not in self.wshape: 62 | return None 63 | sig = str(self.number) 64 | sig += '-' + self.type 65 | sig += '/' + var 66 | return sig 67 | 68 | def recollect(self, w): self.w = w 69 | def present(self): self.presenter = self 70 | def setup(self, *args): pass 71 | def finalize(self): pass -------------------------------------------------------------------------------- /darkflow/net/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/.DS_Store -------------------------------------------------------------------------------- /darkflow/net/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/__init__.py -------------------------------------------------------------------------------- /darkflow/net/flow.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import numpy as np 4 | import tensorflow as tf 5 | import pickle 6 | from multiprocessing.pool import ThreadPool 7 | 8 | train_stats = ( 9 | 'Training statistics: \n' 10 | '\tLearning rate : {}\n' 11 | '\tBatch size : {}\n' 12 | '\tEpoch number : {}\n' 13 | '\tBackup every : {}' 14 | ) 15 | pool = ThreadPool() 16 | 17 | def _save_ckpt(self, step, loss_profile): 18 | file = '{}-{}{}' 19 | model = self.meta['name'] 20 | 21 | profile = file.format(model, step, '.profile') 22 | profile = os.path.join(self.FLAGS.backup, profile) 23 | with open(profile, 'wb') as profile_ckpt: 24 | pickle.dump(loss_profile, profile_ckpt) 25 | 26 | ckpt = file.format(model, step, '') 27 | ckpt = os.path.join(self.FLAGS.backup, ckpt) 28 | self.say('Checkpoint at step {}'.format(step)) 29 | self.saver.save(self.sess, ckpt) 30 | 31 | 32 | def train(self): 33 | loss_ph = self.framework.placeholders 34 | loss_mva = None; profile = list() 35 | 36 | batches = self.framework.shuffle() 37 | loss_op = self.framework.loss 38 | 39 | for i, (x_batch, datum) in enumerate(batches): 40 | if not i: self.say(train_stats.format( 41 | self.FLAGS.lr, self.FLAGS.batch, 42 | self.FLAGS.epoch, self.FLAGS.save 43 | )) 44 | 45 | feed_dict = { 46 | loss_ph[key]: datum[key] 47 | for key in loss_ph } 48 | feed_dict[self.inp] = x_batch 49 | feed_dict.update(self.feed) 50 | 51 | fetches = [self.train_op, loss_op] 52 | 53 | if self.FLAGS.summary: 54 | fetches.append(self.summary_op) 55 | 56 | fetched = self.sess.run(fetches, feed_dict) 57 | loss = fetched[1] 58 | 59 | if loss_mva is None: loss_mva = loss 60 | loss_mva = .9 * loss_mva + .1 * loss 61 | step_now = self.FLAGS.load + i + 1 62 | 63 | if self.FLAGS.summary: 64 | self.writer.add_summary(fetched[2], step_now) 65 | 66 | form = 'step {} - loss {} - moving ave loss {}' 67 | self.say(form.format(step_now, loss, loss_mva)) 68 | profile += [(loss, loss_mva)] 69 | 70 | ckpt = (i+1) % (self.FLAGS.save // self.FLAGS.batch) 71 | args = [step_now, profile] 72 | if not ckpt: _save_ckpt(self, *args) 73 | 74 | if ckpt: _save_ckpt(self, *args) 75 | 76 | def return_predict(self, im): 77 | assert isinstance(im, np.ndarray), \ 78 | 'Image is not a np.ndarray' 79 | h, w, _ = im.shape 80 | im = self.framework.resize_input(im) 81 | this_inp = np.expand_dims(im, 0) 82 | feed_dict = {self.inp : this_inp} 83 | 84 | out = self.sess.run(self.out, feed_dict)[0] 85 | boxes = self.framework.findboxes(out) 86 | threshold = self.FLAGS.threshold 87 | boxesInfo = list() 88 | for box in boxes: 89 | tmpBox = self.framework.process_box(box, h, w, threshold) 90 | if tmpBox is None: 91 | continue 92 | boxesInfo.append({ 93 | "label": tmpBox[4], 94 | "confidence": tmpBox[6], 95 | "topleft": { 96 | "x": tmpBox[0], 97 | "y": tmpBox[2]}, 98 | "bottomright": { 99 | "x": tmpBox[1], 100 | "y": tmpBox[3]} 101 | }) 102 | return boxesInfo 103 | 104 | import math 105 | 106 | def predict(self): 107 | inp_path = self.FLAGS.imgdir 108 | all_inps = os.listdir(inp_path) 109 | all_inps = [i for i in all_inps if self.framework.is_inp(i)] 110 | if not all_inps: 111 | msg = 'Failed to find any images in {} .' 112 | exit('Error: {}'.format(msg.format(inp_path))) 113 | 114 | batch = min(self.FLAGS.batch, len(all_inps)) 115 | 116 | # predict in batches 117 | n_batch = int(math.ceil(len(all_inps) / batch)) 118 | for j in range(n_batch): 119 | from_idx = j * batch 120 | to_idx = min(from_idx + batch, len(all_inps)) 121 | 122 | # collect images input in the batch 123 | this_batch = all_inps[from_idx:to_idx] 124 | inp_feed = pool.map(lambda inp: ( 125 | np.expand_dims(self.framework.preprocess( 126 | os.path.join(inp_path, inp)), 0)), this_batch) 127 | 128 | # Feed to the net 129 | feed_dict = {self.inp : np.concatenate(inp_feed, 0)} 130 | self.say('Forwarding {} inputs ...'.format(len(inp_feed))) 131 | start = time.time() 132 | out = self.sess.run(self.out, feed_dict) 133 | stop = time.time(); last = stop - start 134 | self.say('Total time = {}s / {} inps = {} ips'.format( 135 | last, len(inp_feed), len(inp_feed) / last)) 136 | 137 | # Post processing 138 | self.say('Post processing {} inputs ...'.format(len(inp_feed))) 139 | start = time.time() 140 | pool.map(lambda p: (lambda i, prediction: 141 | self.framework.postprocess( 142 | prediction, os.path.join(inp_path, this_batch[i])))(*p), 143 | enumerate(out)) 144 | stop = time.time(); last = stop - start 145 | 146 | # Timing 147 | self.say('Total time = {}s / {} inps = {} ips'.format( 148 | last, len(inp_feed), len(inp_feed) / last)) 149 | -------------------------------------------------------------------------------- /darkflow/net/framework.py: -------------------------------------------------------------------------------- 1 | from . import yolo 2 | from . import yolov2 3 | from . import vanilla 4 | from os.path import basename 5 | 6 | class framework(object): 7 | constructor = vanilla.constructor 8 | loss = vanilla.train.loss 9 | 10 | def __init__(self, meta, FLAGS): 11 | model = basename(meta['model']) 12 | model = '.'.join(model.split('.')[:-1]) 13 | meta['name'] = model 14 | 15 | self.constructor(meta, FLAGS) 16 | 17 | def is_inp(self, file_name): 18 | return True 19 | 20 | class YOLO(framework): 21 | constructor = yolo.constructor 22 | parse = yolo.data.parse 23 | shuffle = yolo.data.shuffle 24 | preprocess = yolo.predict.preprocess 25 | postprocess = yolo.predict.postprocess 26 | loss = yolo.train.loss 27 | is_inp = yolo.misc.is_inp 28 | profile = yolo.misc.profile 29 | _batch = yolo.data._batch 30 | resize_input = yolo.predict.resize_input 31 | findboxes = yolo.predict.findboxes 32 | process_box = yolo.predict.process_box 33 | 34 | class YOLOv2(framework): 35 | constructor = yolo.constructor 36 | parse = yolo.data.parse 37 | shuffle = yolov2.data.shuffle 38 | preprocess = yolo.predict.preprocess 39 | loss = yolov2.train.loss 40 | is_inp = yolo.misc.is_inp 41 | postprocess = yolov2.predict.postprocess 42 | _batch = yolov2.data._batch 43 | resize_input = yolo.predict.resize_input 44 | findboxes = yolov2.predict.findboxes 45 | process_box = yolo.predict.process_box 46 | 47 | """ 48 | framework factory 49 | """ 50 | 51 | types = { 52 | '[detection]': YOLO, 53 | '[region]': YOLOv2 54 | } 55 | 56 | def create_framework(meta, FLAGS): 57 | net_type = meta['type'] 58 | this = types.get(net_type, framework) 59 | return this(meta, FLAGS) -------------------------------------------------------------------------------- /darkflow/net/mnist/run.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/mnist/run.py -------------------------------------------------------------------------------- /darkflow/net/ops/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/ops/.DS_Store -------------------------------------------------------------------------------- /darkflow/net/ops/__init__.py: -------------------------------------------------------------------------------- 1 | from .simple import * 2 | from .convolution import * 3 | from .baseop import HEADER, LINE 4 | 5 | op_types = { 6 | 'convolutional': convolutional, 7 | 'conv-select': conv_select, 8 | 'connected': connected, 9 | 'maxpool': maxpool, 10 | 'leaky': leaky, 11 | 'dropout': dropout, 12 | 'flatten': flatten, 13 | 'avgpool': avgpool, 14 | 'softmax': softmax, 15 | 'identity': identity, 16 | 'crop': crop, 17 | 'local': local, 18 | 'select': select, 19 | 'route': route, 20 | 'reorg': reorg, 21 | 'conv-extract': conv_extract, 22 | 'extract': extract 23 | } 24 | 25 | def op_create(*args): 26 | layer_type = list(args)[0].type 27 | return op_types[layer_type](*args) -------------------------------------------------------------------------------- /darkflow/net/ops/baseop.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | import numpy as np 3 | 4 | FORM = '{:>6} | {:>6} | {:<32} | {}' 5 | FORM_ = '{}+{}+{}+{}' 6 | LINE = FORM_.format('-'*7, '-'*8, '-'*34, '-'*15) 7 | HEADER = FORM.format( 8 | 'Source', 'Train?','Layer description', 'Output size') 9 | 10 | def _shape(tensor): # work for both tf.Tensor & np.ndarray 11 | if type(tensor) in [tf.Variable, tf.Tensor]: 12 | return tensor.get_shape() 13 | else: return tensor.shape 14 | 15 | def _name(tensor): 16 | return tensor.name.split(':')[0] 17 | 18 | class BaseOp(object): 19 | """ 20 | BaseOp objects initialise with a darknet's `layer` object 21 | and input tensor of that layer `inp`, it calculates the 22 | output of this layer and place the result in self.out 23 | """ 24 | 25 | # let slim take care of the following vars 26 | _SLIM = ['gamma', 'moving_mean', 'moving_variance'] 27 | 28 | def __init__(self, layer, inp, num, roof, feed): 29 | self.inp = inp # BaseOp 30 | self.num = num # int 31 | self.out = None # tf.Tensor 32 | self.lay = layer 33 | 34 | self.scope = '{}-{}'.format( 35 | str(self.num), self.lay.type) 36 | self.gap = roof - self.num 37 | self.var = not self.gap > 0 38 | self.act = 'Load ' 39 | self.convert(feed) 40 | if self.var: self.train_msg = 'Yep! ' 41 | else: self.train_msg = 'Nope ' 42 | self.forward() 43 | 44 | def convert(self, feed): 45 | """convert self.lay to variables & placeholders""" 46 | for var in self.lay.wshape: 47 | self.wrap_variable(var) 48 | for ph in self.lay.h: 49 | self.wrap_pholder(ph, feed) 50 | 51 | def wrap_variable(self, var): 52 | """wrap layer.w into variables""" 53 | val = self.lay.w.get(var, None) 54 | if val is None: 55 | shape = self.lay.wshape[var] 56 | args = [0., 1e-2, shape] 57 | if 'moving_mean' in var: 58 | val = np.zeros(shape) 59 | elif 'moving_variance' in var: 60 | val = np.ones(shape) 61 | else: 62 | val = np.random.normal(*args) 63 | self.lay.w[var] = val.astype(np.float32) 64 | self.act = 'Init ' 65 | if not self.var: return 66 | 67 | val = self.lay.w[var] 68 | self.lay.w[var] = tf.constant_initializer(val) 69 | if var in self._SLIM: return 70 | with tf.variable_scope(self.scope): 71 | self.lay.w[var] = tf.get_variable(var, 72 | shape = self.lay.wshape[var], 73 | dtype = tf.float32, 74 | initializer = self.lay.w[var]) 75 | 76 | def wrap_pholder(self, ph, feed): 77 | """wrap layer.h into placeholders""" 78 | phtype = type(self.lay.h[ph]) 79 | if phtype is not dict: return 80 | 81 | sig = '{}/{}'.format(self.scope, ph) 82 | val = self.lay.h[ph] 83 | 84 | self.lay.h[ph] = tf.placeholder_with_default( 85 | val['dfault'], val['shape'], name = sig) 86 | feed[self.lay.h[ph]] = val['feed'] 87 | 88 | def verbalise(self): # console speaker 89 | msg = str() 90 | inp = _name(self.inp.out) 91 | if inp == 'input': \ 92 | msg = FORM.format( 93 | '', '', 'input', 94 | _shape(self.inp.out)) + '\n' 95 | if not self.act: return msg 96 | return msg + FORM.format( 97 | self.act, self.train_msg, 98 | self.speak(), _shape(self.out)) 99 | 100 | def speak(self): pass -------------------------------------------------------------------------------- /darkflow/net/ops/convolution.py: -------------------------------------------------------------------------------- 1 | import tensorflow.contrib.slim as slim 2 | from .baseop import BaseOp 3 | import tensorflow as tf 4 | import numpy as np 5 | 6 | class reorg(BaseOp): 7 | def _forward(self): 8 | inp = self.inp.out 9 | shape = inp.get_shape().as_list() 10 | _, h, w, c = shape 11 | s = self.lay.stride 12 | out = list() 13 | for i in range(int(h/s)): 14 | row_i = list() 15 | for j in range(int(w/s)): 16 | si, sj = s * i, s * j 17 | boxij = inp[:, si: si+s, sj: sj+s,:] 18 | flatij = tf.reshape(boxij, [-1,1,1,c*s*s]) 19 | row_i += [flatij] 20 | out += [tf.concat(row_i, 2)] 21 | 22 | self.out = tf.concat(out, 1) 23 | 24 | def forward(self): 25 | inp = self.inp.out 26 | s = self.lay.stride 27 | self.out = tf.extract_image_patches( 28 | inp, [1,s,s,1], [1,s,s,1], [1,1,1,1], 'VALID') 29 | 30 | def speak(self): 31 | args = [self.lay.stride] * 2 32 | msg = 'local flatten {}x{}' 33 | return msg.format(*args) 34 | 35 | 36 | class local(BaseOp): 37 | def forward(self): 38 | pad = [[self.lay.pad, self.lay.pad]] * 2; 39 | temp = tf.pad(self.inp.out, [[0, 0]] + pad + [[0, 0]]) 40 | 41 | k = self.lay.w['kernels'] 42 | ksz = self.lay.ksize 43 | half = int(ksz / 2) 44 | out = list() 45 | for i in range(self.lay.h_out): 46 | row_i = list() 47 | for j in range(self.lay.w_out): 48 | kij = k[i * self.lay.w_out + j] 49 | i_, j_ = i + 1 - half, j + 1 - half 50 | tij = temp[:, i_ : i_ + ksz, j_ : j_ + ksz,:] 51 | row_i.append( 52 | tf.nn.conv2d(tij, kij, 53 | padding = 'VALID', 54 | strides = [1] * 4)) 55 | out += [tf.concat(row_i, 2)] 56 | 57 | self.out = tf.concat(out, 1) 58 | 59 | def speak(self): 60 | l = self.lay 61 | args = [l.ksize] * 2 + [l.pad] + [l.stride] 62 | args += [l.activation] 63 | msg = 'loca {}x{}p{}_{} {}'.format(*args) 64 | return msg 65 | 66 | class convolutional(BaseOp): 67 | def forward(self): 68 | pad = [[self.lay.pad, self.lay.pad]] * 2; 69 | temp = tf.pad(self.inp.out, [[0, 0]] + pad + [[0, 0]]) 70 | temp = tf.nn.conv2d(temp, self.lay.w['kernel'], padding = 'VALID', 71 | name = self.scope, strides = [1] + [self.lay.stride] * 2 + [1]) 72 | if self.lay.batch_norm: 73 | temp = self.batchnorm(self.lay, temp) 74 | self.out = tf.nn.bias_add(temp, self.lay.w['biases']) 75 | 76 | def batchnorm(self, layer, inp): 77 | if not self.var: 78 | temp = (inp - layer.w['moving_mean']) 79 | temp /= (np.sqrt(layer.w['moving_variance']) + 1e-5) 80 | temp *= layer.w['gamma'] 81 | return temp 82 | else: 83 | args = dict({ 84 | 'center' : False, 'scale' : True, 85 | 'epsilon': 1e-5, 'scope' : self.scope, 86 | 'updates_collections' : None, 87 | 'is_training': layer.h['is_training'], 88 | 'param_initializers': layer.w 89 | }) 90 | return slim.batch_norm(inp, **args) 91 | 92 | def speak(self): 93 | l = self.lay 94 | args = [l.ksize] * 2 + [l.pad] + [l.stride] 95 | args += [l.batch_norm * '+bnorm'] 96 | args += [l.activation] 97 | msg = 'conv {}x{}p{}_{} {} {}'.format(*args) 98 | return msg 99 | 100 | class conv_select(convolutional): 101 | def speak(self): 102 | l = self.lay 103 | args = [l.ksize] * 2 + [l.pad] + [l.stride] 104 | args += [l.batch_norm * '+bnorm'] 105 | args += [l.activation] 106 | msg = 'sele {}x{}p{}_{} {} {}'.format(*args) 107 | return msg 108 | 109 | class conv_extract(convolutional): 110 | def speak(self): 111 | l = self.lay 112 | args = [l.ksize] * 2 + [l.pad] + [l.stride] 113 | args += [l.batch_norm * '+bnorm'] 114 | args += [l.activation] 115 | msg = 'extr {}x{}p{}_{} {} {}'.format(*args) 116 | return msg -------------------------------------------------------------------------------- /darkflow/net/ops/simple.py: -------------------------------------------------------------------------------- 1 | import tensorflow.contrib.slim as slim 2 | from .baseop import BaseOp 3 | import tensorflow as tf 4 | from distutils.version import StrictVersion 5 | 6 | class route(BaseOp): 7 | def forward(self): 8 | routes = self.lay.routes 9 | routes_out = list() 10 | for r in routes: 11 | this = self.inp 12 | while this.lay.number != r: 13 | this = this.inp 14 | assert this is not None, \ 15 | 'Routing to non-existence {}'.format(r) 16 | routes_out += [this.out] 17 | self.out = tf.concat(routes_out, 3) 18 | 19 | def speak(self): 20 | msg = 'concat {}' 21 | return msg.format(self.lay.routes) 22 | 23 | class connected(BaseOp): 24 | def forward(self): 25 | self.out = tf.nn.xw_plus_b( 26 | self.inp.out, 27 | self.lay.w['weights'], 28 | self.lay.w['biases'], 29 | name = self.scope) 30 | 31 | def speak(self): 32 | layer = self.lay 33 | args = [layer.inp, layer.out] 34 | args += [layer.activation] 35 | msg = 'full {} x {} {}' 36 | return msg.format(*args) 37 | 38 | class select(connected): 39 | """a weird connected layer""" 40 | def speak(self): 41 | layer = self.lay 42 | args = [layer.inp, layer.out] 43 | args += [layer.activation] 44 | msg = 'sele {} x {} {}' 45 | return msg.format(*args) 46 | 47 | class extract(connected): 48 | """a weird connected layer""" 49 | def speak(self): 50 | layer = self.lay 51 | args = [len(layer.inp), len(layer.out)] 52 | args += [layer.activation] 53 | msg = 'extr {} x {} {}' 54 | return msg.format(*args) 55 | 56 | class flatten(BaseOp): 57 | def forward(self): 58 | temp = tf.transpose( 59 | self.inp.out, [0,3,1,2]) 60 | self.out = slim.flatten( 61 | temp, scope = self.scope) 62 | 63 | def speak(self): return 'flat' 64 | 65 | 66 | class softmax(BaseOp): 67 | def forward(self): 68 | self.out = tf.nn.softmax(self.inp.out) 69 | 70 | def speak(self): return 'softmax()' 71 | 72 | 73 | class avgpool(BaseOp): 74 | def forward(self): 75 | self.out = tf.reduce_mean( 76 | self.inp.out, [1, 2], 77 | name = self.scope 78 | ) 79 | 80 | def speak(self): return 'avgpool()' 81 | 82 | 83 | class dropout(BaseOp): 84 | def forward(self): 85 | if self.lay.h['pdrop'] is None: 86 | self.lay.h['pdrop'] = 1.0 87 | self.out = tf.nn.dropout( 88 | self.inp.out, 89 | self.lay.h['pdrop'], 90 | name = self.scope 91 | ) 92 | 93 | def speak(self): return 'drop' 94 | 95 | 96 | class crop(BaseOp): 97 | def forward(self): 98 | self.out = self.inp.out * 2. - 1. 99 | 100 | def speak(self): 101 | return 'scale to (-1, 1)' 102 | 103 | 104 | class maxpool(BaseOp): 105 | def forward(self): 106 | self.out = tf.nn.max_pool( 107 | self.inp.out, padding = 'SAME', 108 | ksize = [1] + [self.lay.ksize]*2 + [1], 109 | strides = [1] + [self.lay.stride]*2 + [1], 110 | name = self.scope 111 | ) 112 | 113 | def speak(self): 114 | l = self.lay 115 | return 'maxp {}x{}p{}_{}'.format( 116 | l.ksize, l.ksize, l.pad, l.stride) 117 | 118 | 119 | class leaky(BaseOp): 120 | def forward(self): 121 | self.out = tf.maximum( 122 | .1 * self.inp.out, 123 | self.inp.out, 124 | name = self.scope 125 | ) 126 | 127 | def verbalise(self): pass 128 | 129 | 130 | class identity(BaseOp): 131 | def __init__(self, inp): 132 | self.inp = None 133 | self.out = inp 134 | -------------------------------------------------------------------------------- /darkflow/net/vanilla/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/vanilla/.DS_Store -------------------------------------------------------------------------------- /darkflow/net/vanilla/__init__.py: -------------------------------------------------------------------------------- 1 | from . import train 2 | 3 | def constructor(self, meta, FLAGS): 4 | self.meta, self.FLAGS = meta, FLAGS -------------------------------------------------------------------------------- /darkflow/net/vanilla/train.py: -------------------------------------------------------------------------------- 1 | _LOSS_TYPE = ['sse','l2', 'smooth', 2 | 'sparse', 'l1', 'softmax', 3 | 'svm', 'fisher'] 4 | 5 | def loss(self, net_out): 6 | m = self.meta 7 | loss_type = self.meta['type'] 8 | assert loss_type in _LOSS_TYPE, \ 9 | 'Loss type {} not implemented'.format(loss_type) 10 | 11 | out = net_out 12 | out_shape = out.get_shape() 13 | out_dtype = out.dtype.base_dtype 14 | _truth = tf.placeholders(out_dtype, out_shape) 15 | 16 | self.placeholders = dict({ 17 | 'truth': _truth 18 | }) 19 | 20 | diff = _truth - out 21 | if loss_type in ['sse','12']: 22 | loss = tf.nn.l2_loss(diff) 23 | 24 | elif loss_type == ['smooth']: 25 | small = tf.cast(diff < 1, tf.float32) 26 | large = 1. - small 27 | l1_loss = tf.nn.l1_loss(tf.multiply(diff, large)) 28 | l2_loss = tf.nn.l2_loss(tf.multiply(diff, small)) 29 | loss = l1_loss + l2_loss 30 | 31 | elif loss_type in ['sparse', 'l1']: 32 | loss = l1_loss(diff) 33 | 34 | elif loss_type == 'softmax': 35 | loss = tf.nn.softmax_cross_entropy_with_logits(logits, y) 36 | loss = tf.reduce_mean(loss) 37 | 38 | elif loss_type == 'svm': 39 | assert 'train_size' in m, \ 40 | 'Must specify' 41 | size = m['train_size'] 42 | self.nu = tf.Variable(tf.ones([train_size, num_classes])) -------------------------------------------------------------------------------- /darkflow/net/yolo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/yolo/.DS_Store -------------------------------------------------------------------------------- /darkflow/net/yolo/__init__.py: -------------------------------------------------------------------------------- 1 | from . import train 2 | from . import predict 3 | from . import data 4 | from . import misc 5 | import numpy as np 6 | 7 | 8 | """ YOLO framework __init__ equivalent""" 9 | 10 | def constructor(self, meta, FLAGS): 11 | 12 | def _to_color(indx, base): 13 | """ return (b, r, g) tuple""" 14 | base2 = base * base 15 | b = 2 - indx / base2 16 | r = 2 - (indx % base2) / base 17 | g = 2 - (indx % base2) % base 18 | return (b * 127, r * 127, g * 127) 19 | if 'labels' not in meta: 20 | misc.labels(meta, FLAGS) #We're not loading from a .pb so we do need to load the labels 21 | assert len(meta['labels']) == meta['classes'], ( 22 | 'labels.txt and {} indicate' + ' ' 23 | 'inconsistent class numbers' 24 | ).format(meta['model']) 25 | 26 | # assign a color for each label 27 | colors = list() 28 | base = int(np.ceil(pow(meta['classes'], 1./3))) 29 | for x in range(len(meta['labels'])): 30 | colors += [_to_color(x, base)] 31 | meta['colors'] = colors 32 | self.fetch = list() 33 | self.meta, self.FLAGS = meta, FLAGS 34 | 35 | # over-ride the threshold in meta if FLAGS has it. 36 | if FLAGS.threshold > 0.0: 37 | self.meta['thresh'] = FLAGS.threshold -------------------------------------------------------------------------------- /darkflow/net/yolo/data.py: -------------------------------------------------------------------------------- 1 | from ...utils.pascal_voc_clean_xml import pascal_voc_clean_xml 2 | from numpy.random import permutation as perm 3 | from .predict import preprocess 4 | # from .misc import show 5 | from copy import deepcopy 6 | import pickle 7 | import numpy as np 8 | import os 9 | 10 | def parse(self, exclusive = False): 11 | meta = self.meta 12 | ext = '.parsed' 13 | ann = self.FLAGS.annotation 14 | if not os.path.isdir(ann): 15 | msg = 'Annotation directory not found {} .' 16 | exit('Error: {}'.format(msg.format(ann))) 17 | print('\n{} parsing {}'.format(meta['model'], ann)) 18 | dumps = pascal_voc_clean_xml(ann, meta['labels'], exclusive) 19 | return dumps 20 | 21 | 22 | def _batch(self, chunk): 23 | """ 24 | Takes a chunk of parsed annotations 25 | returns value for placeholders of net's 26 | input & loss layer correspond to this chunk 27 | """ 28 | meta = self.meta 29 | S, B = meta['side'], meta['num'] 30 | C, labels = meta['classes'], meta['labels'] 31 | 32 | # preprocess 33 | jpg = chunk[0]; w, h, allobj_ = chunk[1] 34 | allobj = deepcopy(allobj_) 35 | path = os.path.join(self.FLAGS.dataset, jpg) 36 | img = self.preprocess(path, allobj) 37 | 38 | # Calculate regression target 39 | cellx = 1. * w / S 40 | celly = 1. * h / S 41 | for obj in allobj: 42 | centerx = .5*(obj[1]+obj[3]) #xmin, xmax 43 | centery = .5*(obj[2]+obj[4]) #ymin, ymax 44 | cx = centerx / cellx 45 | cy = centery / celly 46 | if cx >= S or cy >= S: return None, None 47 | obj[3] = float(obj[3]-obj[1]) / w 48 | obj[4] = float(obj[4]-obj[2]) / h 49 | obj[3] = np.sqrt(obj[3]) 50 | obj[4] = np.sqrt(obj[4]) 51 | obj[1] = cx - np.floor(cx) # centerx 52 | obj[2] = cy - np.floor(cy) # centery 53 | obj += [int(np.floor(cy) * S + np.floor(cx))] 54 | 55 | # show(im, allobj, S, w, h, cellx, celly) # unit test 56 | 57 | # Calculate placeholders' values 58 | probs = np.zeros([S*S,C]) 59 | confs = np.zeros([S*S,B]) 60 | coord = np.zeros([S*S,B,4]) 61 | proid = np.zeros([S*S,C]) 62 | prear = np.zeros([S*S,4]) 63 | for obj in allobj: 64 | probs[obj[5], :] = [0.] * C 65 | probs[obj[5], labels.index(obj[0])] = 1. 66 | proid[obj[5], :] = [1] * C 67 | coord[obj[5], :, :] = [obj[1:5]] * B 68 | prear[obj[5],0] = obj[1] - obj[3]**2 * .5 * S # xleft 69 | prear[obj[5],1] = obj[2] - obj[4]**2 * .5 * S # yup 70 | prear[obj[5],2] = obj[1] + obj[3]**2 * .5 * S # xright 71 | prear[obj[5],3] = obj[2] + obj[4]**2 * .5 * S # ybot 72 | confs[obj[5], :] = [1.] * B 73 | 74 | # Finalise the placeholders' values 75 | upleft = np.expand_dims(prear[:,0:2], 1) 76 | botright = np.expand_dims(prear[:,2:4], 1) 77 | wh = botright - upleft; 78 | area = wh[:,:,0] * wh[:,:,1] 79 | upleft = np.concatenate([upleft] * B, 1) 80 | botright = np.concatenate([botright] * B, 1) 81 | areas = np.concatenate([area] * B, 1) 82 | 83 | # value for placeholder at input layer 84 | inp_feed_val = img 85 | # value for placeholder at loss layer 86 | loss_feed_val = { 87 | 'probs': probs, 'confs': confs, 88 | 'coord': coord, 'proid': proid, 89 | 'areas': areas, 'upleft': upleft, 90 | 'botright': botright 91 | } 92 | 93 | return inp_feed_val, loss_feed_val 94 | 95 | def shuffle(self): 96 | batch = self.FLAGS.batch 97 | data = self.parse() 98 | size = len(data) 99 | 100 | print('Dataset of {} instance(s)'.format(size)) 101 | if batch > size: self.FLAGS.batch = batch = size 102 | batch_per_epoch = int(size / batch) 103 | 104 | for i in range(self.FLAGS.epoch): 105 | shuffle_idx = perm(np.arange(size)) 106 | for b in range(batch_per_epoch): 107 | # yield these 108 | x_batch = list() 109 | feed_batch = dict() 110 | 111 | for j in range(b*batch, b*batch+batch): 112 | train_instance = data[shuffle_idx[j]] 113 | inp, new_feed = self._batch(train_instance) 114 | 115 | if inp is None: continue 116 | x_batch += [np.expand_dims(inp, 0)] 117 | 118 | for key in new_feed: 119 | new = new_feed[key] 120 | old_feed = feed_batch.get(key, 121 | np.zeros((0,) + new.shape)) 122 | feed_batch[key] = np.concatenate([ 123 | old_feed, [new] 124 | ]) 125 | 126 | x_batch = np.concatenate(x_batch, 0) 127 | yield x_batch, feed_batch 128 | 129 | print('Finish {} epoch(es)'.format(i + 1)) 130 | 131 | -------------------------------------------------------------------------------- /darkflow/net/yolo/misc.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | import numpy as np 3 | import cv2 4 | import os 5 | 6 | labels20 = ["aeroplane", "bicycle", "bird", "boat", "bottle", 7 | "bus", "car", "cat", "chair", "cow", "diningtable", "dog", 8 | "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", 9 | "train", "tvmonitor"] 10 | 11 | # 8, 14, 15, 19 12 | 13 | voc_models = ['yolo-full', 'yolo-tiny', 'yolo-small', # <- v1 14 | 'yolov1', 'tiny-yolov1', # <- v1.1 15 | 'tiny-yolo-voc', 'yolo-voc'] # <- v2 16 | 17 | coco_models = ['tiny-coco', 'yolo-coco', # <- v1.1 18 | 'yolo', 'tiny-yolo'] # <- v2 19 | 20 | coco_names = 'coco.names' 21 | nine_names = '9k.names' 22 | 23 | def labels(meta, FLAGS): 24 | model = os.path.basename(meta['name']) 25 | if model in voc_models: 26 | print("Model has a VOC model name, loading VOC labels.") 27 | meta['labels'] = labels20 28 | else: 29 | file = FLAGS.labels 30 | if model in coco_models: 31 | print("Model has a coco model name, loading coco labels.") 32 | file = os.path.join(FLAGS.config, coco_names) 33 | elif model == 'yolo9000': 34 | print("Model has name yolo9000, loading yolo9000 labels.") 35 | file = os.path.join(FLAGS.config, nine_names) 36 | with open(file, 'r') as f: 37 | meta['labels'] = list() 38 | labs = [l.strip() for l in f.readlines()] 39 | for lab in labs: 40 | if lab == '----': break 41 | meta['labels'] += [lab] 42 | if len(meta['labels']) == 0: 43 | meta['labels'] = labels20 44 | 45 | def is_inp(self, name): 46 | return name.lower().endswith(('.jpg', '.jpeg', '.png')) 47 | 48 | def show(im, allobj, S, w, h, cellx, celly): 49 | for obj in allobj: 50 | a = obj[5] % S 51 | b = obj[5] // S 52 | cx = a + obj[1] 53 | cy = b + obj[2] 54 | centerx = cx * cellx 55 | centery = cy * celly 56 | ww = obj[3]**2 * w 57 | hh = obj[4]**2 * h 58 | cv2.rectangle(im, 59 | (int(centerx - ww/2), int(centery - hh/2)), 60 | (int(centerx + ww/2), int(centery + hh/2)), 61 | (0,0,255), 2) 62 | cv2.imshow('result', im) 63 | cv2.waitKey() 64 | cv2.destroyAllWindows() 65 | 66 | def show2(im, allobj): 67 | for obj in allobj: 68 | cv2.rectangle(im, 69 | (obj[1], obj[2]), 70 | (obj[3], obj[4]), 71 | (0,0,255),2) 72 | cv2.imshow('result', im) 73 | cv2.waitKey() 74 | cv2.destroyAllWindows() 75 | 76 | 77 | _MVA = .05 78 | 79 | def profile(self, net): 80 | pass 81 | # data = self.parse(exclusive = True) 82 | # size = len(data); batch = self.FLAGS.batch 83 | # all_inp_ = [x[0] for x in data] 84 | # net.say('Will cycle through {} examples {} times'.format( 85 | # len(all_inp_), net.FLAGS.epoch)) 86 | 87 | # fetch = list(); mvave = list(); names = list(); 88 | # this = net.top 89 | # conv_lay = ['convolutional', 'connected', 'local', 'conv-select'] 90 | # while this.inp is not None: 91 | # if this.lay.type in conv_lay: 92 | # fetch = [this.out] + fetch 93 | # names = [this.lay.signature] + names 94 | # mvave = [None] + mvave 95 | # this = this.inp 96 | # print(names) 97 | 98 | # total = int(); allofthem = len(all_inp_) * net.FLAGS.epoch 99 | # batch = min(net.FLAGS.batch, len(all_inp_)) 100 | # for count in range(net.FLAGS.epoch): 101 | # net.say('EPOCH {}'.format(count)) 102 | # for j in range(len(all_inp_)/batch): 103 | # inp_feed = list(); new_all = list() 104 | # all_inp = all_inp_[j*batch: (j*batch+batch)] 105 | # for inp in all_inp: 106 | # new_all += [inp] 107 | # this_inp = os.path.join(net.FLAGS.dataset, inp) 108 | # this_inp = net.framework.preprocess(this_inp) 109 | # expanded = np.expand_dims(this_inp, 0) 110 | # inp_feed.append(expanded) 111 | # all_inp = new_all 112 | # feed_dict = {net.inp : np.concatenate(inp_feed, 0)} 113 | # out = net.sess.run(fetch, feed_dict) 114 | 115 | # for i, o in enumerate(out): 116 | # oi = out[i]; 117 | # dim = len(oi.shape) - 1 118 | # ai = mvave[i]; 119 | # mi = np.mean(oi, tuple(range(dim))) 120 | # vi = np.var(oi, tuple(range(dim))) 121 | # if ai is None: mvave[i] = [mi, vi] 122 | # elif 'banana ninja yada yada': 123 | # ai[0] = (1 - _MVA) * ai[0] + _MVA * mi 124 | # ai[1] = (1 - _MVA) * ai[1] + _MVA * vi 125 | # total += len(inp_feed) 126 | # net.say('{} / {} = {}%'.format( 127 | # total, allofthem, 100. * total / allofthem)) 128 | 129 | # with open('profile', 'wb') as f: 130 | # pickle.dump([mvave], f, protocol = -1) 131 | -------------------------------------------------------------------------------- /darkflow/net/yolo/predict.py: -------------------------------------------------------------------------------- 1 | from ...utils.im_transform import imcv2_recolor, imcv2_affine_trans 2 | from ...utils.box import BoundBox, box_iou, prob_compare 3 | import numpy as np 4 | import cv2 5 | import os 6 | import json 7 | from ...cython_utils.cy_yolo_findboxes import yolo_box_constructor 8 | 9 | def _fix(obj, dims, scale, offs): 10 | for i in range(1, 5): 11 | dim = dims[(i + 1) % 2] 12 | off = offs[(i + 1) % 2] 13 | obj[i] = int(obj[i] * scale - off) 14 | obj[i] = max(min(obj[i], dim), 0) 15 | 16 | def resize_input(self, im): 17 | h, w, c = self.meta['inp_size'] 18 | imsz = cv2.resize(im, (w, h)) 19 | imsz = imsz / 255. 20 | imsz = imsz[:,:,::-1] 21 | return imsz 22 | 23 | def process_box(self, b, h, w, threshold): 24 | max_indx = np.argmax(b.probs) 25 | max_prob = b.probs[max_indx] 26 | label = self.meta['labels'][max_indx] 27 | if max_prob > threshold: 28 | left = int ((b.x - b.w/2.) * w) 29 | right = int ((b.x + b.w/2.) * w) 30 | top = int ((b.y - b.h/2.) * h) 31 | bot = int ((b.y + b.h/2.) * h) 32 | if left < 0 : left = 0 33 | if right > w - 1: right = w - 1 34 | if top < 0 : top = 0 35 | if bot > h - 1: bot = h - 1 36 | mess = '{}'.format(label) 37 | return (left, right, top, bot, mess, max_indx, max_prob) 38 | return None 39 | 40 | def findboxes(self, net_out): 41 | meta, FLAGS = self.meta, self.FLAGS 42 | threshold = FLAGS.threshold 43 | 44 | boxes = [] 45 | boxes = yolo_box_constructor(meta, net_out, threshold) 46 | 47 | return boxes 48 | 49 | def preprocess(self, im, allobj = None): 50 | """ 51 | Takes an image, return it as a numpy tensor that is readily 52 | to be fed into tfnet. If there is an accompanied annotation (allobj), 53 | meaning this preprocessing is serving the train process, then this 54 | image will be transformed with random noise to augment training data, 55 | using scale, translation, flipping and recolor. The accompanied 56 | parsed annotation (allobj) will also be modified accordingly. 57 | """ 58 | if type(im) is not np.ndarray: 59 | im = cv2.imread(im) 60 | 61 | if allobj is not None: # in training mode 62 | result = imcv2_affine_trans(im) 63 | im, dims, trans_param = result 64 | scale, offs, flip = trans_param 65 | for obj in allobj: 66 | _fix(obj, dims, scale, offs) 67 | if not flip: continue 68 | obj_1_ = obj[1] 69 | obj[1] = dims[0] - obj[3] 70 | obj[3] = dims[0] - obj_1_ 71 | im = imcv2_recolor(im) 72 | 73 | im = self.resize_input(im) 74 | if allobj is None: return im 75 | return im#, np.array(im) # for unit testing 76 | 77 | def postprocess(self, net_out, im, save = True): 78 | """ 79 | Takes net output, draw predictions, save to disk 80 | """ 81 | meta, FLAGS = self.meta, self.FLAGS 82 | threshold = FLAGS.threshold 83 | colors, labels = meta['colors'], meta['labels'] 84 | 85 | boxes = self.findboxes(net_out) 86 | 87 | if type(im) is not np.ndarray: 88 | imgcv = cv2.imread(im) 89 | else: imgcv = im 90 | 91 | h, w, _ = imgcv.shape 92 | resultsForJSON = [] 93 | for b in boxes: 94 | boxResults = self.process_box(b, h, w, threshold) 95 | if boxResults is None: 96 | continue 97 | left, right, top, bot, mess, max_indx, confidence = boxResults 98 | thick = int((h + w) // 300) 99 | if self.FLAGS.json: 100 | resultsForJSON.append({"label": mess, "confidence": float('%.2f' % confidence), "topleft": {"x": left, "y": top}, "bottomright": {"x": right, "y": bot}}) 101 | continue 102 | 103 | cv2.rectangle(imgcv, 104 | (left, top), (right, bot), 105 | self.meta['colors'][max_indx], thick) 106 | cv2.putText( 107 | imgcv, mess, (left, top - 12), 108 | 0, 1e-3 * h, self.meta['colors'][max_indx], 109 | thick // 3) 110 | 111 | 112 | if not save: return imgcv 113 | 114 | outfolder = os.path.join(self.FLAGS.imgdir, 'out') 115 | img_name = os.path.join(outfolder, os.path.basename(im)) 116 | if self.FLAGS.json: 117 | textJSON = json.dumps(resultsForJSON) 118 | textFile = os.path.splitext(img_name)[0] + ".json" 119 | with open(textFile, 'w') as f: 120 | f.write(textJSON) 121 | return 122 | 123 | cv2.imwrite(img_name, imgcv) 124 | -------------------------------------------------------------------------------- /darkflow/net/yolo/train.py: -------------------------------------------------------------------------------- 1 | import tensorflow.contrib.slim as slim 2 | import pickle 3 | import tensorflow as tf 4 | from .misc import show 5 | import numpy as np 6 | import os 7 | 8 | def loss(self, net_out): 9 | """ 10 | Takes net.out and placeholders value 11 | returned in batch() func above, 12 | to build train_op and loss 13 | """ 14 | # meta 15 | m = self.meta 16 | sprob = float(m['class_scale']) 17 | sconf = float(m['object_scale']) 18 | snoob = float(m['noobject_scale']) 19 | scoor = float(m['coord_scale']) 20 | S, B, C = m['side'], m['num'], m['classes'] 21 | SS = S * S # number of grid cells 22 | 23 | print('{} loss hyper-parameters:'.format(m['model'])) 24 | print('\tside = {}'.format(m['side'])) 25 | print('\tbox = {}'.format(m['num'])) 26 | print('\tclasses = {}'.format(m['classes'])) 27 | print('\tscales = {}'.format([sprob, sconf, snoob, scoor])) 28 | 29 | size1 = [None, SS, C] 30 | size2 = [None, SS, B] 31 | 32 | # return the below placeholders 33 | _probs = tf.placeholder(tf.float32, size1) 34 | _confs = tf.placeholder(tf.float32, size2) 35 | _coord = tf.placeholder(tf.float32, size2 + [4]) 36 | # weights term for L2 loss 37 | _proid = tf.placeholder(tf.float32, size1) 38 | # material calculating IOU 39 | _areas = tf.placeholder(tf.float32, size2) 40 | _upleft = tf.placeholder(tf.float32, size2 + [2]) 41 | _botright = tf.placeholder(tf.float32, size2 + [2]) 42 | 43 | self.placeholders = { 44 | 'probs':_probs, 'confs':_confs, 'coord':_coord, 'proid':_proid, 45 | 'areas':_areas, 'upleft':_upleft, 'botright':_botright 46 | } 47 | 48 | # Extract the coordinate prediction from net.out 49 | coords = net_out[:, SS * (C + B):] 50 | coords = tf.reshape(coords, [-1, SS, B, 4]) 51 | wh = tf.pow(coords[:,:,:,2:4], 2) * S # unit: grid cell 52 | area_pred = wh[:,:,:,0] * wh[:,:,:,1] # unit: grid cell^2 53 | centers = coords[:,:,:,0:2] # [batch, SS, B, 2] 54 | floor = centers - (wh * .5) # [batch, SS, B, 2] 55 | ceil = centers + (wh * .5) # [batch, SS, B, 2] 56 | 57 | # calculate the intersection areas 58 | intersect_upleft = tf.maximum(floor, _upleft) 59 | intersect_botright = tf.minimum(ceil , _botright) 60 | intersect_wh = intersect_botright - intersect_upleft 61 | intersect_wh = tf.maximum(intersect_wh, 0.0) 62 | intersect = tf.multiply(intersect_wh[:,:,:,0], intersect_wh[:,:,:,1]) 63 | 64 | # calculate the best IOU, set 0.0 confidence for worse boxes 65 | iou = tf.truediv(intersect, _areas + area_pred - intersect) 66 | best_box = tf.equal(iou, tf.reduce_max(iou, [2], True)) 67 | best_box = tf.to_float(best_box) 68 | confs = tf.multiply(best_box, _confs) 69 | 70 | # take care of the weight terms 71 | conid = snoob * (1. - confs) + sconf * confs 72 | weight_coo = tf.concat(4 * [tf.expand_dims(confs, -1)], 3) 73 | cooid = scoor * weight_coo 74 | proid = sprob * _proid 75 | 76 | # flatten 'em all 77 | probs = slim.flatten(_probs) 78 | proid = slim.flatten(proid) 79 | confs = slim.flatten(confs) 80 | conid = slim.flatten(conid) 81 | coord = slim.flatten(_coord) 82 | cooid = slim.flatten(cooid) 83 | 84 | self.fetch += [probs, confs, conid, cooid, proid] 85 | true = tf.concat([probs, confs, coord], 1) 86 | wght = tf.concat([proid, conid, cooid], 1) 87 | print('Building {} loss'.format(m['model'])) 88 | loss = tf.pow(net_out - true, 2) 89 | loss = tf.multiply(loss, wght) 90 | loss = tf.reduce_sum(loss, 1) 91 | self.loss = .5 * tf.reduce_mean(loss) 92 | tf.summary.scalar('{} loss'.format(m['model']), self.loss) 93 | -------------------------------------------------------------------------------- /darkflow/net/yolov2/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/net/yolov2/.DS_Store -------------------------------------------------------------------------------- /darkflow/net/yolov2/__init__.py: -------------------------------------------------------------------------------- 1 | from . import train 2 | from . import predict 3 | from . import data 4 | from ..yolo import misc 5 | import numpy as np 6 | -------------------------------------------------------------------------------- /darkflow/net/yolov2/data.py: -------------------------------------------------------------------------------- 1 | from ...utils.pascal_voc_clean_xml import pascal_voc_clean_xml 2 | from numpy.random import permutation as perm 3 | from ..yolo.predict import preprocess 4 | from ..yolo.data import shuffle 5 | from copy import deepcopy 6 | import pickle 7 | import numpy as np 8 | import os 9 | 10 | def _batch(self, chunk): 11 | """ 12 | Takes a chunk of parsed annotations 13 | returns value for placeholders of net's 14 | input & loss layer correspond to this chunk 15 | """ 16 | meta = self.meta 17 | labels = meta['labels'] 18 | 19 | H, W, _ = meta['out_size'] 20 | C, B = meta['classes'], meta['num'] 21 | anchors = meta['anchors'] 22 | 23 | # preprocess 24 | jpg = chunk[0]; w, h, allobj_ = chunk[1] 25 | allobj = deepcopy(allobj_) 26 | path = os.path.join(self.FLAGS.dataset, jpg) 27 | img = self.preprocess(path, allobj) 28 | 29 | # Calculate regression target 30 | cellx = 1. * w / W 31 | celly = 1. * h / H 32 | for obj in allobj: 33 | centerx = .5*(obj[1]+obj[3]) #xmin, xmax 34 | centery = .5*(obj[2]+obj[4]) #ymin, ymax 35 | cx = centerx / cellx 36 | cy = centery / celly 37 | if cx >= W or cy >= H: return None, None 38 | obj[3] = float(obj[3]-obj[1]) / w 39 | obj[4] = float(obj[4]-obj[2]) / h 40 | obj[3] = np.sqrt(obj[3]) 41 | obj[4] = np.sqrt(obj[4]) 42 | obj[1] = cx - np.floor(cx) # centerx 43 | obj[2] = cy - np.floor(cy) # centery 44 | obj += [int(np.floor(cy) * W + np.floor(cx))] 45 | 46 | # show(im, allobj, S, w, h, cellx, celly) # unit test 47 | 48 | # Calculate placeholders' values 49 | probs = np.zeros([H*W,B,C]) 50 | confs = np.zeros([H*W,B]) 51 | coord = np.zeros([H*W,B,4]) 52 | proid = np.zeros([H*W,B,C]) 53 | prear = np.zeros([H*W,4]) 54 | for obj in allobj: 55 | probs[obj[5], :, :] = [[0.]*C] * B 56 | probs[obj[5], :, labels.index(obj[0])] = 1. 57 | proid[obj[5], :, :] = [[1.]*C] * B 58 | coord[obj[5], :, :] = [obj[1:5]] * B 59 | prear[obj[5],0] = obj[1] - obj[3]**2 * .5 * W # xleft 60 | prear[obj[5],1] = obj[2] - obj[4]**2 * .5 * H # yup 61 | prear[obj[5],2] = obj[1] + obj[3]**2 * .5 * W # xright 62 | prear[obj[5],3] = obj[2] + obj[4]**2 * .5 * H # ybot 63 | confs[obj[5], :] = [1.] * B 64 | 65 | # Finalise the placeholders' values 66 | upleft = np.expand_dims(prear[:,0:2], 1) 67 | botright = np.expand_dims(prear[:,2:4], 1) 68 | wh = botright - upleft; 69 | area = wh[:,:,0] * wh[:,:,1] 70 | upleft = np.concatenate([upleft] * B, 1) 71 | botright = np.concatenate([botright] * B, 1) 72 | areas = np.concatenate([area] * B, 1) 73 | 74 | # value for placeholder at input layer 75 | inp_feed_val = img 76 | # value for placeholder at loss layer 77 | loss_feed_val = { 78 | 'probs': probs, 'confs': confs, 79 | 'coord': coord, 'proid': proid, 80 | 'areas': areas, 'upleft': upleft, 81 | 'botright': botright 82 | } 83 | 84 | return inp_feed_val, loss_feed_val 85 | 86 | -------------------------------------------------------------------------------- /darkflow/net/yolov2/predict.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import math 3 | import cv2 4 | import os 5 | import json 6 | #from scipy.special import expit 7 | #from utils.box import BoundBox, box_iou, prob_compare 8 | #from utils.box import prob_compare2, box_intersection 9 | from ...utils.box import BoundBox 10 | from ...cython_utils.cy_yolo2_findboxes import box_constructor 11 | 12 | def expit(x): 13 | return 1. / (1. + np.exp(-x)) 14 | 15 | def _softmax(x): 16 | e_x = np.exp(x - np.max(x)) 17 | out = e_x / e_x.sum() 18 | return out 19 | 20 | def findboxes(self, net_out): 21 | # meta 22 | meta = self.meta 23 | boxes = list() 24 | boxes=box_constructor(meta,net_out) 25 | return boxes 26 | 27 | def postprocess(self, net_out, im, save = True): 28 | """ 29 | Takes net output, draw net_out, save to disk 30 | """ 31 | boxes = self.findboxes(net_out) 32 | 33 | # meta 34 | meta = self.meta 35 | threshold = meta['thresh'] 36 | colors = meta['colors'] 37 | labels = meta['labels'] 38 | if type(im) is not np.ndarray: 39 | imgcv = cv2.imread(im) 40 | else: imgcv = im 41 | h, w, _ = imgcv.shape 42 | 43 | resultsForJSON = [] 44 | for b in boxes: 45 | boxResults = self.process_box(b, h, w, threshold) 46 | if boxResults is None: 47 | continue 48 | left, right, top, bot, mess, max_indx, confidence = boxResults 49 | thick = int((h + w) // 300) 50 | if self.FLAGS.json: 51 | resultsForJSON.append({"label": mess, "confidence": float('%.2f' % confidence), "topleft": {"x": left, "y": top}, "bottomright": {"x": right, "y": bot}}) 52 | continue 53 | 54 | cv2.rectangle(imgcv, 55 | (left, top), (right, bot), 56 | colors[max_indx], thick) 57 | cv2.putText(imgcv, mess, (left, top - 12), 58 | 0, 1e-3 * h, colors[max_indx],thick//3) 59 | 60 | if not save: return imgcv 61 | 62 | outfolder = os.path.join(self.FLAGS.imgdir, 'out') 63 | img_name = os.path.join(outfolder, os.path.basename(im)) 64 | if self.FLAGS.json: 65 | textJSON = json.dumps(resultsForJSON) 66 | textFile = os.path.splitext(img_name)[0] + ".json" 67 | with open(textFile, 'w') as f: 68 | f.write(textJSON) 69 | return 70 | 71 | cv2.imwrite(img_name, imgcv) 72 | -------------------------------------------------------------------------------- /darkflow/net/yolov2/train.py: -------------------------------------------------------------------------------- 1 | import tensorflow.contrib.slim as slim 2 | import pickle 3 | import tensorflow as tf 4 | from ..yolo.misc import show 5 | import numpy as np 6 | import os 7 | import math 8 | 9 | def expit_tensor(x): 10 | return 1. / (1. + tf.exp(-x)) 11 | 12 | def loss(self, net_out): 13 | """ 14 | Takes net.out and placeholders value 15 | returned in batch() func above, 16 | to build train_op and loss 17 | """ 18 | # meta 19 | m = self.meta 20 | sprob = float(m['class_scale']) 21 | sconf = float(m['object_scale']) 22 | snoob = float(m['noobject_scale']) 23 | scoor = float(m['coord_scale']) 24 | H, W, _ = m['out_size'] 25 | B, C = m['num'], m['classes'] 26 | HW = H * W # number of grid cells 27 | anchors = m['anchors'] 28 | 29 | print('{} loss hyper-parameters:'.format(m['model'])) 30 | print('\tH = {}'.format(H)) 31 | print('\tW = {}'.format(W)) 32 | print('\tbox = {}'.format(m['num'])) 33 | print('\tclasses = {}'.format(m['classes'])) 34 | print('\tscales = {}'.format([sprob, sconf, snoob, scoor])) 35 | 36 | size1 = [None, HW, B, C] 37 | size2 = [None, HW, B] 38 | 39 | # return the below placeholders 40 | _probs = tf.placeholder(tf.float32, size1) 41 | _confs = tf.placeholder(tf.float32, size2) 42 | _coord = tf.placeholder(tf.float32, size2 + [4]) 43 | # weights term for L2 loss 44 | _proid = tf.placeholder(tf.float32, size1) 45 | # material calculating IOU 46 | _areas = tf.placeholder(tf.float32, size2) 47 | _upleft = tf.placeholder(tf.float32, size2 + [2]) 48 | _botright = tf.placeholder(tf.float32, size2 + [2]) 49 | 50 | self.placeholders = { 51 | 'probs':_probs, 'confs':_confs, 'coord':_coord, 'proid':_proid, 52 | 'areas':_areas, 'upleft':_upleft, 'botright':_botright 53 | } 54 | 55 | # Extract the coordinate prediction from net.out 56 | net_out_reshape = tf.reshape(net_out, [-1, H, W, B, (4 + 1 + C)]) 57 | coords = net_out_reshape[:, :, :, :, :4] 58 | coords = tf.reshape(coords, [-1, H*W, B, 4]) 59 | adjusted_coords_xy = expit_tensor(coords[:,:,:,0:2]) 60 | adjusted_coords_wh = tf.sqrt(tf.exp(coords[:,:,:,2:4]) * np.reshape(anchors, [1, 1, B, 2]) / np.reshape([W, H], [1, 1, 1, 2])) 61 | coords = tf.concat([adjusted_coords_xy, adjusted_coords_wh], 3) 62 | 63 | adjusted_c = expit_tensor(net_out_reshape[:, :, :, :, 4]) 64 | adjusted_c = tf.reshape(adjusted_c, [-1, H*W, B, 1]) 65 | 66 | adjusted_prob = tf.nn.softmax(net_out_reshape[:, :, :, :, 5:]) 67 | adjusted_prob = tf.reshape(adjusted_prob, [-1, H*W, B, C]) 68 | 69 | adjusted_net_out = tf.concat([adjusted_coords_xy, adjusted_coords_wh, adjusted_c, adjusted_prob], 3) 70 | 71 | wh = tf.pow(coords[:,:,:,2:4], 2) * np.reshape([W, H], [1, 1, 1, 2]) 72 | area_pred = wh[:,:,:,0] * wh[:,:,:,1] 73 | centers = coords[:,:,:,0:2] 74 | floor = centers - (wh * .5) 75 | ceil = centers + (wh * .5) 76 | 77 | # calculate the intersection areas 78 | intersect_upleft = tf.maximum(floor, _upleft) 79 | intersect_botright = tf.minimum(ceil , _botright) 80 | intersect_wh = intersect_botright - intersect_upleft 81 | intersect_wh = tf.maximum(intersect_wh, 0.0) 82 | intersect = tf.multiply(intersect_wh[:,:,:,0], intersect_wh[:,:,:,1]) 83 | 84 | # calculate the best IOU, set 0.0 confidence for worse boxes 85 | iou = tf.truediv(intersect, _areas + area_pred - intersect) 86 | best_box = tf.equal(iou, tf.reduce_max(iou, [2], True)) 87 | best_box = tf.to_float(best_box) 88 | confs = tf.multiply(best_box, _confs) 89 | 90 | # take care of the weight terms 91 | conid = snoob * (1. - confs) + sconf * confs 92 | weight_coo = tf.concat(4 * [tf.expand_dims(confs, -1)], 3) 93 | cooid = scoor * weight_coo 94 | weight_pro = tf.concat(C * [tf.expand_dims(confs, -1)], 3) 95 | proid = sprob * weight_pro 96 | 97 | self.fetch += [_probs, confs, conid, cooid, proid] 98 | true = tf.concat([_coord, tf.expand_dims(confs, 3), _probs ], 3) 99 | wght = tf.concat([cooid, tf.expand_dims(conid, 3), proid ], 3) 100 | 101 | print('Building {} loss'.format(m['model'])) 102 | loss = tf.pow(adjusted_net_out - true, 2) 103 | loss = tf.multiply(loss, wght) 104 | loss = tf.reshape(loss, [-1, H*W*B*(4 + 1 + C)]) 105 | loss = tf.reduce_sum(loss, 1) 106 | self.loss = .5 * tf.reduce_mean(loss) 107 | tf.summary.scalar('{} loss'.format(m['model']), self.loss) -------------------------------------------------------------------------------- /darkflow/utils/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/utils/.DS_Store -------------------------------------------------------------------------------- /darkflow/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/darkflow/utils/__init__.py -------------------------------------------------------------------------------- /darkflow/utils/box.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | class BoundBox: 4 | def __init__(self, classes): 5 | self.x, self.y = float(), float() 6 | self.w, self.h = float(), float() 7 | self.c = float() 8 | self.class_num = classes 9 | self.probs = np.zeros((classes,)) 10 | 11 | def overlap(x1,w1,x2,w2): 12 | l1 = x1 - w1 / 2.; 13 | l2 = x2 - w2 / 2.; 14 | left = max(l1, l2) 15 | r1 = x1 + w1 / 2.; 16 | r2 = x2 + w2 / 2.; 17 | right = min(r1, r2) 18 | return right - left; 19 | 20 | def box_intersection(a, b): 21 | w = overlap(a.x, a.w, b.x, b.w); 22 | h = overlap(a.y, a.h, b.y, b.h); 23 | if w < 0 or h < 0: return 0; 24 | area = w * h; 25 | return area; 26 | 27 | def box_union(a, b): 28 | i = box_intersection(a, b); 29 | u = a.w * a.h + b.w * b.h - i; 30 | return u; 31 | 32 | def box_iou(a, b): 33 | return box_intersection(a, b) / box_union(a, b); 34 | 35 | def prob_compare(box): 36 | return box.probs[box.class_num] 37 | 38 | def prob_compare2(boxa, boxb): 39 | if (boxa.pi < boxb.pi): 40 | return 1 41 | elif(boxa.pi == boxb.pi): 42 | return 0 43 | else: 44 | return -1 -------------------------------------------------------------------------------- /darkflow/utils/im_transform.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | def imcv2_recolor(im, a = .1): 5 | t = [np.random.uniform()] 6 | t += [np.random.uniform()] 7 | t += [np.random.uniform()] 8 | t = np.array(t) * 2. - 1. 9 | 10 | # random amplify each channel 11 | im = im * (1 + t * a) 12 | mx = 255. * (1 + a) 13 | up = np.random.uniform() * 2 - 1 14 | # im = np.power(im/mx, 1. + up * .5) 15 | im = cv2.pow(im/mx, 1. + up * .5) 16 | return np.array(im * 255., np.uint8) 17 | 18 | def imcv2_affine_trans(im): 19 | # Scale and translate 20 | h, w, c = im.shape 21 | scale = np.random.uniform() / 10. + 1. 22 | max_offx = (scale-1.) * w 23 | max_offy = (scale-1.) * h 24 | offx = int(np.random.uniform() * max_offx) 25 | offy = int(np.random.uniform() * max_offy) 26 | 27 | im = cv2.resize(im, (0,0), fx = scale, fy = scale) 28 | im = im[offy : (offy + h), offx : (offx + w)] 29 | flip = np.random.binomial(1, .5) 30 | if flip: im = cv2.flip(im, 1) 31 | return im, [w, h, c], [scale, [offx, offy], flip] 32 | -------------------------------------------------------------------------------- /darkflow/utils/pascal_voc_clean_xml.py: -------------------------------------------------------------------------------- 1 | """ 2 | parse PASCAL VOC xml annotations 3 | """ 4 | 5 | import os 6 | import sys 7 | import xml.etree.ElementTree as ET 8 | import glob 9 | 10 | 11 | def _pp(l): # pretty printing 12 | for i in l: print('{}: {}'.format(i,l[i])) 13 | 14 | def pascal_voc_clean_xml(ANN, pick, exclusive = False): 15 | print('Parsing for {} {}'.format( 16 | pick, 'exclusively' * int(exclusive))) 17 | 18 | dumps = list() 19 | cur_dir = os.getcwd() 20 | os.chdir(ANN) 21 | annotations = os.listdir('.') 22 | annotations = glob.glob(str(annotations)+'*.xml') 23 | size = len(annotations) 24 | 25 | for i, file in enumerate(annotations): 26 | # progress bar 27 | sys.stdout.write('\r') 28 | percentage = 1. * (i+1) / size 29 | progress = int(percentage * 20) 30 | bar_arg = [progress*'=', ' '*(19-progress), percentage*100] 31 | bar_arg += [file] 32 | sys.stdout.write('[{}>{}]{:.0f}% {}'.format(*bar_arg)) 33 | sys.stdout.flush() 34 | 35 | # actual parsing 36 | in_file = open(file) 37 | tree=ET.parse(in_file) 38 | root = tree.getroot() 39 | jpg = str(root.find('filename').text) 40 | imsize = root.find('size') 41 | w = int(imsize.find('width').text) 42 | h = int(imsize.find('height').text) 43 | all = list() 44 | 45 | for obj in root.iter('object'): 46 | current = list() 47 | name = obj.find('name').text 48 | if name not in pick: 49 | continue 50 | 51 | xmlbox = obj.find('bndbox') 52 | xn = int(float(xmlbox.find('xmin').text)) 53 | xx = int(float(xmlbox.find('xmax').text)) 54 | yn = int(float(xmlbox.find('ymin').text)) 55 | yx = int(float(xmlbox.find('ymax').text)) 56 | current = [name,xn,yn,xx,yx] 57 | all += [current] 58 | 59 | add = [[jpg, [w, h, all]]] 60 | dumps += add 61 | in_file.close() 62 | 63 | # gather all stats 64 | stat = dict() 65 | for dump in dumps: 66 | all = dump[1][2] 67 | for current in all: 68 | if current[0] in pick: 69 | if current[0] in stat: 70 | stat[current[0]]+=1 71 | else: 72 | stat[current[0]] =1 73 | 74 | print('\nStatistics:') 75 | _pp(stat) 76 | print('Dataset size: {}'.format(len(dumps))) 77 | 78 | os.chdir(cur_dir) 79 | return dumps -------------------------------------------------------------------------------- /darkflow/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.0.0' 2 | """Current version of darkflow.""" -------------------------------------------------------------------------------- /dista.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | from darkflow.net.build import TFNet 3 | import numpy as np 4 | import datetime 5 | import threading 6 | import time 7 | IMAGE_WIDTH = 640 8 | IMAGE_HEIGHT = 480 9 | 10 | results=[] 11 | frame=None 12 | done=False 13 | cap = cv2.VideoCapture(0) 14 | cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) 15 | cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) 16 | options = { 17 | 'model':'cfg/tiny-yolo.cfg', 18 | 'load':'bin/tiny-yolo.weights', 19 | 'threshold': 0.1, 20 | 21 | } 22 | tfnet = TFNet(options) 23 | colors = [tuple(255 * np.random.rand(3)) for _ in range(10)] 24 | class camera(threading.Thread): 25 | def __init__(self, name): 26 | threading.Thread.__init__(self) 27 | self.name = name 28 | def run(self): 29 | print("Starting " + self.name) 30 | get_frame(self.name) 31 | print("Exiting " + self.name) 32 | 33 | def get_frame(threadName): 34 | global frame,done,cap 35 | while not done: 36 | _, frame = cap.read() 37 | 38 | class predictclass(threading.Thread): 39 | def __init__(self, name): 40 | threading.Thread.__init__(self) 41 | self.name = name 42 | def run(self): 43 | print("Starting " + self.name) 44 | predict(self.name) 45 | print("Exiting " + self.name) 46 | def predict(threadName): 47 | global results,frame,done 48 | while not done: 49 | results = tfnet.return_predict(frame) 50 | 51 | def find_marker(image): 52 | gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 53 | gray = cv2.GaussianBlur(gray, (5, 5), 0) 54 | edged = cv2.Canny(gray, 35, 125) 55 | (cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) 56 | c = max(cnts, key = cv2.contourArea) 57 | 58 | # compute the bounding box of the of the paper region and return it 59 | return cv2.minAreaRect(c) 60 | 61 | def distance_to_camera(knownWidth, focalLength, perWidth): 62 | return (knownWidth * focalLength) / perWidth 63 | 64 | # initialize the known distance from the camera to the object, which 65 | # in this case is 24 inches 66 | KNOWN_DISTANCE = 12.0 67 | 68 | # initialize the known object width, which in this case, the piece of 69 | # paper is 11 inches wide 70 | KNOWN_WIDTH = 6.0 71 | 72 | # initialize the list of images that we'll be using 73 | #IMAGE_PATHS = ["images/2ft.png", "images/3ft.png", "images/4ft.png"] 74 | 75 | # load the furst image that contains an object that is KNOWN TO BE 2 feet 76 | # from our camera, then find the paper marker in the image, and initialize 77 | # the focal length 78 | # image = cv2.imread(IMAGE_PATHS[0]) 79 | # marker = find_marker(image) 80 | # focalLength = (marker[1][0] * KNOWN_DISTANCE) / KNOWN_WIDTH 81 | 82 | #output_frame = OutputFrame() 83 | webcam_thread = camera("camera thread") 84 | predictor_thread = predictclass("predictclass thread") 85 | webcam_thread.start() 86 | time.sleep(.1) 87 | predictor_thread.start() 88 | 89 | cnt=0 90 | while True: 91 | stime = time.time() 92 | #ret, frame = cap.read() 93 | #results = tfnet.return_predict(frame) 94 | #results=output_frame.boxes 95 | #print("asdsasz",results) 96 | if 1: 97 | for color, result in zip(colors, results): 98 | tl = (result['topleft']['x'], result['topleft']['y']) 99 | br = (result['bottomright']['x'], result['bottomright']['y']) 100 | label = result['label'] 101 | #print(label) 102 | vech=['car','motercycle','truck','bus'] 103 | confidence = result['confidence'] 104 | rec=['person','traffic light','car','motercycle','truck','bus','stop sign'] 105 | if(confidence*100>35 and (label in rec)): 106 | #image = cv2.imread(imagePath) 107 | marker = find_marker(frame) 108 | inches = distance_to_camera(KNOWN_WIDTH, focalLength, marker[1][0]) 109 | 110 | # draw a bounding box around the image and display it 111 | box = np.int0(cv2.cv.BoxPoints(marker)) 112 | cv2.drawContours(image, [box], -1, (0, 255, 0), 2) 113 | cv2.putText(image, "%.2fft" % (inches / 12), 114 | (image.shape[1] - 200, image.shape[0] - 20), cv2.FONT_HERSHEY_SIMPLEX, 115 | 2.0, (0, 255, 0), 3) 116 | text = '{}: {:.0f}%'.format(label, confidence * 100) 117 | frame = cv2.rectangle(frame, tl, br, color, 5) 118 | frame = cv2.putText( 119 | frame, text, tl, cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 0), 2) 120 | if label in vech: 121 | cnt+=1 122 | cv2.imshow('frame', frame) 123 | print("Vehicles",cnt) 124 | print('FPS {:.1f}'.format(1 / (time.time() - stime))) 125 | if cv2.waitKey(1) & 0xFF == ord('q'): 126 | break 127 | 128 | cap.release() 129 | cv2.destroyAllWindows() 130 | # import the necessary packages 131 | -------------------------------------------------------------------------------- /fatigue.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | from functools import wraps 3 | from pygame import mixer 4 | import time 5 | from playsound import playsound 6 | 7 | lastsave = 0 8 | 9 | 10 | def counter(func): 11 | @wraps(func) 12 | def tmp(*args, **kwargs): 13 | tmp.count += 1 14 | global lastsave 15 | if time.time() - lastsave > 3: 16 | # this is in seconds, so 5 minutes = 300 seconds 17 | lastsave = time.time() 18 | tmp.count = 0 19 | return func(*args, **kwargs) 20 | tmp.count = 0 21 | return tmp 22 | 23 | 24 | 25 | 26 | #cap = cv2.VideoCapture(0) 27 | 28 | 29 | @counter 30 | def closed(): 31 | print ("Eye Closed") 32 | 33 | 34 | def openeye(): 35 | print ("Eye is Open") 36 | face_cascade=None 37 | eye_cascade=None 38 | def load(): 39 | global face_cascade,eye_cascade 40 | face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') 41 | eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml') 42 | 43 | def sound(): 44 | playsound("alarm.mp3") 45 | 46 | def pre(img): 47 | global face_cascade,eye_cascade 48 | load() 49 | if 1: 50 | #ret, img = cap.read() 51 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 52 | faces = face_cascade.detectMultiScale(gray, 1.3, 5) 53 | 54 | for (x, y, w, h) in faces: 55 | cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2) 56 | roi_gray = gray[y:y + h, x:x + w] 57 | roi_color = img[y:y + h, x:x + w] 58 | eyes = eye_cascade.detectMultiScale(roi_gray) 59 | 60 | if eyes is not (): 61 | for (ex, ey, ew, eh) in eyes: 62 | cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2) 63 | openeye() 64 | else: 65 | closed() 66 | if closed.count == 3: 67 | print ("driver is sleeping") 68 | playsound("alarm.mp3") 69 | 70 | cv2.imshow('img', img) 71 | k = cv2.waitKey(30) & 0xff 72 | 73 | -------------------------------------------------------------------------------- /flow: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | import sys 4 | from darkflow.cli import cliHandler 5 | 6 | cliHandler(sys.argv) 7 | 8 | -------------------------------------------------------------------------------- /icons/advt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/advt.png -------------------------------------------------------------------------------- /icons/advt1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/advt1.jpg -------------------------------------------------------------------------------- /icons/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/back.png -------------------------------------------------------------------------------- /icons/humid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/humid.png -------------------------------------------------------------------------------- /icons/offline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/offline.jpg -------------------------------------------------------------------------------- /icons/temperature.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/temperature.png -------------------------------------------------------------------------------- /icons/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/top.png -------------------------------------------------------------------------------- /icons/windspeed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/icons/windspeed.png -------------------------------------------------------------------------------- /images/Screen Shot 2018-03-31 at 5.08.08 pm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/images/Screen Shot 2018-03-31 at 5.08.08 pm.png -------------------------------------------------------------------------------- /images/Screen Shot 2018-03-31 at 5.55.32 pm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/images/Screen Shot 2018-03-31 at 5.55.32 pm.png -------------------------------------------------------------------------------- /images/Screen Shot 2018-03-31 at 5.56.00 pm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/images/Screen Shot 2018-03-31 at 5.56.00 pm.png -------------------------------------------------------------------------------- /mapscache/18.267420_71.158887_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/18.267420_71.158887_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/18.267420_72.037794_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/18.267420_72.037794_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/18.267420_72.916700_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/18.267420_72.916700_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/18.267420_73.795606_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/18.267420_73.795606_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.099189_72.914983_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.099189_72.914983_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.099189_72.915842_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.099189_72.915842_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.099189_72.916700_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.099189_72.916700_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.099189_72.917558_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.099189_72.917558_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_71.158887_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_71.158887_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_72.037794_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_72.037794_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_72.914983_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_72.914983_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_72.915842_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_72.915842_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_72.916700_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_72.916700_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_72.916700_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_72.916700_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_72.917558_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_72.917558_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100000_73.795606_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100000_73.795606_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100811_72.914983_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100811_72.914983_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100811_72.915842_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100811_72.915842_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100811_72.916700_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100811_72.916700_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.100811_72.917558_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.100811_72.917558_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.101622_72.914983_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.101622_72.914983_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.101622_72.915842_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.101622_72.915842_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.101622_72.916700_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.101622_72.916700_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.101622_72.917558_20_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.101622_72.917558_20_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.928412_71.158887_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.928412_71.158887_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.928412_72.037794_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.928412_72.037794_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.928412_72.916700_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.928412_72.916700_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/19.928412_73.795606_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/19.928412_73.795606_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/20.752504_71.158887_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/20.752504_71.158887_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/20.752504_72.037794_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/20.752504_72.037794_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/20.752504_72.916700_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/20.752504_72.916700_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /mapscache/20.752504_73.795606_10_roadmap_640_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/mapscache/20.752504_73.795606_10_roadmap_640_640.jpg -------------------------------------------------------------------------------- /ses.py: -------------------------------------------------------------------------------- 1 | import socket, traceback,time 2 | 3 | host = '169.254.8.219' 4 | port = 5555 5 | 6 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 7 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 8 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) 9 | s.bind((host, port)) 10 | 11 | while 1: 12 | message, address = s.recvfrom(8192) 13 | print (message) 14 | time.sleep(0) 15 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | from setuptools.extension import Extension 3 | from Cython.Build import cythonize 4 | import numpy 5 | import os 6 | import imp 7 | 8 | VERSION = imp.load_source('version', os.path.join('.', 'darkflow', 'version.py')) 9 | VERSION = VERSION.__version__ 10 | 11 | if os.name =='nt' : 12 | ext_modules=[ 13 | Extension("darkflow.cython_utils.nms", 14 | sources=["darkflow/cython_utils/nms.pyx"], 15 | #libraries=["m"] # Unix-like specific 16 | include_dirs=[numpy.get_include()] 17 | ), 18 | Extension("darkflow.cython_utils.cy_yolo2_findboxes", 19 | sources=["darkflow/cython_utils/cy_yolo2_findboxes.pyx"], 20 | #libraries=["m"] # Unix-like specific 21 | include_dirs=[numpy.get_include()] 22 | ), 23 | Extension("darkflow.cython_utils.cy_yolo_findboxes", 24 | sources=["darkflow/cython_utils/cy_yolo_findboxes.pyx"], 25 | #libraries=["m"] # Unix-like specific 26 | include_dirs=[numpy.get_include()] 27 | ) 28 | ] 29 | 30 | elif os.name =='posix' : 31 | ext_modules=[ 32 | Extension("darkflow.cython_utils.nms", 33 | sources=["darkflow/cython_utils/nms.pyx"], 34 | libraries=["m"], # Unix-like specific 35 | include_dirs=[numpy.get_include()] 36 | ), 37 | Extension("darkflow.cython_utils.cy_yolo2_findboxes", 38 | sources=["darkflow/cython_utils/cy_yolo2_findboxes.pyx"], 39 | libraries=["m"], # Unix-like specific 40 | include_dirs=[numpy.get_include()] 41 | ), 42 | Extension("darkflow.cython_utils.cy_yolo_findboxes", 43 | sources=["darkflow/cython_utils/cy_yolo_findboxes.pyx"], 44 | libraries=["m"], # Unix-like specific 45 | include_dirs=[numpy.get_include()] 46 | ) 47 | ] 48 | 49 | else : 50 | ext_modules=[ 51 | Extension("darkflow.cython_utils.nms", 52 | sources=["darkflow/cython_utils/nms.pyx"], 53 | libraries=["m"] # Unix-like specific 54 | ), 55 | Extension("darkflow.cython_utils.cy_yolo2_findboxes", 56 | sources=["darkflow/cython_utils/cy_yolo2_findboxes.pyx"], 57 | libraries=["m"] # Unix-like specific 58 | ), 59 | Extension("darkflow.cython_utils.cy_yolo_findboxes", 60 | sources=["darkflow/cython_utils/cy_yolo_findboxes.pyx"], 61 | libraries=["m"] # Unix-like specific 62 | ) 63 | ] 64 | 65 | setup( 66 | version=VERSION, 67 | name='darkflow', 68 | description='Darkflow', 69 | license='GPLv3', 70 | url='https://github.com/thtrieu/darkflow', 71 | packages = find_packages(), 72 | scripts = ['flow'], 73 | ext_modules = cythonize(ext_modules) 74 | ) -------------------------------------------------------------------------------- /sounds/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/.DS_Store -------------------------------------------------------------------------------- /sounds/stop_bn.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/stop_bn.mp3 -------------------------------------------------------------------------------- /sounds/stop_en.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/stop_en.mp3 -------------------------------------------------------------------------------- /sounds/stop_hi.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/stop_hi.mp3 -------------------------------------------------------------------------------- /sounds/stop_mh.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/stop_mh.mp3 -------------------------------------------------------------------------------- /sounds/tl_bn.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tl_bn.mp3 -------------------------------------------------------------------------------- /sounds/tl_en.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tl_en.mp3 -------------------------------------------------------------------------------- /sounds/tl_hi.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tl_hi.mp3 -------------------------------------------------------------------------------- /sounds/tl_mh.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tl_mh.mp3 -------------------------------------------------------------------------------- /sounds/tr_bn.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tr_bn.mp3 -------------------------------------------------------------------------------- /sounds/tr_en.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tr_en.mp3 -------------------------------------------------------------------------------- /sounds/tr_hi.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tr_hi.mp3 -------------------------------------------------------------------------------- /sounds/tr_mh.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/tr_mh.mp3 -------------------------------------------------------------------------------- /sounds/vehicle_ahead_bn.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/vehicle_ahead_bn.mp3 -------------------------------------------------------------------------------- /sounds/vehicle_ahead_en.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/vehicle_ahead_en.mp3 -------------------------------------------------------------------------------- /sounds/vehicle_ahead_hi.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/vehicle_ahead_hi.mp3 -------------------------------------------------------------------------------- /sounds/vehicle_ahead_mh.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/sounds/vehicle_ahead_mh.mp3 -------------------------------------------------------------------------------- /tai.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | import os 4 | import sys 5 | import tensorflow as tf 6 | from utils import label_map_util 7 | from utils import visualization_utils as vis_util 8 | import threading 9 | 10 | MODEL_NAME = 'ssd_mobilenet_v1_coco_11_06_2017' 11 | # Path to frozen detection graph. This is the actual model that is used for the object detection. 12 | PATH_TO_CKPT = 'models/' + MODEL_NAME + '/frozen_inference_graph.pb' 13 | # List of the strings that is used to add correct label for each box. 14 | CWD_PATH = os.getcwd() 15 | PATH_TO_LABELS = os.path.join(CWD_PATH,'object_detection', 'data', 'mscoco_label_map.pbtxt') 16 | print(PATH_TO_LABELS) 17 | NUM_CLASSES = 90 18 | IMAGE_WIDTH = 640 19 | IMAGE_HEIGHT = 480 20 | 21 | class OutputFrame: 22 | def __init__(self): 23 | self.frame = np.zeros((IMAGE_HEIGHT,IMAGE_WIDTH,3)) 24 | self.boxes = () 25 | 26 | def load_image_into_numpy_array(image): 27 | (im_width, im_height) = image.size 28 | return np.array(image.getdata()).reshape( 29 | (im_height, im_width, 3)).astype(np.uint8) 30 | 31 | class WebcamThread(threading.Thread): 32 | def __init__(self, name): 33 | threading.Thread.__init__(self) 34 | self.name = name 35 | def run(self): 36 | print("Starting " + self.name) 37 | get_frame(self.name) 38 | print("Exiting " + self.name) 39 | 40 | def get_frame(threadName): 41 | while not done: 42 | _, frame = cap.read() 43 | output_frame.frame = frame 44 | 45 | class PredictorThread(threading.Thread): 46 | def __init__(self, name): 47 | threading.Thread.__init__(self) 48 | self.name = name 49 | def run(self): 50 | print("Starting " + self.name) 51 | predict(self.name) 52 | print("Exiting " + self.name) 53 | 54 | def predict(threadName): 55 | while not done: 56 | _, image_np = cap.read() 57 | # Expand dimensions since the model expects images to have shape: [1, None, None, 3] 58 | image_np_expanded = np.expand_dims(image_np, axis=0) 59 | image_tensor = detection_graph.get_tensor_by_name('image_tensor:0') 60 | # Each box represents a part of the image where a particular object was detected. 61 | boxes = detection_graph.get_tensor_by_name('detection_boxes:0') 62 | # Each score represent how level of confidence for each of the objects. 63 | # Score is shown on the result image, together with the class label. 64 | scores = detection_graph.get_tensor_by_name('detection_scores:0') 65 | classes = detection_graph.get_tensor_by_name('detection_classes:0') 66 | num_detections = detection_graph.get_tensor_by_name('num_detections:0') 67 | # Actual detection. 68 | output_frame.boxes = sess.run( 69 | [boxes, scores, classes, num_detections], 70 | feed_dict={image_tensor: image_np_expanded}) 71 | 72 | 73 | if __name__ == "__main__": 74 | done = False 75 | detection_graph = tf.Graph() 76 | with detection_graph.as_default(): 77 | od_graph_def = tf.GraphDef() 78 | with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: 79 | serialized_graph = fid.read() 80 | od_graph_def.ParseFromString(serialized_graph) 81 | tf.import_graph_def(od_graph_def, name='') 82 | 83 | label_map = label_map_util.load_labelmap(PATH_TO_LABELS) 84 | categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True) 85 | category_index = label_map_util.create_category_index(categories) 86 | 87 | cap = cv2.VideoCapture(0) 88 | fourcc = cv2.VideoWriter_fourcc('a', 'v', 'c', '1') # note the lower case 89 | out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640,480), True) 90 | cap.set(3, IMAGE_WIDTH) 91 | cap.set(4, IMAGE_HEIGHT) 92 | sess = tf.Session(graph=detection_graph) 93 | output_frame = OutputFrame() 94 | 95 | webcam_thread = WebcamThread("Webcam Thread") 96 | predictor_thread = PredictorThread("Predictor Thread") 97 | webcam_thread.start() 98 | predictor_thread.start() 99 | 100 | while True: 101 | if output_frame.boxes == (): 102 | to_show = output_frame.frame 103 | else: 104 | to_show = output_frame.frame 105 | vis_util.visualize_boxes_and_labels_on_image_array( 106 | to_show, 107 | np.squeeze(output_frame.boxes[0]), 108 | np.squeeze(output_frame.boxes[2]).astype(np.int32), 109 | np.squeeze(output_frame.boxes[1]), 110 | category_index, 111 | use_normalized_coordinates=True, 112 | line_thickness=8) 113 | 114 | cv2.imshow('frame', to_show) 115 | out.write((to_show).astype('u1')) 116 | if cv2.waitKey(1) & 0xFF == ord('q'): 117 | done = True 118 | break 119 | 120 | cap.release() 121 | out.release() 122 | cv2.destroyAllWindows() -------------------------------------------------------------------------------- /test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/test/.DS_Store -------------------------------------------------------------------------------- /test/requirements-testing.txt: -------------------------------------------------------------------------------- 1 | tensorflow 2 | pytest 3 | requests 4 | opencv-python 5 | numpy 6 | Cython 7 | codecov 8 | pytest-cov -------------------------------------------------------------------------------- /test/training/annotations/1.xml: -------------------------------------------------------------------------------- 1 | 2 | VOC2007 3 | 1.jpg 4 | 5 | The VOC2007 Database 6 | PASCAL VOC2007 7 | flickr 8 | 336426776 9 | 10 | 11 | Elder Timothy Chaves 12 | Tim Chaves 13 | 14 | 15 | 500 16 | 375 17 | 3 18 | 19 | 0 20 | 21 | person 22 | Left 23 | 0 24 | 0 25 | 26 | 135 27 | 25 28 | 236 29 | 188 30 | 31 | 32 | 33 | bicycle 34 | Left 35 | 0 36 | 0 37 | 38 | 95 39 | 85 40 | 232 41 | 253 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/training/annotations/2.xml: -------------------------------------------------------------------------------- 1 | 2 | VOC2007 3 | 2.jpg 4 | 5 | The VOC2007 Database 6 | PASCAL VOC2007 7 | flickr 8 | 329950741 9 | 10 | 11 | Lothar Lenz 12 | Lothar Lenz 13 | 14 | 15 | 500 16 | 332 17 | 3 18 | 19 | 0 20 | 21 | person 22 | Left 23 | 0 24 | 0 25 | 26 | 235 27 | 51 28 | 309 29 | 222 30 | 31 | 32 | 33 | horse 34 | Left 35 | 0 36 | 0 37 | 38 | 157 39 | 106 40 | 426 41 | 294 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/training/images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/test/training/images/1.jpg -------------------------------------------------------------------------------- /test/training/images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishekjshukla/Traffic-Signs-and-Object-Detection/0a1a41687f4cd08cb7525cccfc3265111ad47d6c/test/training/images/2.jpg --------------------------------------------------------------------------------