question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TorchServe KeyError

See original GitHub issue

Discussed in https://github.com/open-mmlab/mmdetection/discussions/9200

<div type='discussions-op-text'>

Originally posted by austinmw October 31, 2022 Hi, I used MMDetection 3.0.0rc2 to train a Deformable DETR model and a Faster RCNN model, and then I used the mmdet2torchserve tool to create two model.mar. I tried testing local deployment with my own TorchServe Dockerfile, but I get errors with both of the TorchServe archives:

KeyError: "class DeformableDETR in mmdet/models/detectors/deformable_detr.py: 'DetDataPreprocessor is not in the model registry. Please check whether the value of DetDataPreprocessor is correct or it was registered as expected.

and

KeyError: "class FasterRCNN in mmdet/models/detectors/faster_rcnn.py: 'DetDataPreprocessor is not in the model registry. Please check whether the value of DetDataPreprocessor is correct or it was registered as expected.

My Dockerfile looks like this:

# Use Sagemaker PyTorch inference container as base image
ARG REGION
FROM 763104351884.dkr.ecr.${REGION}.amazonaws.com/pytorch-inference:1.12.1-gpu-py38-cu113-ubuntu20.04-sagemaker

# Install MMEngine, MMCV, MMDetection
WORKDIR /opt/ml/code
RUN pip install cython nvgpu && \
    pip install -U pip openmim torch-model-archiver && \
    pip install git+https://github.com/open-mmlab/mmengine.git@v0.2.0 && \
    mim install "mmcv>=2.0.0rc2" -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.12.0/index.html && \
    pip install git+https://github.com/open-mmlab/mmdetection.git@v3.0.0rc2 && \
    rm -rf /var/lib/apt/lists/*

COPY config.properties /home/model-server/config.properties

WORKDIR /
ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"]
CMD ["torchserve", "--start", "--ts-config", "/home/model-server/config.properties", "--model-store", "/opt/ml/model"]

I placed the model.mars into /opt/ml/model.

Anyone know how to resolve this KeyError? Is mmdet_handler.py compatible with v3.0.0rc2?

</div>

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
RunningLeoncommented, Nov 16, 2022

@lvhan028 to take look. MMDeploy should already be compatible with mmdet 3.x in mmdeploy 1.x. We just need to have an entry point in mmdet.

Hi, torchserve is not included in mmdeploy. Deployment for torchserve would be kept in mmdet. As for the error, it’s because of the BC-breaking of mmdet2.x and mmdet3.x. A fixing of this would come later.

1reaction
austinmwcommented, Nov 11, 2022

Hi, thanks for response, okay I’ll see if I can get it working for PR, otherwise can wait till official 3.0 release

Read more comments on GitHub >

github_iconTop Results From Across the Web

TorchServe KeyError - open-mmlab/mmdetection - GitHub
I tried testing local deployment with my own TorchServe Dockerfile, but I get errors with both of the TorchServe archives: KeyError: "class DeformableDETR ......
Read more >
KeyError when trying to modify pytorch-example
It seems that most operation are defined on FloatTensor and DoubleTensor (source), and your model gets a ByteTensor in model(data) .
Read more >
2. Troubleshooting Guide - PyTorch
Refer to this section for common issues faced while deploying your Pytorch models using Torchserve and their corresponding troubleshooting steps.
Read more >
发布 0.6.3 OpenMMLab - MMOCR's documentation!
同时可以使用 test_torchserve.py 来可视化对比 TorchServe 和 PyTorch 结果。 ... Fix GPG key error in CI and docker by @gaotongxiao in ...
Read more >
Manual Yolo V7 (Python) integration in HA - Configuration
Here is a TorchServe example I played with for Yolov5. ... in <module> for object in response["predictions"]: KeyError: 'predictions'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found