You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
( I add a " --sample-image ./input1.jpg" to get a sample output in order to make sure the results are the same between the detectron2 one and the c++ one )
I print the result of the "traceable_model" by add some codes in export_model.py so the code became:
if args.format == "torchscript":
ts_model = torch.jit.trace(traceable_model, (image,))
result = traceable_model(image)
print("result[0] : ",result[0].shape)
print("result[1] : ", result[1].shape)
print("result[2] : ", result[2].shape)
print("result[3] : ", result[3].shape)
print("result[4] : ", result[4].shape)
with PathManager.open(os.path.join(args.output, "model.ts"), "wb") as f:
torch.jit.save(ts_model, f)
dump_torchscript_IR(ts_model, args.output)
Now I use the c++ sample code in the guide, I just take out the bbox part and I find it is different from the result of the detectorn2
in detectorn2 the bbox is:
torch.Size([52, 4])
in c++ the bbox is :
CPUFloatType [41, 4]
when I use the exporter , it shows numerous warning message like:
/media/gino/a278e84d-9197-4f4e-8f2a-3a52677ef946/home/gino/detectron2/detectron2/structures/image_list.py:79: 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!
assert t.shape[:-2] == tensors[0].shape[:-2], t.shape
/home/gino/.local/lib/python3.6/site-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
/media/gino/a278e84d-9197-4f4e-8f2a-3a52677ef946/home/gino/detectron2/detectron2/structures/boxes.py:148: TracerWarning: torch.as_tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
tensor = torch.as_tensor(tensor, dtype=torch.float32, device=device)
/media/gino/a278e84d-9197-4f4e-8f2a-3a52677ef946/home/gino/detectron2/detectron2/structures/boxes.py:153: 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!
assert tensor.dim() == 2 and tensor.size(-1) == 4, tensor.size()
/media/gino/a278e84d-9197-4f4e-8f2a-3a52677ef946/home/gino/detectron2/detectron2/modeling/proposal_generator/proposal_utils.py:78: TracerWarning: Converting a tensor to a Python integer 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!
topk_scores_i = logits_i.narrow(1, 0, num_proposals_i)
What's wrong with my detectron2 ? How do I get the correct result in c++?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi sir,
I'm trying to export the model in detectron2 to the c++ in libtorch environment. I follow the guide and use the following command:
( I add a " --sample-image ./input1.jpg" to get a sample output in order to make sure the results are the same between the detectron2 one and the c++ one )
I print the result of the "traceable_model" by add some codes in export_model.py so the code became:
Now I use the c++ sample code in the guide, I just take out the bbox part and I find it is different from the result of the detectorn2
in detectorn2 the bbox is:
in c++ the bbox is :
when I use the exporter , it shows numerous warning message like:
What's wrong with my detectron2 ? How do I get the correct result in c++?
Beta Was this translation helpful? Give feedback.
All reactions