-
Notifications
You must be signed in to change notification settings - Fork 659
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
TranslatorFactory for yolov8 #2753
Comments
I assume YoloV8TranslatorFactory would be very similar and parallel to YoloV5TranslatorFactory. But the current YoloV5TranslatorFactory is not guaranteed to be used for YoloV8TranslatorFactory out-of-box. But the good news is that as long as YoloV8 has a onnx model, then we can load it into DJL with OnnxRuntime engine. You can maybe take a look at PR #2452 , which contains a simple testing example, and see if you can try to build a YoloV8Translator from YoloV5Translator? |
String onnxFile = "D:\Sidney\dev\ai\action\pp\bestn.onnx";
/////////////////////////////////////////////////////////////////////////////////////////////////////// Loading: 100% |========================================| The probabilities are too big and then get too many boxes(big number return by detectedObjects.getNumberOfObjects() in unexpected), what's the possible cause? python return correct label and boxes as expected for the same model. |
I'm not familiar with yolo5 and yolo8, can help to implement YoloV8Translator.java? Thanks. |
private DetectedObjects processFromBoxOutput(NDList list) {
NDArray features4OneImg = list.get(0);
int sizeClasses = classes.size();
long sizeBoxes = features4OneImg.size(1);
ArrayList<IntermediateResult> intermediateResults = new ArrayList<>();
for (long b = 0; b < sizeBoxes; b++) {
float maxClass = 0;
int maxIndex = 0;
for (int c = 4; c < sizeClasses; c++) {
float classProb = features4OneImg.getFloat(c, b);
if (classProb > maxClass) {
maxClass = classProb;
maxIndex = c;
}
}
if (maxClass > threshold) {
float xPos = features4OneImg.getFloat(0, b);// center x
float yPos = features4OneImg.getFloat(1, b);// center y
float w = features4OneImg.getFloat(2, b);
float h = features4OneImg.getFloat(3, b);
Rectangle rect = new Rectangle(Math.max(0, xPos - w / 2), Math.max(0, yPos - h / 2), w, h);
intermediateResults.add(new IntermediateResult(classes.get(maxIndex), maxClass, maxIndex, rect));
}
}
return nms(intermediateResults);
} yolov8 work after amend this method in YoloV5Translator.java |
Sorry I forgot to check this reply in time.
This is great! It's good to know that yolov8 can resuse the yolov5 Translator in this way. This in principle agrees with our desgin, where the Would you mind contributing this feature to DJL? Basically the PR is gonna contain this code and your testing example, which serves as unit test. |
I had never done a PR in github, I can try if someone guide me, or someone can do a PR to amend only one method in YoloV5Translator.java to get YoloV8Translator.java |
@SidneyLann You can use this chance to give it a try. Just fork the djl repo, create a new branch from the master, and then on github website click into "new pull request". We can help you edit the branch afterwards. You creating the PR makes sure your authorship of the feature. Alternatively, we can create a PR for you too. But could you share the testing code that showcases that the above function works with yolov8? |
I looked into your repo, there is only one branch, "master". The photo above shows that you didn't do any changes yet on this branch, thus "there isn't anything to compare". You can use chatgpt or google to find how to create a new branch locally, named say "feature", and make some changes, push it to your repo. Then in the photo above, intead of "compare: master", you can opt to "compare: feature". Then you will see the file difference, and then you can continue to create a PR. |
Can YoloV5TranslatorFactory.java be used here? Or need to implements YoloV8TranslatorFactory?
Many objects can be detected in python, but no one object can be detected in DJL. problem in YoloV5TranslatorFactory or data preprocess? Thanks.
The text was updated successfully, but these errors were encountered: