Megvii-BaseDetection / YOLOX

YOLOX is a high-performance anchor-free YOLO, exceeding yolov3~v5 with MegEngine, ONNX, TensorRT, ncnn, and OpenVINO supported. Documentation: https://yolox.readthedocs.io/
Apache License 2.0
9.4k stars 2.2k forks source link

ImportError: cannot import name 'COCODataset' from 'yolox.data' #426

Open kail85 opened 3 years ago

kail85 commented 3 years ago

in yolox/exp/yolox_base.py, at below line

    def get_data_loader(self, batch_size, is_distributed, no_aug=False):
        from yolox.data import (
            COCODataset,
            TrainTransform,
            YoloBatchSampler,
            DataLoader,
            InfiniteSampler,
            MosaicDetection,
        )

Got an error 'ImportError: cannot import name 'COCODataset' from 'yolox.data''

Also tried

from yolox.data.datasets.coco import COCODataset

also got an error

cannot find module 'yolox.data.datasets.coco'.

Anyone please suggest? Thanks.

CallmeAG commented 1 year ago

I Got this error too. Do you solved it yet?

FateScript commented 1 year ago

I have tried it on my machine and it works.

In [1]: from yolox.data import COCODataset

In [2]: COCODataset?
Init signature: COCODataset(*args, **kwds)
Docstring:      COCO dataset class.
Init docstring:
COCO dataset initialization. Annotation data are read into memory by COCO API.
Args:
    data_dir (str): dataset root directory
    json_file (str): COCO json file name
    name (str): COCO data name (e.g. 'train2017' or 'val2017')
    img_size (int): target image size after pre-processing
    preproc: data augmentation strategy
File:           /data/workspace/YOLOX/yolox/data/datasets/coco.py
Type:           type
Subclasses:

Did you install the package through python3 -m pip install -v -e .?

gyh420 commented 1 year ago

how to fix it?