open-mmlab / mmdeploy

OpenMMLab Model Deployment Framework

Home Page:https://mmdeploy.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] mmaction input do not support np array

northagain opened this issue · comments

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

def create_input(self,
                 imgs: Union[str, np.ndarray],
                 input_shape: Sequence[int] = None,
                 data_preprocessor: Optional[BaseDataPreprocessor] = None)\
        -> Tuple[Dict, torch.Tensor]:
    """Create input for video recognition.

    Args:
        **imgs (str | np.ndarray): Input image(s), accepted data type are
            `str`, `np.ndarray`.**
        input_shape (list[int]): A list of two integer in (width, height)
            format specifying input shape. Defaults to `None`.

    Returns:
        tuple: (data, img), meta information for the input image and input.
    """
    **if isinstance(imgs, (list, tuple)):
        if not all(isinstance(img, str) for img in imgs):
            raise AssertionError('imgs must be strings')
    elif isinstance(imgs, str):
        imgs = [imgs]
    else:
        raise AssertionError('imgs must be strings')**

    from mmcv.transforms.wrappers import Compose
    model_cfg = process_model_config(self.model_cfg, imgs, input_shape)
    test_pipeline = Compose(model_cfg.test_pipeline)

    data = []
    for img in imgs:
        data_ = dict(filename=img, label=-1, start_index=0, modality='RGB')
        data_ = test_pipeline(data_)
        data.append(data_)

    data = pseudo_collate(data)
    if data_preprocessor is not None:
        data = data_preprocessor(data, False)
        return data, data['inputs']
    else:
        return data, BaseTask.get_tensor_from_input(data)

It says accepted data type are str, np.ndarray, however the instance check says 'imgs must be strings'

Reproduction

just running mmaction inference

Environment

mmdeploy latest dokcer

Error traceback

No response