Giter VIP home page Giter VIP logo

devicehive-video-analysis's Introduction

License

Video analysis demo

Requirements

Python

All requirements are listed in requirements file, except openCV (because of video support described here, here and here)

So (almost) all required packages can be installed by pip

Update: Since this release opencv-python ships with FFmpeg, V4L and V4L2. So i have added it to requirements.

pip install -r requirements.txt

Models data

Running

Local demo

To evaluate video file run

python eval.py --video="/path_to_video_file/"

Also video url can be passed (tested for youtube)

python eval.py --video="youtube_url"

If --video is not provided video device "0" (usually it's web cam) will be used by default.

Press q to close program.
Press s to save currents frame to file.

Run

python eval.py --help

for more info about available arguments.

Web based demo

There is demo with web interface and devicehive integration. It will capture video stream from your web cam, evaluate it and send predictions to devicehive. To use it run

python daemon.py

and go to http://127.0.0.1:8000 to configure devicehive connection. Video stream is available on http://127.0.0.1:8000/events/

devicehive-video-analysis's People

Contributors

igor-panteleev avatar nikolay-kha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

devicehive-video-analysis's Issues

Class list?

Do you have a class list that this project is capable of processing?

Error while running python eval.py --video="https://www.youtube.com/watch?v=MKk1u5RMTn4&list=RDMMMKk1u5RMTn4"

Traceback (most recent call last):
File "eval.py", line 123, in
tf.flags.DEFINE_string('video', 0, 'Path to the video file.')
File "/home/abhayjeet/.local/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 58, in wrapper
return original_function(*args, **kwargs)
File "/home/abhayjeet/.local/lib/python2.7/site-packages/absl/flags/_defines.py", line 241, in DEFINE_string
DEFINE(parser, name, default, help, flag_values, serializer, **args)
File "/home/abhayjeet/.local/lib/python2.7/site-packages/absl/flags/_defines.py", line 81, in DEFINE
DEFINE_flag(_flag.Flag(parser, serializer, name, default, help, **args),
File "/home/abhayjeet/.local/lib/python2.7/site-packages/absl/flags/_flag.py", line 107, in init
self._set_default(default)
File "/home/abhayjeet/.local/lib/python2.7/site-packages/absl/flags/_flag.py", line 196, in _set_default
self.default = self._parse(value)
File "/home/abhayjeet/.local/lib/python2.7/site-packages/absl/flags/_flag.py", line 169, in _parse
'flag --%s=%s: %s' % (self.name, argument, e))
absl.flags._exceptions.IllegalFlagValueError: flag --video=0: flag value must be a string, found "<type 'int'>"

Installed all the requirements.
Using tensorflow-gpu 1.7.0
cuda 9.0

Using this sample with GPU support

Hi
And thanks for this repo.

I got it to work "OUT OF THE BOX" with tensorflow cpu 1.4.0 in the requirements.txt.
But it does not work with any other cpu version of tensorflow nor 1.4.0-gpu or any other gpu version.
Tried hard in the last couple days (even installed ubuntu more than 10 times breaking and starting all over again) but no success so far. only TF1.4.0 cpu.
Other examples i use works flawlessly with my GPU. GTX1080.

Any idea why and how to fix this excellent example code to work with gpu even newer version of tensorflow?

10X
--{-@

Error in Raspberry Pi

$ python3 eval.py --video="aab.mp4"

** (Detector:2966): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted

$python3 daemon.py
[INFO] 2018-05-13 17:50:24,420: Start camera loop
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted

$python3
Python 3.5.3
[GCC 6.3.0 20170124] on linux

import tensorflow
import cv2
tensorflow.version
'1.4.0'
cv2.version
'3.4.0'

'pip install -r requirements.txt' fails

-e git://github.com/devicehive/devicehive-python-webconfig.git@a792db1babcedb5baa68ec6ba6ebcf0041f20469#egg=devicehive_webconfig

It runs well in most part, but it fails at this part.
When I run the command below,
$ pip install -e git://github.com/devicehive/devicehive-python-webconfig.git@a792db1babcedb5baa68ec6ba6ebcf0041f20469#egg=devicehive_webconfig

I get

Obtaining devicehive_webconfig from git+git://github.com/devicehive/devicehive-python-webconfig.git@a792db1babcedb5baa68ec6ba6ebcf0041f20469#egg=devicehive_webconfig
Updating /home/david/.virtualenvs/tf-yolo-demo/src/devicehive-webconfig clone (to revision a792db1babcedb5baa68ec6ba6ebcf0041f20469)
fatal: Could not parse object 'a792db1babcedb5baa68ec6ba6ebcf0041f20469'.
Command "git reset --hard -q a792db1babcedb5baa68ec6ba6ebcf0041f20469" failed with error code 128 in /home/david/.virtualenvs/tf-yolo-demo/src/devicehive-webconfig

$ git reset --hard -q a792db1babcedb5baa68ec6ba6ebcf0041f20469

fatal: Could not parse object 'a792db1babcedb5baa68ec6ba6ebcf0041f20469'.

Ruuning in docker

Hello,

Thank you very much for the wonderful work. I have a question: If I run this demo inside docker container, can I get the output in with web interface outside with http://127.0.0.1:8000/events/

I tried, but does not work. I am not sure what to do to make it work.

Best,
Fayzur

how can I make it faster?

I have managed to run the eval.py with YouTube video, but it is quite slow. The video is not playing at the same speed like in YouTube.

I'm using Google Cloud Platform with 2 GPUs

How can I make it faster?

"OSError: Can't open [filepath]"

When trying to evaluate any local video saved in my Downloads, I get this error:

OpenCV: Couldn't read video stream from file "~/Downloads/tf_traffic.mp4" Traceback (most recent call last): File "eval.py", line 126, in <module> tf.app.run(main=evaluate) File "/Users/ruhi/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run: _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "eval.py", line 44, in evaluate: raise IOError('Can\'t open "{}"'.format(FLAGS.video)) OSError: Can't open "~/Downloads/tf_traffic.mp4 "

I have ensure all dependencies are correctly installed and my file path is correct.

Question about merge your normalization ops and postprocess ops

Firstly, thanks a lot for your tutorial and code. It works perfectly!

And when reading your code, I found your comment in models/yolo.py:

We can merge normalization with other OPs, but we need to redefine input tensor for this.

So I would like to know whether you have any idea on how to do that?

I am now trying to export your version of YOLO from TF to TF-Serving, and if I chose self._raw_inp as input to export, then it will report Invalid argument: You must feed a value for placeholder tensor 'evaluation/input' with dtype float and shape [1,608,608,3] error. So instead, I exported self._eval_inp, and re-wrote the normalization part in numpy. It worked, but as you mentioned, it will be faster if we use tf's API to do the normalization. So I wonder whether you have any idea on how to merge normalization and postprocess in your _evaluate() in models/yolo.py.

Thanks! :-)

ImportError: No module named web.routes

Hi,
thanks for the tutorial!

When I start python daemon.py I get the following error:
Traceback (most recent call last):
File "daemon.py", line 25, in
from web.routes import routes
ImportError: No module named web.routes

Do you have an idea what the problem is? Which package shall I install?

It doesn't seem to open any of the YouTube videos

Of course, there are still many videos I haven't tried yet, but I couldn't get any successful result so far.
I ran
pip install -r requirements.txt
with modified requirements.txt (due to this issue)

-e git://github.com/devicehive/devicehive-python-webconfig.git#egg=devicehive_webconfig

then,
python eval.py --video="https://youtube_url"

Traceback (most recent call last):
File "eval.py", line 129, in
tf.app.run(main=evaluate)
File "~/.virtualenvs/tf-yolo-demo/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval.py", line 47, in evaluate
raise IOError('Can't open "{}"'.format(FLAGS.video))
OSError: Can't open "https://youtube_url"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.