Deci-AI / super-gradients

Easily train or fine-tune SOTA computer vision models with one open source training library. The home of Yolo-NAS.
https://www.supergradients.com
Apache License 2.0
4.53k stars 493 forks source link

ClassBalancedSampler parameter error #2045

Open anusreedivakaran1 opened 3 weeks ago

anusreedivakaran1 commented 3 weeks ago

πŸ› Describe the bug

I was trying to add ClassBalancedSampler in train dataloader_params. Here is how I used the ClassBalancedSampler:

train_data = coco_detection_yolo_format_train(
    dataset_params={
        'data_dir': dataset_params['data_dir'],
        'images_dir': dataset_params['train_images_dir'],
        'labels_dir': dataset_params['train_labels_dir'],
        'classes': dataset_params['classes'],
        'input_dim': [640, 640]
    },
    dataloader_params={
        'batch_size':BATCH_SIZE,
        'num_workers':WORKERS,
        "sampler":{
            "ClassBalancedSampler":{
                "oversample_threshold": None, 
                "oversample_aggressiveness": 0.5
                }
            }
    }
)

But I am getting this error,

The console stream is logged into /home/user/sg_logs/console.log
[2024-08-22 17:11:44] INFO - crash_tips_setup.py - Crash tips is enabled. You can set your environment variable to CRASH_HANDLER=FALSE to disable it
[2024-08-22 17:11:48] INFO - detection_dataset.py - Dataset Initialization in progress. `cache_annotations=True` causes the process to take longer due to full dataset i
ndexing.
Indexing dataset annotations: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 436727/436727 [00:41<00:00, 10505.81it/s]
Traceback (most recent call last):
  File "/home/user/bahrain_poc/model_training/nas_s_25_training.py", line 52, in <module>
    train_data = coco_detection_yolo_format_train(
  File "/home/user/atcc/nas_env/lib/python3.10/site-packages/super_gradients/training/dataloaders/dataloaders.py", line 351, in coco_detection_yolo_format_train
    return get_data_loader(
  File "/home/user/atcc/nas_env/lib/python3.10/site-packages/super_gradients/training/dataloaders/dataloaders.py", line 86, in get_data_loader
    dataloader_params = _process_dataloader_params(cfg, dataloader_params, dataset, train)
  File "/home/user/atcc/nas_env/lib/python3.10/site-packages/super_gradients/training/dataloaders/dataloaders.py", line 145, in _process_dataloader_params
    dataloader_params = _process_sampler_params(dataloader_params, dataset, default_dataloader_params)
  File "/home/user/atcc/nas_env/lib/python3.10/site-packages/super_gradients/training/dataloaders/dataloaders.py", line 169, in _process_sampler_params
    dataloader_params = _instantiate_sampler(dataset, dataloader_params)
  File "/home/user/atcc/nas_env/lib/python3.10/site-packages/super_gradients/training/dataloaders/dataloaders.py", line 212, in _instantiate_sampler
    dataloader_params["sampler"] = SamplersFactory().get(dataloader_params["sampler"])  # a living object
  File "/home/user/atcc/nas_env/lib/python3.10/site-packages/super_gradients/common/factories/base_factory.py", line 66, in get
    return self.type_dict[_type](**_params)
TypeError: ClassBalancedSampler.__init__() got an unexpected keyword argument 'shuffle'

How do I resolve this issue?

Versions

PyTorch version: 2.4.0+cu121 Is debug build: False CUDA used to build PyTorch: 12.1 ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: Could not collect CMake version: version 3.29.6 Libc version: glibc-2.35

Python version: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-6.5.0-45-generic-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: 12.5.82 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA RTX A6000 GPU 1: NVIDIA RTX A6000

Nvidia driver version: 555.42.06 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.2.1 /usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.2.1 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: 48 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 48 On-line CPU(s) list: 0-47 Vendor ID: AuthenticAMD Model name: AMD Ryzen Threadripper PRO 5965WX 24-Cores CPU family: 25 Model: 8 Thread(s) per core: 2 Core(s) per socket: 24 Socket(s): 1 Stepping: 2 Frequency boost: enabled CPU max MHz: 7021.0928 CPU min MHz: 1800.0000 BogoMIPS: 7586.09 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 mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin brs arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm Virtualization: AMD-V L1d cache: 768 KiB (24 instances) L1i cache: 768 KiB (24 instances) L2 cache: 12 MiB (24 instances) L3 cache: 128 MiB (4 instances) NUMA node(s): 1 NUMA node0 CPU(s): 0-47 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Mitigation; Safe RET Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines; IBPB conditional; IBRS_FW; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] numpy==1.23.0 [pip3] onnx==1.15.0 [pip3] onnx-simplifier==0.4.36 [pip3] onnxruntime==1.15.0 [pip3] onnxsim==0.4.36 [pip3] pytorch-quantization==2.2.1 [pip3] torch==2.4.0 [pip3] torchmetrics==0.8.0 [pip3] torchvision==0.19.0 [pip3] triton==3.0.0 [conda] Could not collect

aravind-trois commented 2 weeks ago

I too had the same issue, @BloodAxe any solution???