Skip to content
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

TypeError: expected str, bytes or os.PathLike object, not NoneType #1514

Closed
Bananaspirit opened this issue Oct 10, 2023 · 1 comment
Closed
Labels
🐛 Bug Something isn't working

Comments

@Bananaspirit
Copy link

Bananaspirit commented Oct 10, 2023

🐛 Describe the bug

When I try to fill a quantization, my code causes an error:
TypeError: expected str, bytes or os.PathLike object, not NoneType

import os
from super_gradients.training import Trainer
from super_gradients.common.object_names import Models
from super_gradients.training import models
from super_gradients.training.losses import PPYoloELoss
from super_gradients.training.metrics import DetectionMetrics_050
from super_gradients.training.models.detection_models.pp_yolo_e import PPYoloEPostPredictionCallback
from super_gradients.training.datasets.detection_datasets.coco_format_detection import COCOFormatDetectionDataset
from super_gradients.training.transforms.transforms import DetectionMosaic, DetectionRandomAffine, DetectionHSV, \
    DetectionHorizontalFlip, DetectionPaddedRescale, DetectionStandardize, DetectionTargetsFormatTransform
from super_gradients.training.utils.collate_fn.crowd_detection_collate_fn import CrowdDetectionCollateFN
from super_gradients.training.pre_launch_callbacks import modify_params_for_qat
from super_gradients.training.datasets.datasets_utils import worker_init_reset_seed
from super_gradients.training import dataloaders



trainer = Trainer(experiment_name="yolo_nas_s_soccer_players", ckpt_root_dir="/home/banana/Docs/VScode/Python/RSM_projects/Auto_Pilot/Qantization_test/checkpoints")

net = models.get(Models.YOLO_NAS_S, num_classes=26, checkpoint_path="/home/banana/Docs/VScode/Python/RSM_projects/ckpt_best.pth")

train_dataset_params = COCOFormatDetectionDataset(data_dir="/home/banana/Docs/VScode/Python/RSM_projects/Auto_Pilot/Qantization_test/soccer-players-2/",
                                                  images_dir="train",
                                                  json_annotation_file="train/_annotations.coco.json",
                                                  input_dim=(640, 640),
                                                  ignore_empty_annotations=False,
                                                  transforms=[
                                                      DetectionMosaic(prob=1., input_dim=(640, 640)),
                                                      DetectionRandomAffine(degrees=0., scales=(0.5, 1.5), shear=0.,
                                                                            target_size=(640, 640),
                                                                            filter_box_candidates=False,
                                                                            border_value=128),
                                                      DetectionHSV(prob=1., hgain=5, vgain=30, sgain=30),
                                                      DetectionHorizontalFlip(prob=0.5),
                                                      DetectionPaddedRescale(input_dim=(640, 640), max_targets=300),
                                                      DetectionStandardize(max_value=255),
                                                      DetectionTargetsFormatTransform(max_targets=300,
                                                                                      input_dim=(640, 640),
                                                                                      output_format="LABEL_CXCYWH")
                                                  ])

val_dataset_params = COCOFormatDetectionDataset(data_dir="/home/banana/Docs/VScode/Python/RSM_projects/Auto_Pilot/Qantization_test/soccer-players-2/",
                                                images_dir="test",
                                                json_annotation_file="test/_annotations.coco.json",
                                                input_dim=(640, 640),
                                                ignore_empty_annotations=False,
                                                transforms=[
                                                    DetectionPaddedRescale(input_dim=(640, 640), max_targets=300),
                                                    DetectionStandardize(max_value=255),
                                                    DetectionTargetsFormatTransform(max_targets=300,
                                                                                    input_dim=(640, 640),
                                                                                    output_format="LABEL_CXCYWH")
                                                ])

train_dataloader_params = {
    "shuffle": True,
    "batch_size": 16,
    "drop_last": False,
    "pin_memory": True,
    "collate_fn": CrowdDetectionCollateFN(),
    "worker_init_fn": worker_init_reset_seed,
    "min_samples": 512
}

val_dataloader_params = {
    "shuffle": False,
    "batch_size": 32,
    "num_workers": 2,
    "drop_last": False,
    "pin_memory": True,
    "collate_fn": CrowdDetectionCollateFN(),
    "worker_init_fn": worker_init_reset_seed
}

