tensorflow implementation of 'YOLO : Real-Time Object Detection'

Overview

YOLO_tensorflow

(Version 0.3, Last updated :2017.02.21)

1.Introduction

This is tensorflow implementation of the YOLO:Real-Time Object Detection

It can only do predictions using pretrained YOLO_small & YOLO_tiny network for now.

(+ YOLO_face detector from https://github.com/quanhua92/darknet )

I extracted weight values from darknet's (.weight) files.

My code does not support training. Use darknet for training.

Original code(C implementation) & paper : http://pjreddie.com/darknet/yolo/

2.Install

(1) Download code

(2) Download YOLO weight file from

YOLO_small : https://drive.google.com/file/d/0B2JbaJSrWLpza08yS2FSUnV2dlE/view?usp=sharing

YOLO_tiny : https://drive.google.com/file/d/0B2JbaJSrWLpza0FtQlc3ejhMTTA/view?usp=sharing

YOLO_face : https://drive.google.com/file/d/0B2JbaJSrWLpzMzR5eURGN2dMTk0/view?usp=sharing

(3) Put the 'YOLO_(version).ckpt' in the 'weight' folder of downloaded code

3.Usage

(1) direct usage with default settings (display on console, show output image, no output file writing)

python YOLO_(small or tiny)_tf.py -fromfile (input image filename)

(2) direct usage with custom settings

python YOLO_(small or tiny)_tf.py argvs

where argvs are

-fromfile (input image filename) : input image file
-disp_console (0 or 1) : whether display results on terminal or not
-imshow (0 or 1) : whether display result image or not
-tofile_img (output image filename) : output image file
-tofile_txt (output txt filename) : output text file (contains class, x, y, w, h, probability)

(3) import on other scripts

import YOLO_(small or tiny)_tf
yolo = YOLO_(small or tiny)_tf.YOLO_TF()

yolo.disp_console = (True or False, default = True)
yolo.imshow = (True or False, default = True)
yolo.tofile_img = (output image filename)
yolo.tofile_txt = (output txt filename)
yolo.filewrite_img = (True or False, default = False)
yolo.filewrite_txt = (True of False, default = False)

yolo.detect_from_file(filename)
yolo.detect_from_cvmat(cvmat)

4.Requirements

  • Tensorflow
  • Opencv2

5.Copyright

According to the LICENSE file of the original code,

  • Me and original author hold no liability for any damages
  • Do not use this on commercial!

6.Changelog

2016/02/15 : First upload!

2016/02/16 : Added YOLO_tiny, Fixed bug that ignores one of the boxes in grid when both boxes detected valid objects

2016/08/26 : Uploaded weight file converter! (darknet weight -> tensorflow ckpt)

2017/02/21 : Added YOLO_face (Thanks https://github.com/quanhua92/darknet)

Comments
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 4
  • YOLO_weight_extractor support one class cfg and .weights file?

    YOLO_weight_extractor support one class cfg and .weights file?

    I used one class cfg and .weights file like this: ./darknet yolo test cfg/yolo1-tiny-obj.cfg yolo1-tiny-obj_40000.weights. Then error happened in [detection] layer: 15: darknet: ./src/detection_layer.c:25: make_detection_layer: Assertion `sideside((1 + l.coords)*l.n + l.classes) == inputs' failed. 已放弃 (核心已转储) My cfg file like this: [net] batch=64 subdivisions=8 height=448 width=448 channels=3 momentum=0.9 decay=0.0005

    saturation=.75 exposure=.75 hue = .1

    learning_rate=0.0005 policy=steps steps=200,400,600,800,20000,30000 scales=2.5,2,2,2,.1,.1 max_batches = 40000

    [convolutional] batch_normalize=1 filters=16 size=3 stride=1 pad=1 activation=leaky

    [maxpool] size=2 stride=2

    [convolutional] batch_normalize=1 filters=32 size=3 stride=1 pad=1 activation=leaky

    [maxpool] size=2 stride=2

    [convolutional] batch_normalize=1 filters=64 size=3 stride=1 pad=1 activation=leaky

    [maxpool] size=2 stride=2

    [convolutional] batch_normalize=1 filters=128 size=3 stride=1 pad=1 activation=leaky

    [maxpool] size=2 stride=2

    [convolutional] batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky

    [maxpool] size=2 stride=2

    [convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky

    [maxpool] size=2 stride=2

    [convolutional] batch_normalize=1 size=3 stride=1 pad=1 filters=1024 activation=leaky

    [convolutional] batch_normalize=1 size=3 stride=1 pad=1 filters=256 activation=leaky

    [connected] output= 1470 activation=linear

    [detection] classes=1 coords=4 rescore=1 side=7 num=2 softmax=0 sqrt=1 jitter=.2

    object_scale=1 noobject_scale=.5 class_scale=1 coord_scale=5

    Have anyone known how to solve the problem? Thank you.

    opened by 123liluky 1
  • About iou threshold

    About iou threshold

    for i in range(len(boxes_filtered)):
    			if probs_filtered[i] == 0 : continue
    			for j in range(i+1,len(boxes_filtered)):
    				if self.iou(boxes_filtered[i],boxes_filtered[j]) > self.iou_threshold : 
    					probs_filtered[j] = 0.0
    		
    		filter_iou = np.array(probs_filtered>0.0,dtype='bool')
    		boxes_filtered = boxes_filtered[filter_iou]
    		probs_filtered = probs_filtered[filter_iou]
    		classes_num_filtered = classes_num_filtered[filter_iou]
    

    This code indicates that you remove the high iou, but I think you should remove the low.

    opened by puke3615 1
  • import order bug fix

    import order bug fix

    the order of import cause different cv2.imread() result, I don't know reason. In current order, cv2.imread() returns None. But after change the order of "import tensorflow as tf" and "import cv2", the function works correctly.

    opened by rossilhf 1
  • Would you like to share you code that extractes weight values from darknet's (.weight) files?

    Would you like to share you code that extractes weight values from darknet's (.weight) files?

    I tried to write a script to extract weight values from darknet's file.But I failed.The darknet's yolo-tiny.weight file is 172M.While I extracted weights referring to the structure of the yolo-tiny network ,I only got 123M's weights.Anything I missed? Is there something else in the yolo-tiny.weight file? Any instruction is appreciated! PS:Thank you for your great work!

    opened by WaterflowLee 1
  • Add some features~

    Add some features~

    1. Add count classes function
    2. cv2.imwrite saved check
    3. add -fromfolder function, user can specify which folder to read pictures from and program will return overall accuracy
    opened by jayxio 0
  • ./darknet:找不到命令

    ./darknet:找不到命令

    When I conducted sudo ./darknet yolo test ./cfg/yolo-tiny.cfg ./yolo-tiny.weights to get yolo-tiny.ckpt. Error was ./darknet:找不到命令? Have you run into? Thank you.

    opened by 123liluky 0
  • Hi, how to tranform the weights file into ckpt file?

    Hi, how to tranform the weights file into ckpt file?

    Good morning! I have trained my own model with the darknet framework from the official web and I get the .weights file as the result. I want to know how to tranform the .weights file into .ckpt file and to use your program to detect pictures. Thanks a lot!

    opened by zh0ngtian 0
  • modprobe: ERROR: could not insert 'nvidia_378_uvm': Invalid argument

    modprobe: ERROR: could not insert 'nvidia_378_uvm': Invalid argument

    When trying to load YOLO_small.ckpt, at line self.fc_32 = self.fc_layer(32,self.fc_30,1470,flat=False,linear=True) I get the error:

    modprobe: ERROR: could not insert 'nvidia_378_uvm': Invalid argument
    E tensorflow/stream_executor/cuda/cuda_driver.cc:509] failed call to cuInit: CUDA_ERROR_UNKNOWN
    I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: vm-gpu
    I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: vm-gpu
    I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 367.57.0
    I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:363] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module  367.57  Mon Oct  3 20:37:01 PDT 2016
    GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
    """
    I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: 367.57.0
    I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:300] kernel version seems to match DSO: 367.57.0
    

    Is the driver version hard coded into the checkpoint file? My driver is 367.57.0, as you can tell. I can run other tensorflow code fine. Using tensorflow-gpu=0.12.1. Using the same code on an exact same machine with a newer drive is fine, but this machine cannot have its drivers updated for reasons, so I'm wondering if it's possible to run this file with the older driver. I use CUDA 8.0 and cuDNN 5.1

    opened by halt9 0
  • ValueError: Restore called with invalid save path: 'weights/YOLO_small.ckpt'. File path is: 'weights/YOLO_small.ckpt'

    ValueError: Restore called with invalid save path: 'weights/YOLO_small.ckpt'. File path is: 'weights/YOLO_small.ckpt'

    When I run python YOLO_small_tf.py -fromfile /Users/yashajain/Downloads/yolotf-master/test/person.jpg

    It builds the network , but fails with :

    ValueError: Restore called with invalid save path: 'weights/YOLO_small.ckpt'. File path is: 'weights/YOLO_small.ckpt'

    I have the YOLO_small.ckpt file in weights/YOLO_small.ckpt'

    opened by Yaffa1607 0
  • Facing Problems While Testing

    Facing Problems While Testing

    First, my sincere thanks for making the implementation available in tensorflow framework.

    Problem 1: When I run on "small" weight file, I sometimes face the issue sometimes not even for the same image as present in the test folder. The issue is "OverflowError: signed integer is less than minimum"

    My PC specifics have a CPU RAM of 12gb and a GPU TITAN X

    Problem 2: When I run on "tiny" weight file, the image after detection shows rectangle made on different parts even when testing multiple times on the same image. Also, the the custom setting seem not to work in my case.

    Please do help. Thanks.

    opened by ghost 0
  • extracting weights of yolov2 tiny-voc

    extracting weights of yolov2 tiny-voc

    @gliese581gg hey, I want to extract weights of yolov2-tiny-voc.weights. But this code supports only yolo1 right ? How can I extract weights of tiny yolov2 ? please guide me. Thanks in advance!

    opened by Thilanka97 0
  • .weights -> .ckpt format not working

    .weights -> .ckpt format not working

    I followed the weight_extractor doc for converting yolov2-tiny.cfg and yolov2-tiny.weights using the following command

    ./darknet yolo test cfg/yolov2-tiny.cfg yolov2-tiny.weights

    However, there were no text file written to cjy folder. The output was this : First section must be [net] or [network]: Success

    Any ideas on this ? @gliese581gg

    opened by prateethvnayak 0
  • Category selection

    Category selection

    I think that the 'classes_num_filtered' variant should be derived from 'probs', not 'filter_mat_probs' in interpret_output function.Could you tell me if it is the right thing to do?

    opened by xudongwang123 0
  • Keras-Yolov3-mobilenet

    Keras-Yolov3-mobilenet

    I've trained yolov3 on mobilenet backend and get a good MAP(about 90M and 2 times faster than keras yolov3).I upload my code for mobilenet-yolov3 on https://github.com/Adamdad/keras-YOLOv3-mobilenet.git use it as you wish

    opened by Adamdad 0
  • run error

    run error

    run: python YOLO_tiny_tf.py -test.jpg error shows up as follow:

    C:\Users\Max\Anaconda3\envs\tensorflow\python.exe E:/condaDev/YOLO_tensorflow-master/YOLO_tiny_tf.py Building YOLO_tiny graph... Layer 1 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 16, Input channels = 3 Layer 2 : Type = Pool, Size = 2 * 2, Stride = 2 Layer 3 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 32, Input channels = 16 Layer 4 : Type = Pool, Size = 2 * 2, Stride = 2 Layer 5 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 64, Input channels = 32 Layer 6 : Type = Pool, Size = 2 * 2, Stride = 2 Layer 7 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 128, Input channels = 64 Layer 8 : Type = Pool, Size = 2 * 2, Stride = 2 Layer 9 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 256, Input channels = 128 Layer 10 : Type = Pool, Size = 2 * 2, Stride = 2 Layer 11 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 512, Input channels = 256 Layer 12 : Type = Pool, Size = 2 * 2, Stride = 2 Layer 13 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 1024, Input channels = 512 Layer 14 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 1024, Input channels = 1024 Layer 15 : Type = Conv, Size = 3 * 3, Stride = 1, Filters = 1024, Input channels = 1024 Layer 16 : Type = Full, Hidden = 256, Input dimension = 50176, Flat = 1, Activation = 1 Layer 17 : Type = Full, Hidden = 4096, Input dimension = 256, Flat = 0, Activation = 1 Layer 19 : Type = Full, Hidden = 1470, Input dimension = 4096, Flat = 0, Activation = 0 2018-08-24 13:26:27.092913: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 WARNING:tensorflow:From C:\Users\Max\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\tf_should_use.py:118: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02. Instructions for updating: Use tf.global_variables_initializer instead. Loading complete!

    seems run partly, outputs some info, but the rest part disappeared

    opened by hktxt 0
Owner
Jinyoung Choi
HI!
Jinyoung Choi
Real Time Object Detection and Classification using Yolo Algorithm.

Real time Object detection & Classification using YOLO algorithm. Real Time Object Detection and Classification using Yolo Algorithm. What is Object D

Ketan Chawla 1 Apr 17, 2022
Real-time multi-object tracker using YOLO v5 and deep sort

This repository contains a two-stage-tracker. The detections generated by YOLOv5, a family of object detection architectures and models pretrained on the COCO dataset, are passed to a Deep Sort algorithm which tracks the objects. It can track any object that your Yolov5 model was trained to detect.

Mike 3.6k Jan 5, 2023
LF-YOLO (Lighter and Faster YOLO) is used to detect defect of X-ray weld image.

This project is based on ultralytics/yolov3. LF-YOLO (Lighter and Faster YOLO) is used to detect defect of X-ray weld image. Download $ git clone http

null 26 Dec 13, 2022
Yolo ros - YOLO-ROS for HUAWEI ATLAS200

YOLO-ROS YOLO-ROS for NVIDIA YOLO-ROS for HUAWEI ATLAS200, please checkout for b

ChrisLiu 5 Oct 18, 2022
Object tracking and object detection is applied to track golf puts in real time and display stats/games.

Putting_Game Object tracking and object detection is applied to track golf puts in real time and display stats/games. Works best with the Perfect Prac

Max 1 Dec 29, 2021
Object detection using yolo-tiny model and opencv used as backend

Object detection Algorithm used : Yolo algorithm Backend : opencv Library required: opencv = 4.5.4-dev' Quick Overview about structure 1) main.py Load

null 2 Jul 6, 2022
YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )

Yolo v4, v3 and v2 for Windows and Linux (neural networks for object detection) Paper YOLO v4: https://arxiv.org/abs/2004.10934 Paper Scaled YOLO v4:

Alexey 20.2k Jan 9, 2023
Object detection (YOLO) with pytorch, OpenCV and python

Real Time Object/Face Detection Using YOLO-v3 This project implements a real time object and face detection using YOLO algorithm. You only look once,

null 1 Aug 4, 2022
Image-Adaptive YOLO for Object Detection in Adverse Weather Conditions

Image-Adaptive YOLO for Object Detection in Adverse Weather Conditions Accepted by AAAI 2022 [arxiv] Wenyu Liu, Gaofeng Ren, Runsheng Yu, Shi Guo, Jia

liuwenyu 245 Dec 16, 2022
Autonomous Perception: 3D Object Detection with Complex-YOLO

Autonomous Perception: 3D Object Detection with Complex-YOLO LiDAR object detect

Thomas Dunlap 2 Feb 18, 2022
Face and other object detection using OpenCV and ML Yolo

Object-and-Face-Detection-Using-Yolo- Opencv and YOLO object and face detection is implemented. You only look once (YOLO) is a state-of-the-art, real-

Happy  N. Monday 3 Feb 15, 2022
Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Detection"

M-LSD: Towards Light-weight and Real-time Line Segment Detection Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line

NAVER/LINE Vision 357 Jan 4, 2023
Real-Time-Student-Attendence-System - Real Time Student Attendence System

Real-Time-Student-Attendence-System The Student Attendance Management System Pro

Rounak Das 1 Feb 15, 2022
Unofficial PyTorch implementation of "RTM3D: Real-time Monocular 3D Detection from Object Keypoints for Autonomous Driving" (ECCV 2020)

RTM3D-PyTorch The PyTorch Implementation of the paper: RTM3D: Real-time Monocular 3D Detection from Object Keypoints for Autonomous Driving (ECCV 2020

Nguyen Mau Dzung 271 Nov 29, 2022
Use tensorflow to implement a Deep Neural Network for real time lane detection

LaneNet-Lane-Detection Use tensorflow to implement a Deep Neural Network for real time lane detection mainly based on the IEEE IV conference paper "To

MaybeShewill-CV 1.9k Jan 8, 2023
ICCV2021 Paper: AutoShape: Real-Time Shape-Aware Monocular 3D Object Detection

ICCV2021 Paper: AutoShape: Real-Time Shape-Aware Monocular 3D Object Detection

Zongdai 107 Dec 20, 2022
Lunar is a neural network aimbot that uses real-time object detection accelerated with CUDA on Nvidia GPUs.

Lunar Lunar is a neural network aimbot that uses real-time object detection accelerated with CUDA on Nvidia GPUs. About Lunar can be modified to work

Zeyad Mansour 276 Jan 7, 2023
BED: A Real-Time Object Detection System for Edge Devices

BED: A Real-Time Object Detection System for Edge Devices About this project Thi

Data Analytics Lab at Texas A&M University 44 Nov 18, 2022
Real-time Object Detection for Streaming Perception, CVPR 2022

StreamYOLO Real-time Object Detection for Streaming Perception Jinrong Yang, Songtao Liu, Zeming Li, Xiaoping Li, Sun Jian Real-time Object Detection

Jinrong Yang 237 Dec 27, 2022