dbolya / yolact

A simple, fully convolutional model for real-time instance segmentation.
MIT License
5k stars 1.33k forks source link

issues about converting yolact to onnx and coreml #374

Open dzyjjpy opened 4 years ago

dzyjjpy commented 4 years ago

I try to convert onnx and coreml successfully according to your advice(https://github.com/Ma-Dan/yolact). However, before I want to use it one cell phone device,  it will have errors when compiling the .modelml file.

265/266: Converting Node Type Constant 266/266: Converting Node Type Softmax Translation to CoreML spec completed. Now compiling the CoreML model. Model Compilation done. Custom layers have been added to the CoreML model corresponding to the following ops in the onnx model: 1/2: op type: Constant, op input names and shapes: [], op output names and shapes: [('781', (19248, 4))] 2/2: op type: Softmax, op input names and shapes: [('779', 'Shape not available')], op output names and shapes: [('782', (1, 19248, 2))]

I print the log for pytorth to onnx process. The input for 781 is onnx:constant, and input is empty()

when converting onnx, there is a warning information regarding constant and trace as below: Loading model... Done. /home/jiapy/workspace/segmentation/yolact-coreml/yolact.py:255: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!   if self.last_conv_size != (conv_w, conv_h): graph(%image : Float(1, 3, 550, 550),

dose anyone have similar experience?

dzyjjpy commented 4 years ago

@Ma-Dan @dbolya

chingi071 commented 3 years ago

@dzyjjpy Hello, I would like to ask, have you successfully converted to onnx? I executed the following command to perform the onnx conversion, and the following error did occur. I want to ask you if this happened and how to deal with it, thank you.

$python eval.py --trained_model=weights/yolact_resnet50_54_800000.pth --score_threshold=0.15 --top_k=15 --image=test.jpg
Multiple GPUs detected! Turning off JIT.
Config not specified. Parsed yolact_resnet50_config from the file name.

Loading model... Done.
/home/joy/yolact_v2/yolact.py:221: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.last_img_size != (cfg._tmp_img_w, cfg._tmp_img_h):