train_params = {
    "warmup_initial_lr": 1e-6,
    "initial_lr": 5e-4,
    "lr_mode": "cosine",
    "cosine_final_lr_ratio": 0.1,
    "optimizer": "AdamW",
    "zero_weight_decay_on_bias_and_bn": True,
    "lr_warmup_epochs": 3,
    "warmup_mode": "linear_epoch_step",
    "optimizer_params": {"weight_decay": 0.0001},
    "ema": True,
    "ema_params": {"decay": 0.9, "decay_type": "threshold"},
    "max_epochs": 10,
    "mixed_precision": True,
    "loss": PPYoloELoss(use_static_assigner=False, num_classes=26, reg_max=16),
    "valid_metrics_list": [
        DetectionMetrics_050(score_thres=0.1, top_k_predictions=300, num_cls=26, normalize_targets=True,
                             post_prediction_callback=PPYoloEPostPredictionCallback(score_threshold=0.01,
                                                                                    nms_top_k=1000, max_predictions=300,
                                                                                    nms_threshold=0.7))],

    "metric_to_watch": '[email protected]'}

train_params, train_dataset_params, val_dataset_params, train_dataloader_params, val_dataloader_params = modify_params_for_qat(
    train_params, train_dataset_params, val_dataset_params, train_dataloader_params, val_dataloader_params)

trainset = train_dataset_params
valset = val_dataset_params


train_loader = dataloaders.get(dataset=trainset,
                               dataloader_params=train_dataloader_params)

valid_loader = dataloaders.get(dataset=valset, dataloader_params=val_dataloader_params)

#print()
#print(val_dataset_params)                       
trainer.qat(model=net, training_params=train_params, train_loader=train_loader, valid_loader=valid_loader, calib_loader=train_loader)

''''''

Complete error:

Traceback (most recent call last):
  File "/home/banana/Docs/VScode/Python/RSM_projects/Auto_Pilot/Qantization_test/main.py", line 112, in <module>
    trainer.qat(model=net, training_params=train_params, train_loader=train_loader, valid_loader=valid_loader, calib_loader=train_loader)
  File "/home/banana/Docs/VScode/Python/RSM_projects/Auto_Pilot/Qantization_test/QAT_TEST/lib/python3.10/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 2433, in qat
    _ = self.ptq(
  File "/home/banana/Docs/VScode/Python/RSM_projects/Auto_Pilot/Qantization_test/QAT_TEST/lib/python3.10/site-packages/super_gradients/training/sg_trainer/sg_trainer.py", line 2562, in ptq
    os.makedirs(self.checkpoints_dir_path, exist_ok=True)
  File "/usr/lib/python3.10/os.py", line 210, in makedirs
    head, tail = path.split(name)
  File "/usr/lib/python3.10/posixpath.py", line 103, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Versions

Collecting environment information...
PyTorch version: 1.11.0+cu113
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A

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

Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.2.0-34-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Архитектура: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Порядок байт: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
ID прроизводителя: GenuineIntel
Имя модели: Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz
Семейство ЦПУ: 6
Модель: 158
Потоков на ядро: 2
Ядер на сокет: 4
Сокетов: 1
Степпинг: 10
CPU max MHz: 4100,0000
CPU min MHz: 800,0000
BogoMIPS: 4800.00
Флаги: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
Виртуализация: VT-x
L1d cache: 128 KiB (4 instances)
L1i cache: 128 KiB (4 instances)
L2 cache: 1 MiB (4 instances)
L3 cache: 8 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-7
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
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; IBRS, IBPB conditional, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Mitigation; Microcode
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] numpy==1.23.0
[pip3] onnx==1.13.0
[pip3] onnx-simplifier==0.4.33
[pip3] onnxruntime==1.13.1
[pip3] pytorch-quantization==2.1.2
[pip3] torch==1.11.0+cu113
[pip3] torchaudio==0.11.0+cu113
[pip3] torchmetrics==0.8.0
[pip3] torchvision==0.12.0+cu113
[conda] Could not collect

@BloodAxe BloodAxe added the 🐛 Bug Something isn't working label Oct 10, 2023
@BloodAxe
Copy link
Contributor

It was fixed in master branch yesterday. You can install SG from git to have the latest changes or wait for next release of SG which should happen somewhere next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants