Git Product home page Git Product logo

automl-video-ondevice's Introduction

AutoML Video Edge Library

AutoML Video Edge Library is an open source engine used for inferencing models trained using AutoML Video. It supports running Tensorflow, TF-TRT, TFLite, and EdgeTPU-optimized TFLite models.

I'm Developing For:

For Linux Desktop


If you are looking to do inferencing with no additional hardware, using only CPU then you may use the vanilla Tensorflow (.pb) and TFLite (.tflite) models.

Prerequisites

sudo apt-get update
sudo apt-get install python3.7
sudo apt-get install python3-pip
pip3 install opencv-contrib-python --user
pip3 install numpy

Note: opencv-contrib-python is only necessary for the examples, but can be excluded if only the library is being used.

If you plan on running TFLite models on the desktop, install the TFLite interpreter: https://www.tensorflow.org/lite/guide/python

If you plan on running Tensorflow models on desktop:
pip3 install tensorflow==1.14

Get the Code

git clone https://github.com/google/automl-video-ondevice

After that is done downloading, move into the directory.
cd automl-video-ondevice

Running an Example

For TFLite:
python3 examples/video_file_demo.py --model=data/traffic_model.tflite

For Tensorflow:
python3 examples/video_file_demo.py --model=data/traffic_model.pb

For Coral Device


Prerequisites

Make sure you've setup your coral device: https://coral.ai/docs/setup

Install the TFLite runtime on your device: https://www.tensorflow.org/lite/guide/python

sudo apt-get update
sudo apt-get install git
sudo apt-get install python3-opencv
pip3 install numpy

Get the Code

git clone https://github.com/google/automl-video-ondevice

After that is done downloading, move into the directory.
cd automl-video-ondevice

Running an Example

python3 examples/video_file_demo.py --model=data/traffic_model_edgetpu.tflite

For NVIDIA Jetson


Prerequisites

sudo apt-get update
sudo apt-get install git
sudo apt-get install python3.7-pip
sudo apt-get install python3-opencv
sudo apt-get install protobuf-compiler libprotoc-dev
sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
pip3 install cython numpy
pip3 install --no-cache-dir --ignore-installed --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 'tensorflow<2'

git clone https://github.com/NVIDIA/TensorRT.git 
cd oss/tools/onnx-graphsurgeon
make install

pip3 install --ignore-installed git+https://github.com/onnx/tensorflow-onnx

Get the Code

git clone https://github.com/google/automl-video-ondevice

After that is done downloading, move into the directory.
cd automl-video-ondevice

Run a TensorFlow-TensorRT Example

python3 examples/video_file_demo.py --model=data/traffic_model_trt.pb

Run a TensorRT Example

For TensorRT, the chip Engines converted with must be the same kind of chip to run inference workflow on. We hereby convert a TensorRT Engine on the Nano Platform. Later on, we hope to export the onnx model from Cloud console to hide the onnx converting steps from users.

First convert the model to ONNX format, use the model downloaded from GCP Video Intelligence console: python3 -m tf2onnx.convert --graphdef frozen_inference_graph.pb --inputs image_tensor:0 --outputs detection_boxes:0,detection_classes:0,detection_scores:0,num_detections:0 --output models/model_opset_10.onnx --fold_const --opset 10 --verbose

then, python3 examples/modify_onnx_model_opset10.py --onnx model_opset_10.onnx --modified model_opset_10_modified.onnx

Then convert ONNX graph to a TensorRT Engine file, please note the TensorRT conversion is a memory intensive process so be mindful when running on less powerful device like Nano: /usr/src/tensorrt/bin/trtexec --onnx=model_opset_10_modified.onnx --fp16 --workspace=2048 --allowGPUFallback --saveEngine=vot_fp16.plan --verbose &> trtexec_build.log

The log could be viewed by tail -f trtexec_build.log. The TensorRT Engine file vot_fp16.plan could be deployed to a Deep Stream application.

automl-video-ondevice's People

Contributors

automl-video-robot avatar copybara-service[bot] avatar mengdong avatar qwook avatar yongzhe2160 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

automl-video-ondevice's Issues

Security Policy violation Binary Artifacts

This issue was automatically created by Allstar.

Security Policy Violation
Project is out of compliance with Binary Artifacts policy: binaries present in source code

Rule Description
Binary Artifacts are an increased security risk in your repository. Binary artifacts cannot be reviewed, allowing the introduction of possibly obsolete or maliciously subverted executables. For more information see the Security Scorecards Documentation for Binary Artifacts.

Remediation Steps
To remediate, remove the generated executable artifacts from the repository.

Artifacts Found

  • automl_video_ondevice/object_tracking/mediapipe_tracker/aarch64/mediapipe_tracker.so

Additional Information
This policy is drawn from Security Scorecards, which is a tool that scores a project's adherence to security best practices. You may wish to run a Scorecards scan directly on this repository for more details.


Allstar has been installed on all Google managed GitHub orgs. Policies are gradually being rolled out and enforced by the GOSST and OSPO teams. Learn more at http://go/allstar

This issue will auto resolve when the policy is in compliance.

Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.

RuntimeError: The basic tracker is not publicly available yet,

Trying to use the object tracker in coral_camera_demo.py (--use_tracker=True) and I get the error:

'''
RuntimeError: The basic tracker is not publicly available yet, please reach out to repo maintainers for early access. If this error persists, it may mean your CPU architecture is not yet supported.
'''

Notes - this is with Raspberry Pi 4 and Coral USB

Cant run Jetson example - TRT segment could not be empty

