Skip to content

used onnx wrong #940

Open
Open
@Chenhait

Description

@Chenhait

i tried to use onnx model, but there is a wrong, thank you if any advance.
python neural_style/neural_style.py eval --content-image images/content-images/amber.jpg --model saved_models/candy.onnx --output-image aa.jpg --cuda 1

first, there is a wrong,
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
i changed
inp = {model.graph.input[0].name: content_image.numpy()}
to
inp = {model.graph.input[0].name: content_image.cpu().numpy()}

then, there is another wrong

Traceback (most recent call last):
  File "neural_style/neural_style.py", line 240, in <module>
    main()
  File "neural_style/neural_style.py", line 236, in main
    stylize(args)
  File "neural_style/neural_style.py", line 134, in stylize
    output = stylize_onnx_caffe2(content_image, args)
  File "neural_style/neural_style.py", line 167, in stylize_onnx_caffe2
    c2_out = prepared_backend.run(inp)[0]
  File "/home/tt/anaconda3/envs/gonnx/lib/python3.8/site-packages/onnx_caffe2/backend_rep.py", line 31, in run
    with core.NameScope(self._name_scope):
  File "/home/tt/anaconda3/envs/gonnx/lib/python3.8/site-packages/onnx_caffe2/backend_rep.py", line 23, in _name_scope
    return 'gpu_{}'.format(self.predict_net.device_option.cuda_gpu_id)
AttributeError: cuda_gpu_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions