1 Star 0 Fork 3

CV爱好者/djl-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github/workflows
android
apache-beam/ctr-prediction
apache-flink
apache-kafka
apache-spark
aws
camel-djl
canary
docs
footwear_classification
graalvm
gradle/wrapper
live-object-detection
malicious-url-detector
module
multi-engine
src
README.md
build.gradle
gradle
gradlew
performance_numbers.md
settings.gradle
pneumonia-detection
quarkus
tools/gradle
visualization-vue
web-demo
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
NOTICE
README.md
gradlew
gradlew.bat
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

MultiEngine on DJL

This is an example of how to run multiple engines in one Java process using DJL.

Why is it good to be able to run multiple engines in one Java process?

Many deep learning frameworks have their individual strength and weaknesses when doing training/inference on different models. Some frameworks run certain models faster and being able to switch between what engines to use on what models gives the benefits of being able to utilize the strengths of each engine.

This example uses an image of soccer players, puts that through a PyTorch model to do object detection to get a player from the image, then feeds that resulting image to an MXNet model to do pose estimation.

Note: Loading multiple deep learning engines will cause OpenMP to load multiple times, which may cause a slowdown or memory errors to occur. Here are the results of a few simple benchmarks that we ran.

Setup

Go into the multi-engine directory and run the following command to build the project:

cd multi-engine

# for Linux/macOS:
./gradlew build

# for Windows:
..\gradlew build

Run the MultiEngine Program

Run the following command to run the project:

# for Linux/macOS:
./gradlew run

# for Windows:
..\gradlew build

This will take the original image:

Original Image

Use a object detection PyTorch model to extract the player and pass the result through an MXNet model to do pose estimation and give us the final image with the joints marked as shown below:

Pose Estimation

Configurations and the Code

Code

The main code loads the image in and calls the detectPersonWithPyTorchModel method where it will load in the PyTorch model based on the filter parameters and detect a person from the image. It will then crop the image where the person was detected and return that image.

Once we have the image of the person, we pass it to the next method detectJointsWithMxnetModel method where it loads the MxNet Model from model zoo based on the filter parameters to do joint detection on the image of the person. It will then output the result of the joints image to build/output.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/cvfan/djl-demo.git
git@gitee.com:cvfan/djl-demo.git
cvfan
djl-demo
djl-demo
master

搜索帮助

371d5123 14472233 46e8bd33 14472233