I am trying to run the Jetson example with my webcam (which I have verified is in /dev/video2), and I get the following error:

python3 examples/jetson_camera_demo.py --video_device 2

`Loading data/traffic_model_tftrt.pb with data/traffic_label_map.pbtxt labels.
Loading: data/traffic_model_tftrt.pb <Format.TENSORFLOW> data/traffic_label_map.pbtxt
2020-08-16 08:29:02.565609: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.2
WARNING:tensorflow:Deprecation warnings have been disabled. Set TF_ENABLE_DEPRECATION_WARNINGS=1 to re-enable them.
2020-08-16 08:29:08.936702: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libnvinfer.so.7
2020-08-16 08:29:08.940730: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libnvinfer_plugin.so.7
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

Loading an LSTM model.
2020-08-16 08:29:09.942331: W tensorflow/core/platform/profile_utils/cpu_utils.cc:98] Failed to find bogomips in /proc/cpuinfo; cannot determine CPU frequency
2020-08-16 08:29:09.943629: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x2babe200 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-16 08:29:09.943751: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-08-16 08:29:09.948270: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-08-16 08:29:10.035637: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:950] ARM64 does not support NUMA - returning NUMA node zero
2020-08-16 08:29:10.036192: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x27c586a0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-08-16 08:29:10.036301: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Xavier, Compute Capability 7.2
2020-08-16 08:29:10.036969: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:950] ARM64 does not support NUMA - returning NUMA node zero
2020-08-16 08:29:10.037136: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1639] Found device 0 with properties: 
name: Xavier major: 7 minor: 2 memoryClockRate(GHz): 1.109
pciBusID: 0000:00:00.0
2020-08-16 08:29:10.037360: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.2
2020-08-16 08:29:10.037572: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-08-16 08:29:10.037721: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-08-16 08:29:10.038833: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-08-16 08:29:10.042316: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-08-16 08:29:10.044700: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-08-16 08:29:10.044913: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.8
2020-08-16 08:29:10.045253: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:950] ARM64 does not support NUMA - returning NUMA node zero
2020-08-16 08:29:10.045603: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:950] ARM64 does not support NUMA - returning NUMA node zero
2020-08-16 08:29:10.045736: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1767] Adding visible gpu devices: 0
2020-08-16 08:29:10.045955: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.2
2020-08-16 08:29:12.579091: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1180] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-08-16 08:29:12.579227: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1186]      0 
2020-08-16 08:29:12.579295: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1199] 0:   N 
2020-08-16 08:29:12.579898: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:950] ARM64 does not support NUMA - returning NUMA node zero
2020-08-16 08:29:12.580393: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:950] ARM64 does not support NUMA - returning NUMA node zero
2020-08-16 08:29:12.580673: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1325] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 767 MB memory) -> physical GPU (device: 0, name: Xavier, pci bus id: 0000:00:00.0, compute capability: 7.2)
[ WARN:0] global /tmp/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
2020-08-16 08:29:13.931597: E tensorflow/core/common_runtime/executor.cc:648] Executor failed to create kernel. Invalid argument: The TF function for the TRT segment could not be empty
	 [[{{node import/TRTEngineOp_0}}]]
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn
    target_list, run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: The TF function for the TRT segment could not be empty
	 [[{{node import/TRTEngineOp_0}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/jetson_camera_demo.py", line 123, in <module>
    main()
  File "examples/jetson_camera_demo.py", line 102, in main
    if engine.run(timestamp, resized_frame, annotations):
  File "/home/gbenel/automl-video-ondevice/automl_video_ondevice/object_tracking/tf_object_detection.py", line 105, in run
    session_return = self.session.run(self._output_nodes, feed_dict=feed_dict)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 956, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1180, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1359, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1384, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: The TF function for the TRT segment could not be empty
	 [[node import/TRTEngineOp_0 (defined at /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1748) ]]

Original stack trace for 'import/TRTEngineOp_0':
  File "examples/jetson_camera_demo.py", line 123, in <module>
    main()
  File "examples/jetson_camera_demo.py", line 68, in main
    engine = vot.load(args.model, args.labels, config)
  File "/home/gbenel/automl-video-ondevice/automl_video_ondevice/object_tracking/__init__.py", line 68, in load
    config)
  File "/home/gbenel/automl-video-ondevice/automl_video_ondevice/object_tracking/tf_object_detection.py", line 43, in __init__
    self._load_frozen_graph(frozen_graph_path)
  File "/home/gbenel/automl-video-ondevice/automl_video_ondevice/object_tracking/tf_object_detection.py", line 66, in _load_frozen_graph
    if self._is_lstm else []))
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/util/deprecation.py", line 513, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/importer.py", line 405, in import_graph_def
    producer_op_list=producer_op_list)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/importer.py", line 517, in _import_graph_def_internal
    _ProcessNewOps(graph)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/importer.py", line 243, in _ProcessNewOps
    for new_op in graph._add_new_tf_operations(compute_devices=False):  # pylint: disable=protected-access
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 3561, in _add_new_tf_operations
    for c_op in c_api_util.new_tf_operations(self)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 3561, in <listcomp>
    for c_op in c_api_util.new_tf_operations(self)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 3451, in _create_op_from_tf_operation
    ret = Operation(c_op, self)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 1748, in __init__
    self._traceback = tf_stack.extract_stack()
`

How to Build mediapipe_tracker.so

hi , thanks you for your this project, it is useful for me. Could you please tell how to Build mediapipe_tracker.so. Because I want to build other modules in the mediapipe.

Thank you very much.

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.