grimoire / mmdetection-to-tensorrt

convert mmdetection model to tensorrt, support fp16, int8, batch input, dynamic shape etc.
Apache License 2.0
581 stars 84 forks source link

Can not load dataset from config. Use default CLASSES instead. #104

Open azuryl opened 2 years ago

azuryl commented 2 years ago

where can get MSKRCNN config file if I use mmdet config file then mmdet2trt init_trt_model....... [01/27/2022-14:52:30] [TRT] [W] TensorRT was linked against cuBLAS/cuBLAS LT 10.2.3 but loaded cuBLAS/cuBLAS LT 10.2.2 [01/27/2022-14:52:30] [TRT] [W] TensorRT was linked against cuBLAS/cuBLAS LT 10.2.3 but loaded cuBLAS/cuBLAS LT 10.2.2 inference.py get_classes_from_config....... Can not load dataset from config. Use default CLASSES instead.

grimoire commented 2 years ago

This error can be ignored by setting the class name in https://github.com/grimoire/mmdetection-to-tensorrt/blob/5352f1568e71cb0b5f187211a0d92fe0dc570756/mmdet2trt/apis/inference.py#L62 .

azuryl commented 2 years ago

This error can be ignored by setting the class name in

https://github.com/grimoire/mmdetection-to-tensorrt/blob/5352f1568e71cb0b5f187211a0d92fe0dc570756/mmdet2trt/apis/inference.py#L62 . @grimoire Dear yes I modified this section according to you suggestion

def get_classes_from_config(model_cfg): model_cfg_str = model_cfg if isinstance(model_cfg, str): model_cfg = mmcv.Config.fromfile(model_cfg) print("#####mmdet2trt/apis/inference.py get_classes_from_config.......",model_cfg) from mmdet.datasets import DATASETS, build_dataset

try:
   dataset = build_dataset(model_cfg)

   return dataset.CLASSES

except Exception:
    logger.warning(
        'inference.py Can not load dataset from config. Use default CLASSES instead.')
    classes =['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
    return classes
azuryl commented 2 years ago

This error can be ignored by setting the class name in

https://github.com/grimoire/mmdetection-to-tensorrt/blob/5352f1568e71cb0b5f187211a0d92fe0dc570756/mmdet2trt/apis/inference.py#L62 .

I convert MASK RCNN R-50-FPN |pytorch from https://github.com/open-mmlab/mmdetection/tree/master/configs/mask_rcnn

but there are another issue in https://github.com/grimoire/mmdetection-to-tensorrt/blob/5352f1568e71cb0b5f187211a0d92fe0dc570756/mmdet2trt/apis/inference.py#L144 the output is Zero

#################model: TRTModule() TRT infer.................. forward!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! dets: tensor([], device='cuda:0', size=(0, 5)) labels: tensor([], device='cuda:0') ^^^^^^^dets_results: [array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32), array([], shape=(0, 5), dtype=float32)] ###############result: