Skip to content

Commit

Permalink
Bug fixes in read_image_to_tensor (#97)
Browse files Browse the repository at this point in the history
* Select cpu if gpu not available

* Change BGR to RGB before inference

* Append sys path, so the notebook can open on windows

* Convert color from bgr to rgb

* Remove sys path because we assume that the notebooks are decoupled with the path dependence

* Remove color conversion because it perform in the function read_image_to_tensor
  • Loading branch information
stereomatchingkiss authored Apr 21, 2021
1 parent dbe2d4d commit f4bb74c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
65 changes: 33 additions & 32 deletions notebooks/inference-pytorch-export-libtorch.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions yolort/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def read_image_to_tensor(
image (np.ndarray): the candidate ndarray image to be parsed to Tensor.
is_half (bool): whether to transfer image to half. Default: False.
"""
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = np.ascontiguousarray(image, dtype=np.float32) # uint8 to float32
image = np.transpose(image / 255.0, [2, 0, 1])

Expand Down

0 comments on commit f4bb74c

Please sign in to comment.