facebookresearch / d2go

D2Go is a toolkit for efficient deep learning
Apache License 2.0
842 stars 201 forks source link

I need help with using the output torchscript files #126

Open ptmdmusique opened 3 years ago

ptmdmusique commented 3 years ago

Hello, I need help on how to use the output Torchscript files on mobile devices (both iOS and Android)

Currently, I used the suggested script

d2go.exporter --config-file configs/faster_rcnn_fbnetv3a_C4.yaml \
--predictor-types torchscript --output-dir ./ \
MODEL.WEIGHTS https://mobile-cv.s3-us-west-2.amazonaws.com/d2go/models/246823121/model_0479999.pth

and got 3 files image but I'm not sure how to use those in iOS or Android

Is there any example on how to use it or maybe is there any way to convert it into a single .pt file so I can follow the example

Also, is there any way to convert a normal detectron2 model to d2go model? In detectron2, I use COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml and got around 90% accuracy, but in d2go, when I use mask_rcnn_fbnetv3a_dsmask_C4.yaml, I only have around 30% accuracy with the same dataset.

zhanghang1989 commented 3 years ago

model.jit is the file you are looking for.

d2go is mainly targeting at efficient models, which are much smaller than R50. It may not be straightforward to convert detectron2 R50 models to d2go.

ptmdmusique commented 3 years ago

Thank you very much for your fast response 👏

d2go is mainly targeting at efficient models, which are much smaller than R50. It may not be straightforward to convert detectron2 R50 models to d2go.

Got it, so I guess we need to tweak the hyper-parameter and get more data for it to increase accuracy then?

model.jit is the file you are looking for.

Do you have an example on how to use model.jit in mobile ❓

zhanghang1989 commented 3 years ago

It is regular torchscript model, just use torch.jit.load("model.jit")

You can rename it to .pt. They are the same thing.

ptmdmusique commented 3 years ago

Thank you! I'll test it out and close if it works