I’m deploying a custom-trained YOLOv7-tiny (2 classes: animal, person) on AMB82-Mini (RTL8735B), and getting the “ghost boxes clustered at top-left” issue described in thread #4667:
I have systematically isolated the problem to the Acuity .nb conversion step. Everything before conversion is verified working:
My reparameterized model (best_reparam.pt) tested in PyTorch with detect.py: detects correctly, boxes on the right objects with correct labels. So training and reparameterization are correct.
Detect.forward() modified per the docs to output raw [bs,255,H,W] layout (sigmoid only, no grid/stride decode).
THE PROBLEM (only appears after conversion)
Converted .nb (uint8): loads fine (no “nn open fail”), runs, but ALL bounding boxes cluster at the top-left corner regardless of image content. Real objects in the frame are not detected. ~14 phantom detections per frame at duplicated coordinates. This is identical to thread #4667.
int16 attempt: fails to load on the board with:
“vip_create_buffer_from_handle fail, buffer size is bigger than handle size. 0xfd800 > 0x7ec00”
(int16 model is ~9.8MB, appears too large for the NN memory region.)
ONNX export environment: PyTorch 2.11.0+cu128, numpy 2.3.5, onnx 1.22.0.
Note: I had to use torch.onnx.export with dynamo=False (legacy exporter), because torch 2.11’s default dynamo exporter fails on this model.
Reparam: reparam_yolov7-tiny.py from Yolov7_reparam_scripts, nc set to 2 in yolov7-tiny-deploy.yaml.
inputmeta: scale 0.00392157, reverse_channel false, mean [0,0,0]
Quantization: uint8, asymmetric_affine, 10 calibration images from my dataset.
Since the model is verified correct before conversion and only the .nb shows ghost boxes, what in the conversion/export environment causes this top-left coordinate shift for a 2-class model?
Is there a specific PyTorch / ONNX / numpy version combination required for the ONNX export? (Thread #4667’s working environment used numpy 2.2.6 / onnx 1.20.0 for export.)
Could the dynamo=False legacy ONNX export be the cause, and if so, what is the recommended export method for newer PyTorch?
Thread #4667 was resolved via the Docker toolkit, but I am already using the official Docker toolkit image and still see the issue. Is there an updated image or a known fix?
I can share the ONNX file, the inputmeta yml, or the full conversion logs if helpful. Thank you.
NNWIDTH / NNHEIGHT: confirmed both are 416 in the sketch, matching the model input size (416x416).
2/3. Understood regarding the ONNX export. My export environment was newer than yolov7/requirements.txt — I used PyTorch 2.11 + numpy 2.3.5 with torch.onnx.export(dynamo=False), because my GPU (RTX 5060 Ti / Blackwell) requires newer PyTorch to run. I will re-export the ONNX in a separate CPU-only environment that matches yolov7/requirements.txt (older torch / numpy / onnx), then re-convert and report back.
Understood that 6.18.8 is the latest toolkit.
Sharing my files for reference:
ONNX model (too large for the 10 MB forum limit, shared via Google Drive):
My export command:
python export.py --weights best_reparam.pt --simplify --img-size 416 416
(with dynamo=False added to the torch.onnx.export call in export.py, required for torch 2.11)
I will report back after re-exporting with the older versions. Thank
I re-exported the ONNX in a clean environment matching yolov7/requirements.txt (torch 2.2.0, numpy 1.26.4, onnx 1.22, no dynamo). I compared it against my original torch 2.11 export:
The two ONNX files are operationally identical, so the export environment/torch version does not appear to be the cause of the ghost boxes.
Since the reparameterized model detects correctly in PyTorch, and the ONNX is verified correct, the issue appears to be in the Acuity conversion (import/quantize/export) itself. Could you please try converting my ONNX (shared above) on your end and check whether the resulting .nb produces the same top-left ghost boxes? That would confirm whether it’s the conversion step. Thank you.
Thanks for providing your .onnx model and I have converted it into .nb using Ameba Offline Model Conversion Docker toolkit. Upon testing, I did not observe any ghost boxes and the model seems to work pretty well on recognising a person.