Closed chandan-labelfuse closed 1 year ago
I am trying to run similar way, as follows, and getting mAP as 0. let me know if anyone have got it working.
import torch
import numpy as np
from tqdm import tqdm
from super_gradients.training import models
from super_gradients.training.metrics import IoU, DetectionMetrics_050, DetectionMetrics_075, DetectionMetrics_050_095
from super_gradients.training import dataloaders
from super_gradients.training.models.detection_models.yolo_base import YoloPostPredictionCallback
from super_gradients.training.models.detection_models.pp_yolo_e import PPYoloEPostPredictionCallback
device = torch.device("cuda")
# post_prediction_callback = YoloPostPredictionCallback(conf=0.001, iou=0.6) #yolox
# post_prediction_callback = PPYoloEPostPredictionCallback(score_threshold=0.001, nms_threshold=0.7, nms_top_k=1000, max_predictions=300)
batch_size = 64
data_dir = "/datasets/coco2017"
# train_dataloader = dataloaders.get(name='coco2017_train',
# dataset_params={"data_dir": data_dir},
# dataloader_params={'num_workers': 2, "batch_size": batch_size}
# )
val_dataloader = dataloaders.get(name='coco2017_val',
dataset_params={"data_dir": data_dir},
dataloader_params={'num_workers': 2, "batch_size": batch_size}
)
model_name = "yolo_nas_s" # "yolo_nas_s" yolox_s
model = models.get(model_name, pretrained_weights="coco", num_classes=80)
model.to(device)
post_prediction_callback = model.get_post_prediction_callback(conf=0.1, iou=0.3)
met = DetectionMetrics_050(num_cls=80, post_prediction_callback=post_prediction_callback)
data_loader_itr = iter(val_dataloader)
c, limit = 0, 7000
model.eval()
with torch.no_grad():
for batch_idx, batch_items in enumerate(tqdm(data_loader_itr)):
imgs, targets = batch_items[0].to(device), batch_items[1].to(device)
c += 1
if c >= limit: break
raw_output = model(imgs)
met.update(preds=raw_output, target=targets, device=device, inputs=imgs)
# map_result = met.compute()
# print(f"{batch_idx} map_result: {map_result}")
map_result = met.compute()
print(f"map_result: {map_result}")
I managed to resolve it by going through the docs and replicating the postprocessing steps.
Hi,
Can you share those steps?
Thanks
On Sat, May 20, 2023, 23:13 chandan-labelfuse @.***> wrote:
I managed to resolve it by going through the docs and replicating the postprocessing steps.
— Reply to this email directly, view it on GitHub https://github.com/Deci-AI/super-gradients/issues/1042#issuecomment-1555959843, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6LQPBJ3KJYPTXMFXXQNETXHD7FDANCNFSM6AAAAAAYH5CSRM . You are receiving this because you commented.Message ID: @.***>
I was able to run it.
import torch
import numpy as np
from tqdm import tqdm
from super_gradients.training import models
from super_gradients.training.metrics import IoU, DetectionMetrics_050, DetectionMetrics_075, DetectionMetrics_050_095
from super_gradients.training.transforms.transforms import *
from super_gradients.training.datasets.data_formats.default_formats import XYXY_LABEL, LABEL_CXCYWH
from super_gradients.training import dataloaders
from super_gradients.training.models.detection_models.pp_yolo_e import PPYoloEPostPredictionCallback
device = torch.device("cuda")
post_prediction_callback = PPYoloEPostPredictionCallback(score_threshold=0.01, nms_threshold=0.7, nms_top_k=1000, max_predictions=300)
data_dir = "/datasets/coco2017"
val_dataloader = dataloaders.coco2017_val_yolo_nas()
model_name = "yolo_nas_s"
model = models.get(model_name, pretrained_weights="coco", num_classes=80)
model.to(device)
# normalize_targets=True, is very important parameter here.
met = DetectionMetrics_050(score_thres=0.01, top_k_predictions=300, num_cls=80, normalize_targets=True, post_prediction_callback=post_prediction_callback)
data_loader_itr = iter(val_dataloader)
model.eval()
with torch.no_grad():
for batch_idx, batch_items in enumerate(tqdm(data_loader_itr)):
# print(f'{batch_idx}, {len(batch_items)}')
imgs, targets = batch_items[0].to(device), batch_items[1].to(device)
raw_output = model(imgs)
met.update(preds=raw_output, target=targets, device=device, inputs=imgs)
map_result = met.compute()
# print(f"{batch_idx} map_result: {map_result}")
map_result = met.compute()
print(f"map_result: {map_result}")
I managed to resolve it by going through the docs and replicating the postprocessing steps.
Can you show your code? I have similar problem.
💡 Your Question
I have converted the yolo-nas model to onnx using the official script and launched it in Triton Inference server.
It loads as expected and gives the inference results as two outputs, one with shape of (1, 8400, 80) and other with the shape of (1, 8400, 4) which I assume the shapes of scores and boxes respectively.
My question is regarding processing these outputs. I have tried
get_post_prediction_callback
to postprocess these output but the resulting predictions seems to be inaccurate. I am not sure if I am doing something wrong. Any guidance in postprocessing the outputs from Triton inference server is really appreciated.
Versions
PyTorch version: 1.13.1+cu117 Is debug build: False CUDA used to build PyTorch: 11.7 ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.2 LTS (x86_64) GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0 Clang version: Could not collect CMake version: Could not collect Libc version: glibc-2.35
Python version: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (64-bit runtime) Python platform: Linux-5.15.0-1031-aws-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: Tesla V100-SXM2-16GB Nvidia driver version: 530.30.02 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True
CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz CPU family: 6 Model: 79 Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1 Stepping: 1 CPU max MHz: 3000.0000 CPU min MHz: 1200.0000 BogoMIPS: 4600.02 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx xsaveopt Hypervisor vendor: Xen Virtualization type: full L1d cache: 128 KiB (4 instances) L1i cache: 128 KiB (4 instances) L2 cache: 1 MiB (4 instances) L3 cache: 45 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-7 Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported Vulnerability L1tf: Mitigation; PTE Inversion Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown Vulnerability Retbleed: Not affected Vulnerability Spec store bypass: Vulnerable Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Versions of relevant libraries: [pip3] numpy==1.23.0 [pip3] torch==1.13.1 [pip3] torchmetrics==0.8.0 [pip3] torchvision==0.14.1 [pip3] triton==2.0.0 [pip3] tritonclient==2.33.0