dianjixz / v831_yolo

GNU General Public License v2.0
15 stars 10 forks source link

Tiny Yolo V3 #2

Open alejoGT1202 opened 2 years ago

alejoGT1202 commented 2 years ago

Hi I trained a tiny yolo v3 model with the scripts provided in this repo, however when I tried the test.py script I got the following error:

input shape: torch.Size([1, 3, 224, 224])
/home/alejo/Documents/MaixPy/v831_yolo/models/tiny_yolo_v3.py:240: TracerWarning: Converting a tensor to a NumPy array 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!
  all_obj = all_obj.to('cpu').numpy()
/home/alejo/Documents/MaixPy/v831_yolo/models/tiny_yolo_v3.py:241: TracerWarning: Converting a tensor to a NumPy array 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!
  all_class = all_class.to('cpu').numpy()
/home/alejo/Documents/MaixPy/v831_yolo/models/tiny_yolo_v3.py:242: TracerWarning: Converting a tensor to a NumPy array 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!
  all_bbox = all_bbox.to('cpu').numpy()
Traceback (most recent call last):
  File "test.py", line 237, in <module>
    torch_to_onnx(net.to("cpu"), input_shape, onnx_out, device="cpu")
  File "/home/alejo/Documents/MaixPy/v831_yolo/convert.py", line 15, in torch_to_onnx
    torch.onnx.export(net, x, out_name, export_params=True, input_names = input_names, output_names=output_names)
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/onnx/__init__.py", line 316, in export
    return utils.export(model, args, f, export_params, verbose, training,
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/onnx/utils.py", line 107, in export
    _export(model, args, f, export_params, verbose, training, input_names, output_names,
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/onnx/utils.py", line 724, in _export
    _model_to_graph(model, args, verbose, input_names,
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/onnx/utils.py", line 493, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/onnx/utils.py", line 437, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/onnx/utils.py", line 388, in _trace_and_get_graph_from_model
    torch.jit._get_trace_graph(model, args, strict=False, _force_outplace=False, _return_inputs_states=True)
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/jit/_trace.py", line 1166, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/jit/_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/home/alejo/Documents/MaixPy/sipeed/lib/python3.8/site-packages/torch/jit/_trace.py", line 121, in wrapper
    out_vars, _ = _flatten(outs)
RuntimeError: Only tuples, lists and Variables are supported as JIT inputs/outputs. Dictionaries and strings are also accepted, but their usage is not recommended. Here, received an input of unsupported type: numpy.ndarray

Is it possible to use the other yolo versions or only the slim yolo v2?

ZKH66 commented 2 years ago

Have you solved the problem?

alejoGT1202 commented 2 years ago

No, it only works with slim_yolo v2

ZKH66 commented 2 years ago

I would like to ask if v831 can only use resnet18 and yolov2, have you experimented on the development board

alejoGT1202 commented 2 years ago

Apparently yes on my v831 board I could only deploy a model using yolov2 for detection and resnet18 for classification.

dianjixz commented 2 years ago

This repositories was prepared for V831, mainly using slim_YOLO V2 model. you may need to modify some code,when you to use other models.