Git Product home page Git Product logo

microsoft / microsoft-rocket-video-analytics-platform Goto Github PK

View Code? Open in Web Editor NEW
212.0 21.0 66.0 28.7 MB

A highly extensible software stack to empower everyone to build practical real-world live video analytics applications for object detection and counting with cutting edge machine learning algorithms.

Home Page: https://aka.ms/Rocket

License: MIT License

Batchfile 0.11% C# 99.89%
video-analytics edge-computing dotnet-core docker object-detection tensorflow azure yolov3 counting gpu

microsoft-rocket-video-analytics-platform's Introduction

Microsoft Rocket Video Analytics Platform

A highly extensible software stack to empower everyone to build practical real-world live video analytics applications for object detection and counting/alerting with cutting edge machine learning algorithms. The repository features a hybrid edge-cloud video analytics pipeline (built on C# .NET Core), which allows TensorFlow DNN model plug-in, GPU/FPGA acceleration, docker containerization/Kubernetes orchestration, and interactive querying for after-the-fact analysis. A brief summary of Rocket platform can be found inside ๐Ÿ“Rocket-features-and-pipelines.pdf.

Feel free to check out our ๐Ÿ“webinar on Rocket from Dec 2019.

How to run the code

Step 1: Set up environment

Setup on Windows

  • Microsoft Visual Studio (VS 2017 is preferred) is recommended IDE for Rocket on Windows 10. While installing Visual Studio, please also add C++ 2015.3 v14.00 (v140) toolset to your local machine. Snapshot below shows how to include C++ 2015.3 v14.00 from Visual Studio Installer.
    C++v140

  • Follow instructions to install .NET Core 2.2 (2.2.102 is preferred).

  • To enable GPU support, install CUDA Toolkit and cuDNN. Please also make sure your NVIDIA driver is up-to-date.

    • CUDA 8.0 (e.g., cuda_8.0.61_win10_network.exe) is needed for Darknet (e.g., YOLO) models.

      After installation, please make sure files in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\visual_studio_integration\MSBuildExtensions are copied to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\BuildCustomizations

    • CUDA 9.1 (e.g., cuda_9.1.85_win10_network.exe) is needed to support TensorFlow models.

    • cuDNN v7 is preferred (e.g., cudnn-8.0-windows10-x64-v7.2.1.38.zip).

      Copy <installpath>\cuda\bin\cudnn64_7.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin.
      Copy <installpath>\cuda\ include\cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include.
      Copy <installpath>\cuda\lib\x64\cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64.
      Add Variable Name: CUDA_PATH with Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 into Environment Variables.
      PathVariable

    • Restart your computer after installing CUDA and cuDNN.

Setup on Linux

Docker is recommended to run Rocket on Linux. Below we use Ubuntu 16.04 as an example to walk through the steps of building Rocket docker image and run it with GPU acceleration.

  • Install .NET Core 2.2 SDK (2.2.301 is preferred).
  • Install docker-ce (version 18.09.7 is preferred).
  • Install NVIDIA driver based on your GPU model (e.g., 418.67 for Tesla GPU).
  • Install nvidia-docker2. The NVIDIA Container Toolkit allows users to build and run GPU accelerated Docker containers. Note that you do NOT need to install the CUDA toolkit on the host, but GPU driver needs to be installed.

Step 2: Run the pipeline

Check out the repository.

Prepare video feeds and line configuration

  • Prepare video feeds. Rocket can be fed with either live video streams (e.g., rtsp://<url>:<port>/) or local video files (should be put into \media\). A sample video file sample.mp4 is already included in \media\.
  • Prepare a configuration file (should be placed into \cfg\) used in line-based counting/alerting and cascaded DNN calls. Each line in the file defines a line-of-interest with the format below.
    <line_name> <line_id> <x_1> <y_1> <x_2> <y_2> <overlap_threshold>
    A line configuration file sample.txt manually created based on sample.mp4 is also included in the folder \cfg\.
    To learn more about configuring your own lines of interest, please visit this page.

Build on Windows

  • Run Config.bat before the first time you run Rocket to download pre-compiled OpenCV and TensorFlow binaries as well as Darknet YOLO weights files. It may take few minutes depending on your network status. Proceed only when all downloads finish. YOLOv3 and Tiny YOLOv3 are already included in Rocket. You can plug-in other YOLO models as you wish.

  • Launch VAP.sln in src\VAP\ from Visual Studio.

  • Set pipeline config PplConfig in VideoPipelineCore - App.config. We have pre-compiled six configurations in the code. Pipeline descriptions are also included in ๐Ÿ“Rocket-features-and-pipelines.pdf.

    • 0: Line-based counting
    • 1: Darknet Yolo v3 on every frame (slide #7)
    • 2: TensorFlow FastRCNN on every frame (slide #8)
    • 3: Background subtraction-based (BGS) early filtering -> Darknet Tiny Yolo -> Darknet Yolo v3 (slide #9)
    • 4: BGS early filtering -> Darknet Tiny Yolo -> Database (ArangoDB and blob storage on Azure) (slide #10)
    • 5: BGS early filtering -> TensorFlow Fast R-CNN -> Azure Machine Learning (cloud) (slide #11)
  • (Optional) Set up your own database and Azure Machine Learning service if PplConfig is set to 4 or 5.

    • Azure Database:
      • Deploy SQL database like MySQL or NoSQL database such as ArangoDB on Azure by creating a VM.
      • Supply database settings (e.g., server name, user name, credentials etc.) to Rocket in App.Config.
      • You can also set up your cloud storage (e.g., Azure Blob Storage) to store images/videos. In pipeline 4, Rocket sends detection images to an Azure storage account and metadata to an Azure database.
      azureconfig
    • Azure Machine Learning:
      • Deploy your deep learning models to Azure (e.g., using Azure Kubernetes Service or AKS) for inference with GPU or FPGA.
      • After deploying your model as a web service, provide host URL, key, and service ID to VAP in App.Config. Rocker will handle the communication between local modules and the cloud service.
      azureconfig
  • Build the solution.

  • Run the code.

    • Using Visual Studio: set VideoPipelineCore - Property - Debug - Application Arguments <video_file/camera_url> <line_detection_config_file> <sampling_factor> <resolution_factor> <object_category>. To run Rocket on the sample video, for example, arguments can be set to sample.mp4 sample.txt 1 1 car.
    • Using Command Line (CMD or PowerShell): run dotnet .\VideoPipelineCore.dll <video_file/camera_url> <line_detection_config_file> <sampling_factor> <resolution_factor> <object_category> in \src\VAP\VideoPipelineCore\bin\Debug\netcoreapp2.2. For instance, dotnet .\VideoPipelineCore.dll sample.mp4 sample.txt 1 1 car.

Build on Linux

We have pre-built a Rocket docker image from docker branch with local processing only (slide #12 without cloud parts). The image is hosted on Docker Hub, a public library and community for container images, and you will be asked to login before pull/push images (sign up first if you don't have an account).

To test on the pre-built Rocket image, run
docker pull ycshu086/rocket-sample-edgeonly:0.1

Once pulled, run the command below to start Rocket with NVIDIA GPU.
docker run --runtime=nvidia -v <local directory>:/app/output ycshu086/rocket-sample-edgeonly:0.1 sample.mp4 sample.txt 1 1 car

  • Build your own Rocket pipeline on Linux

    • Pull base docker image with CUDA toolkit and OpenCV. This image is needed to build Rocket docker image.
      docker pull ycshu086/ubuntu-dotnetcore-opencv-opencvsharp-cuda-cudnn:<version>.
    • Git clone docker branch for source code to dockerize Rocket on Linux.
    • Create line configuration file(s) inside \cfg. If you are running Rocket on a pre-recorded video, please also copy the video file into \media.
    • (Optional) Update \src\VAP\VideoPipelineCore\App.Config to set proper parameters for database and Azure Machine Learning service connection.
    • Run sudo chmod 744 Config.sh and sudo ./Config.sh before the first time you build Rocket image to download pre-compiled TensorFlow binaries.
    • Run docker build to build Rocket image using Dockerfile.VAP.
      docker build -t <repository>/<image>:<version> -f Dockerfile.VAP .
    • (Optional) Push Rocket image to a cloud repository (e.g., docker hub, Azure Container Registry etc.) if you need to run it somewhere else.
      docker push -t <repository>/<image>:<version>
  • Run Rocket image on Linux

    • Pull a pre-built Rocket docker image to the local machine. You can use docker images to check existing images.
      docker pull -t <repository>/<image>:<version>

    • Mount volume into the container and run Rocket image with NVIDIA GPU.
      docker run --runtime=nvidia -v <local directory>:/app/output <repository>/<image>:<version> sample.mp4 sample.txt 1 1 car

Step 3: Results

Output images are generated in folders in \src\VAP\VideoPipelineCore\bin\ (Windows), or the local directory you mount during docker run on Linux. Results from different modules are sent to different directories (e.g., output_bgsline for background subtraction-based detector) whereas output_all has images from all modules. Name of each file consists of frame ID, module name, and confidence score. Below are few sample results from running pipeline 3 and pipeline 5 on sample.mp4. You should also see results printed in console during running. output The above illustration on pipeline 3 shows that at frame 2679, background subtraction detected an object, tiny Yolo DNN confirmed it was a car with a confidence of 0.24, and heavy Yolo v3 confirmed it with a confidence of 0.92. Likewise, for pipeline 5 where the TensorFlow FastRNN model had a confidence of 0.55 and AzureML (in the cloud) came back with a confidence of 0.76 for the same object.

microsoft-rocket-video-analytics-platform's People

Contributors

ganesh-ananth avatar iharwell avatar microsoft-github-policy-service[bot] avatar sharwell avatar ycshu086 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  avatar  avatar

microsoft-rocket-video-analytics-platform's Issues

process of plugging in a custom Tensorflow model

Hi
I am experimenting with the Rocket Platform and ran pipeline 4, but got the following output :

~$ sudo docker run --runtime=nvidia -v /home/Createlabs/Microsoft-Rocket-Video-Analytics-Platform/output:/app/output lvareg.azurecr.io/custom_rocket sample.mp4 sample.txt 1 1 tree
./cfg/sample.txt
Downloading default label map
Downloading default model
Extracting
dir = /app

Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path '/app/faster_rcnn_openimages_v4_inception_resnet_v2_1/frozen_inference_graph.pb'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.ReadAllBytes(String path)
   at Wrapper.TF.TFWrapper..ctor() in /app/src/VAP/TFWrapper/TFWrapper.cs:line 64
   at TFDetector.FrameDNNTF..ctor(List`1 lines) in /app/src/VAP/TFDetector/FrameDNNTF.cs:line 25
   at TFDetector.LineTriggeredDNNTF..ctor(List`1 lines) in /app/src/VAP/TFDetector/LineTriggeredDNNTF.cs:line 25
   at VideoPipelineCore.Program.Main(String[] args) in /app/src/VAP/VideoPipelineCore/Program.cs:line 75

(The sample.mp4 is a video containing trees.)

Currently, I plugged in a model from Tensorflow Hub and have changed lines 116-119 in src/VAP/TFWrapper/TFWrapper.cs to :

string defaultModelUrl = "https://tfhub.dev/google/faster_rcnn/openimages_v4/inception_resnet_v2/1?tf-hub-format=compressed";

            var modelFile = Path.Combine(dir, "faster_rcnn_openimages_v4_inception_resnet_v2_1/frozen_inference_graph.pb");
            var zipfile = Path.Combine(dir, "faster_rcnn_openimages_v4_inception_resnet_v2_1.tar.gz");

The error indicates looking for the frozen_inference_graph.pb, which is a file in the original model .

Please share the process of plugging in a custom Tensorflow model.
I am new to ML and the Rocket platform. Any help would be appreciated. TIA!

Unable to download the Microsoft-Rocket-Video-Analytics-Platform-opencv_world340.dll

Hi there,
When I build the rocket on Windows and try to run the Config.bat, I find I cannot download opencv binary files
I list them as below for your reference, it seems that I do not have the permission to get this file. How to deal with this staff?

(base) C:\Users\95492\Downloads\Microsoft-Rocket-Video-Analytics-Platform-master>powershell -Command "(New-Object Net.WebClient).DownloadFile('https://aka.ms/Microsoft-Rocket-Video-Analytics-Platform-opencv_world340.dll', './src/VAP/YoloWrapper/Dependencies/opencv_world340.dll')"
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (403) Forbidden."
At line:1 char:1

  • (New-Object Net.WebClient).DownloadFile('https://aka.ms/Microsoft-Roc ...
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : WebException
    
    
    

(base) C:\Users\95492\Downloads\Microsoft-Rocket-Video-Analytics-Platform-master>powershell -Command "(New-Object Net.WebClient).DownloadFile('https://aka.ms/Microsoft-Rocket-Video-Analytics-Platform-opencv_world340d.dll', './src/VAP/YoloWrapper/Dependencies/opencv_world340d.dll')"
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (403) Forbidden."
At line:1 char:1

  • (New-Object Net.WebClient).DownloadFile('https://aka.ms/Microsoft-Roc ...
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : WebException
    

Running multiple video frames

Can I clarify that the current available pipelines do not allow the application to process more than one video stream at a time?

System.NullReferenceException: 'Object reference not set to an instance of an object.' lineDetector.<Field at offset 0x00000008> was null.

Windows 10
CUDA 8.0
cuDNN 9.1
nvidia driver 442.19
.NET Core 2.2.102

I've tried to implement this repository but I get the next error while running the code. It does initialize and creates the output folders but does not start the footage processing.

Tried to debug it and run it in different CPU settings but did not manage to make it work

Hope you can help me

Issue

Unable to load DLL 'yolo_cpp_dll_gpu'

Good morning,

When attempting to add GPU support following the guide given, and installing all of the necessary tools, I get the following error. I copied the dll per the guide into the output directory of my program, so it is alongside the exe.

02:11:28.992 ERR >> [WebServer] [1xgT3lLQekmWySVa4MN5ow] Unhandled exception.
$type : System.TypeInitializationException
TypeName : Program
TargetSite : Void MoveNext()
StackTrace :
at EmbedIO.WebApi.WebApiModuleBase.SerializeResultAsync[TResult](IHttpContext context, Task1 task) at EmbedIO.Routing.RouteResolverBase1.ResolveAsync(IHttpContext context)
at EmbedIO.Routing.RouteResolverCollectionBase2.ResolveAsync(IHttpContext context) at EmbedIO.Routing.RoutingModuleBase.OnRequestAsync(IHttpContext context) at EmbedIO.WebModuleBase.HandleRequestAsync(IHttpContext context) at EmbedIO.ExceptionHandler.Handle(String logSource, IHttpContext context, Exception exception, ExceptionHandlerCallback handler, HttpExceptionHandlerCallback httpHandler) at EmbedIO.WebModuleBase.HandleRequestAsync(IHttpContext context) at EmbedIO.Internal.WebModuleCollection.DispatchRequestAsync(IHttpContext context) at EmbedIO.WebServerBase1.DoHandleContextAsync(IHttpContextImpl context)
Message : The type initializer for 'CaptchaAssasin.Program' threw an exception.
InnerException : object
$type : System.DllNotFoundException
Message :
Unable to load DLL 'yolo_cpp_dll_gpu' or one of its dependencies: The specified module could not be found. (0x8007007E)
TypeName :
TargetSite : Int32 GetDeviceCount()
StackTrace :
at Alturos.Yolo.YoloWrapper.GetDeviceCount()
at Alturos.Yolo.YoloWrapper.Initialize(String configurationFilename, String weightsFilename, String namesFilename, GpuConfig gpuConfig)
at Alturos.Yolo.YoloWrapper..ctor(String configurationFilename, String weightsFilename, String namesFilename, GpuConfig gpuConfig, IYoloSystemValidator yoloSystemValidator)
at CaptchaAssasin.Program..cctor() in C:\Users\Drew\RiderProjects\Test\Program.cs:line 13
Source : Alturos.Yolo
HResult : -2146233052
Source : Program
HResult : -2146233036

Error : Unable to load DLL 'x64\yolo_cpp_dll_gpu_lt.dll'

Win 10 1803
VS 2017 + ( C++ 2015.3 v140 toolset)
CUDA 9.1 , cuDNN 8.0 , Nvidia driver 441.22
.NET Core 2.2

I compiled this great project without any error , but I get this error when running :

System.DllNotFoundException: 'Unable to load DLL 'x64\yolo_cpp_dll_gpu_lt.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

tried Debug/Release , AnyCPU / x64

Please look at this image :

Error

missing dll \src\VAP\YoloWrapper\Dependencies\opencv_world340d.dll

error code: MSB3030 โ€œD:\Source Root\RVAP\src\VAP\YoloWrapper\Dependencies\opencv_world340d.dllโ€๏ผŒmissing. YoloWrapper D:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 5100

Need help to find a copy of opencv_world340d.dll.

error: (-2) GStreamer: your gstreamer installation is missing a required plugin

OpenCV(3.4.1) Error: Unspecified error (GStreamer: your gstreamer installation is missing a required plugin
) in handlemessage, file /opencv/modules/videoio/src/cap_gstreamer.cpp, line 1869
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

OpenCV(3.4.1) /opencv/modules/videoio/src/cap_gstreamer.cpp:1869: error: (-2) GStreamer: your gstreamer installation is missing a required plugin
in function handlemessage

Please do help me out what am I missing.

Defining multiple lines

Hello, I'm trying to define multiple lines in the configuration file but, it seems like it only reads the first line and if I define more that one line it throws an out of index error, like below(I was wondering shouldn't 05 be i7 or something like that because each line has 7 arguments and i is keeping track of each line?) I also attached the conf file that I'm using in which I have defined two lines.
image
Here is the conf file I'm using
image
Would you please help me with how I can define multiple lines?

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.