PRBonn / bonnetal

Bonnet and then some! Deep Learning Framework for various Image Recognition Tasks. Photogrammetry and Robotics Lab, University of Bonn
MIT License
234 stars 60 forks source link

Error using standalone image inference #28

Closed ohad-denh closed 3 years ago

ohad-denh commented 3 years ago

hey there,

training worked fine, also making the inference models was no problem. I then build for standalone use, which gives me no errors.

But when I try using standalone inference on images as described in deploy/segmentation, I get the following C++ error:

Predicting image: ../train/tasks/segmentation/dataset/504-896/rgb/rgb-cropped/
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 140) > this->size() (which is 0)
Aborted (core dumped)

Since I dont yet have any idea of C++ whatsoever, I thought maybe someone has a chance to see the problem directly. In the following I'll add the whole console output for my infer_img execution, aswell as the config of the model. I would appreciate any clue. Thx for looking!

My example is called with tensor rt, but I get the same error with pytorch aswell. I first thought it was about image dimensions, remade the inference models with new dimensions etc., but did not get there yet.

The full console output:

developer@olli:/home/olli/Code/XxxXxxx/bonnetal/deploy$ ./devel/lib/bonnetal_segmentation_standalone/infer_img -p ../train/tasks/segmentation/mystuff/deployed/best_darknet_leaf -i ../train/tasks/segmentation/dataset/504-896/rgb/rgb-cropped/ -b tensorrt
================================================================================
image: ../train/tasks/segmentation/dataset/504-896/rgb/rgb-cropped/
path: ../train/tasks/segmentation/mystuff/deployed/best_darknet_leaf/
backend: tensorrt
verbose: 0
================================================================================
Setting verbosity to: true
Trying to open model
Trying to deserialize previously stored: ../train/tasks/segmentation/mystuff/deployed/best_darknet_leaf//model.trt
Successfully found TensorRT engine file ../train/tasks/segmentation/mystuff/deployed/best_darknet_leaf//model.trt
Successfully created inference runtime
No DLA selected.
Successfully allocated 122542320 for model.
Successfully read 122542320 to modelmem.
INFO: Glob Size is 122257600 bytes.
INFO: Added linear block of size 173408256
INFO: Added linear block of size 173408256
INFO: Added linear block of size 28901376
INFO: Added linear block of size 28901376
INFO: Added linear block of size 14450688
INFO: Added linear block of size 7225344
INFO: Deserialize required 1790698 microseconds.
Created engine!
Successfully deserialized Engine from trt file
Binding: 0, type: 0
[Dim 3][Dim 504][Dim 896]
Binding: 1, type: 3
[Dim 1][Dim 504][Dim 896]
Successfully create binding buffer
================================================================================
Predicting image: ../train/tasks/segmentation/dataset/504-896/rgb/rgb-cropped/
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 140) > this->size() (which is 0)
Aborted (core dumped)

And the config

backbone:
  OS: 8
  bn_d: 0.01
  dropout: 0.01
  extra:
    darknet: darknet53
  name: darknet
  train: true
dataset:
  color_map:
    0:
    - 0
    - 0
    - 0
    1:
    - 255
    - 0
    - 0
    2:
    - 0
    - 0
    - 255
  img_means:
  - 0.4148446751432425
  - 0.5053385609354691
  - 0.45907718096515426
  img_prop:
    depth: 3
    height: 504
    width: 896
  img_stds:
  - 0.14722864867881855
  - 0.16334236156069035
  - 0.17758600209156641
  labels:
    0: ground
    1: carrot
    2: weed
  labels_w:
    0: 1.0
    1: 1.0
    2: 1.0
  location: dataset/leaf_moreweed/
  name: leaf_moreweed
  workers: 12
decoder:
  bn_d: 0.01
  dropout: 0.01
  extra:
    aspp_channels: 256
    last_channels: 32
    skip_os:
    - 4
    - 2
  name: aspp_residual
  train: true
head:
  dropout: 0.01
  name: segmentation
train:
  avg_N: 3
  batch_size: 2
  crop_prop:
    height: 480
    width: 480
  down_epochs: 100
  final_decay: 0.995
  loss: xentropy
  max_epochs: 100
  max_lr: 0.0001
  max_momentum: 0.95
  min_lr: 1.0e-05
  min_momentum: 0.9
  report_batch: 1
  report_epoch: 1
  save_imgs: false
  save_summary: true
  up_epochs: 0.5
  w_decay: 0.0001

best regards, olli

jcyhcs commented 3 years ago

@ohad-denh hi,professor: i want to test bonnet c++ tensorrt, i download one pretrained model like: persons-erfnet-512-88.tar.gz then ubpack it, i got: image but c++ program need *.trt model , so what can i do it? oh,please help me!