Closed jeonga0303 closed 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.
죄송하지만 모델 빌드는 init_detector 사용하셨나요? 저는 거기부터 막혀서ㅠㅠ
음,, internimage 모델 사용하실거면 internimage 레포지토리 중 detection 폴더가 있어야합니다 하위 폴더 중 configs, mmcv_custom, mmdet_custom, ops_dcnv3, tools는 무조건 있어야돼요 그리고 docker로 python랑 mmcv 환경 조성하시고, ops_dcnv3 이용해서 DCNv3 모듈 설치 된 환경이어야해요
init_detector 사용해서 inference 하실 때는 이런식으로 진행하시면 됩니다~ 문제없이 잘 작동해요
감사합니다!!
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)
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.
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.
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.