neuralmagic / deepsparse

Sparsity-aware deep learning inference runtime for CPUs
https://neuralmagic.com/deepsparse/
Other
3.03k stars 173 forks source link

onxx give the wrong inference #1660

Closed AJITKUMAR130012 closed 3 months ago

AJITKUMAR130012 commented 3 months ago

Describe the bug I have trained my model on the custom dataset. So I have fiexed number of class {Bus, Car Cycle, Cycle-Rickshaw, Goods-Auto Mini-Truck, Motorcycle, Passengers-Auto, Person, Truck]. In th ".pt" format result is fine. But after converting to the onxx format. It predict the label based on the original data.yml file. As example , in my data.yml file "person" is present at the location 8 but in the original cocodata.yml file "boat" is present at this location. So while the inferencing on the vedio by the onnx format, it predict person as boat?

Expected behavior For the "Person", it should predict as the "Person", But is predict the boat

Environment Include all relevant environment information:

  1. OS [e.g. Ubuntu 22.04]:
  2. Python version [e.g. 3.9.13]:
  3. DeepSparse version or commit hash [e.g. 0.1.0, f7245c8]:
  4. ML framework version(s) [e.g. torch 1.7.1]:
  5. Other Python package versions [e.g. SparseML, Sparsify, numpy, ONNX]:
  6. CPU info - output of deepsparse/src/deepsparse/arch.bin or output of cpu_architecture() as follows:
    >>> import deepsparse.cpu
    >>> print(deepsparse.cpu.cpu_architecture())

To Reproduce Exact steps to reproduce the behavior:

Errors If applicable, add a full print-out of any errors or exceptions that are raised or include screenshots to help explain your problem.

Additional context Add any other context about the problem here. Also include any relevant files.

Please help me in this regard, I am using below code

import os import time st=time.time() model_path="traffic_best.onnx" output_path="out" cmd=["deepsparse.yolov8.annotate", "--source", "People2.mp4", "--model_filepath", str(model_path), "--save_dir", output_path] cmd = ' '.join(cmd) os.system(cmd) ed=time.time() print(ed-st)

AJITKUMAR130012 commented 3 months ago

It is resolved by changing the content of coco_classes.py

This file is present on the below path.

./Deepspare/venv/lib/python3.9/site-packages/deepsparse/yolo/utils/coco_classes.py