Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for loading and inferencing on aws-neuron and aws-neuronx #18199

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

takipipo
Copy link

@takipipo takipipo commented Dec 12, 2024

Given that the current Ultralytics does not support AWS-Neuron, AWS-NeuronX, which is one of the unsupported options by Ultralytics, AWS-NeuronX is a cost-effective way to productionize the YOLO models.

Here is the Proposal method for exporting the Ultralytics model to AWS-Neuron.

from ultralytics import NeuronYOLO

model = NeuronYOLO("yolov8n.pt")
model.export(format="neuron")

neuron_model = NeuronYOLO("yolov8n.neuron")
neuron_model.predict("https://ultralytics.com/images/bus.jpg")

Here is the Proposal method for exporting the Ultralytics model to AWS-NeuronX

from ultralytics import NeuronYOLO

model = NeuronYOLO("yolov8n.pt")
model.export(format="neuronx")

neuronx_model = NeuronYOLO("yolov8n.neuronx")
neuronx_model.predict("https://ultralytics.com/images/bus.jpg")

cc: @nirattisai-t @luangtatipsy

takipipo and others added 27 commits June 26, 2024 15:11
fix: NeuronYOLO base class
fix: support python < 3.10
Copy link

sentry-io bot commented Dec 12, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: ultralytics/cfg/init.py

Function Unhandled Issue
check_cfg TypeError: 'epochs=epoch' is of invalid type str. 'epochs' must be an int (i.e. 'epochs=8') ...
Event Count: 4
check_cfg TypeError: 'epochs=50 imgsz=640' is of invalid type str. 'epochs' must be an int (i.e. 'epochs=8') ...
Event Count: 2

Did you find this useful? React with a 👍 or 👎

Copy link

github-actions bot commented Dec 12, 2024


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I sign the CLA


2 out of 3 committers have signed the CLA.
✅ (takipipo)[https://github.com/takipipo]
✅ (UltralyticsAssistant)[https://github.com/UltralyticsAssistant]
@ubuntu
Ubuntu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@takipipo
Copy link
Author

I have read the CLA Document and I sign the CLA

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 7.51534% with 603 lines in your changes missing coverage. Please review.

Project coverage is 71.52%. Comparing base (1cfe60e) to head (2c81115).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ultralytics/nn/neuron_autobackend.py 5.96% 394 Missing ⚠️
ultralytics/engine/neuron_exporter.py 0.00% 186 Missing ⚠️
ultralytics/engine/neuron_predictor.py 0.00% 11 Missing ⚠️
ultralytics/engine/neuron_model.py 50.00% 6 Missing ⚠️
ultralytics/models/yolo/detect/neuron_predict.py 55.55% 4 Missing ⚠️
ultralytics/models/yolo/neuron_model.py 75.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (1cfe60e) and HEAD (2c81115). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (1cfe60e) HEAD (2c81115)
Tests 8 4
Benchmarks 6 3
GPU 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18199      +/-   ##
==========================================
- Coverage   78.52%   71.52%   -7.01%     
==========================================
  Files         128      134       +6     
  Lines       17138    17785     +647     
==========================================
- Hits        13458    12721     -737     
- Misses       3680     5064    +1384     
Flag Coverage Δ
Benchmarks 33.97% <7.51%> (-1.07%) ⬇️
GPU 37.32% <7.51%> (-3.79%) ⬇️
Tests 65.54% <7.51%> (-6.92%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glenn-jocher glenn-jocher self-requested a review December 12, 2024 18:21
Copy link
Member

@ambitious-octopus ambitious-octopus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @takipipo , the AWS-Neuron inference integration you're working on looks very promising. Thank you for your effort and contributions!
That said, the PR requires some adjustments and cleanup to align with our codebase.

  1. Duplicate Code: You've introduced a new exporter.py and autobackend.py, which results in a lot of duplicate code. Instead of creating new files, please integrate your changes into the existing exporter.py and autobackend.py to maintain consistency and reduce redundancy.

  2. NeuronYOLO Model: There’s no need to create a separate NeuronYOLO model for this integration. Both inference and export functionality should be handled within autobackend.py and exporter.py as part of the existing framework.

Unfortunately, I’m unable to test your PR in its current state. Once you've made these changes I’ll take another look.

Thanks again for your contributions!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you simplify the docstrings here?

@@ -614,7 +614,7 @@ def export_mnn(self, prefix=colorstr("MNN:")):

@try_export
def export_ncnn(self, prefix=colorstr("NCNN:")):
"""YOLO NCNN export using PNNX https://github.com/pnnx/pnnx."""
"""YOLOv8 NCNN export using PNNX https://github.com/pnnx/pnnx."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""YOLOv8 NCNN export using PNNX https://github.com/pnnx/pnnx."""
"""YOLO NCNN export using PNNX https://github.com/pnnx/pnnx."""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants