MaskDINO icon indicating copy to clipboard operation
MaskDINO copied to clipboard

How to export maskdino into onnx format?

Open MeAmarP opened this issue 3 years ago • 7 comments

Hi Team, After initial evaluation am planning to export model into onnx format using detectron2 deploy tools.

But, Am running into following error, on build_model(cfg) call. KeyError: "No object named 'MaskDINO' found in 'META_ARCH' registry!"

I made following changes in setup_cfg() method of export_model.py

def setup_cfg(args):
    cfg = get_cfg()
    # cuda context is initialized before creating dataloader, so we don't fork anymore
    cfg.DATALOADER.NUM_WORKERS = 0
    add_pointrend_config(cfg)
    add_deeplab_config(cfg)                            # <---
    add_maskdino_config(cfg)                         # <---
    cfg.merge_from_file(args.config_file)
    cfg.merge_from_list(args.opts)
    cfg.freeze()
    return cfg

Is there any way I can resolve this? Please guide me here.

MeAmarP avatar Jan 11 '23 13:01 MeAmarP

Hi Team If I understand, I have to import maskdino somewhere in export_model.py right?

MeAmarP avatar Jan 12 '23 07:01 MeAmarP

We did not try oonx before, so we could not offer any suggestions now.

FengLi-ust avatar Jan 15 '23 05:01 FengLi-ust

Have you tried any other method for exporting model?

MeAmarP avatar Jan 16 '23 11:01 MeAmarP

MaskDINO uses a lot of Mask2Former codes and Mask2Former currently won’t work with onnx.

Mask2Former actually can be export to onnx with opset version >= 16. But the prediction is just messed up.

If you want try, check demo/demo..py and demo/predictor.py. It creates a DefaultPredictor and DefaultPredictorhas an attribute model. This model is basically a PyTorch model. So you can export it to onnx using torch.onnx.export().

kaitolucifer avatar Jan 30 '23 15:01 kaitolucifer

@MeAmarP did you resolve the issue?

krzysztofsulima avatar Feb 21 '23 09:02 krzysztofsulima

Any progress on this? How would one deploy this model in production? Which exporting formats can this model be exported to?

roboserg avatar May 20 '23 22:05 roboserg

I got the same error when I tried to convert my MASK DINO model to onnx using detectron export_model.py file. Any progress on this?

ikranergiz avatar Apr 22 '24 13:04 ikranergiz