OpenGVLab / InternImage

[CVPR 2023 Highlight] InternImage: Exploring Large-Scale Vision Foundation Models with Deformable Convolutions
https://arxiv.org/abs/2211.05778
MIT License
2.52k stars 234 forks source link

[Solved] Can't you infer the image file itself from the inference_detector function? #175

Closed jeonga0303 closed 1 year ago

jeonga0303 commented 1 year ago

First of all, you can use the following methods to infer. image = PIL.Image.open(image) image = np.array(image) result = inference_detector(model, image)

However, it results in a different result than when inferred through the file path and when the image is inserted. Correct results appear when inferring from file path

The reason is that when inferring the image file itself, the preprocessing process must be performed manually.

image

So I implemented the pre-processing code myself. transforms.Methods such as Compose are not supported in the mmcv subversion.

But now it's a problem. After implementing preprocessing similarly, I put a value in the function and found the following error.

image

TypeError: expected str, bytes or os.PathLike object, not Tensor

Do you know how to infer images themselves? Pre-processing must be included. Please provide the sample code at least.

chungminho1 commented 1 year ago

Excuse me, did you use "init_detector" when building model? I'm also trying to use inference_detector, but I met keyerror.

jeonga0303 commented 1 year ago

죄송하지만 모델 빌드는 init_detector 사용하셨나요? 저는 거기부터 막혀서ㅠㅠ

음,, internimage 모델 사용하실거면 internimage 레포지토리 중 detection 폴더가 있어야합니다 하위 폴더 중 configs, mmcv_custom, mmdet_custom, ops_dcnv3, tools는 무조건 있어야돼요 그리고 docker로 python랑 mmcv 환경 조성하시고, ops_dcnv3 이용해서 DCNv3 모듈 설치 된 환경이어야해요

init_detector 사용해서 inference 하실 때는 이런식으로 진행하시면 됩니다~ 문제없이 잘 작동해요

image
chungminho1 commented 1 year ago

감사합니다!!

jeonga0303 commented 1 year ago

This issue has been resolved.

To infer the image itself, you can preprocess it as follows. image = mmcv.imread('xxxx.jpg')

The results are the same as when deducing by file path.

And if you want to deduce using a byte-type image, please refer to the following. image = mmcv.imfrombytes(image, flag='color' image = mmcv.imread(image)