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.
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 following command to run the project:
# for Linux/macOS:
./gradlew run
# for Windows:
..\gradlew build
This will take the 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:
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
.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。