File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 13
13
import onnx_graphsurgeon as gs
14
14
import tensorrt as trt
15
15
import pycuda .driver as cuda
16
- from pytorch_quantization import nn as quant_nn
17
16
prod_package_error = None
18
17
except Exception as e :
19
18
prod_package_error = e
Original file line number Diff line number Diff line change 1
- import torchvision
1
+ from aloscene .io .utils .errors import InvalidSampleError
2
+
3
+ import cv2
2
4
import torch
5
+ import torchvision
6
+ import numpy as np
3
7
from torchvision .io .image import ImageReadMode
4
8
5
- from aloscene .io .utils .errors import InvalidSampleError
6
-
7
9
8
10
def load_image (image_path ):
9
11
"""
@@ -22,5 +24,11 @@ def load_image(image_path):
22
24
try :
23
25
image = torchvision .io .read_image (image_path , ImageReadMode .RGB ).type (torch .float32 )
24
26
except RuntimeError as e :
25
- raise InvalidSampleError (f"[Alodataset Warning] Invalid image: { image_path } error={ e } " )
27
+ try :
28
+ image = cv2 .imread (image_path )
29
+ image = cv2 .cvtColor (image , cv2 .COLOR_BGR2RGB )
30
+ image = np .moveaxis (image , 2 , 0 )
31
+ image = torch .Tensor (image ).type (torch .float32 )
32
+ except RuntimeError as e :
33
+ raise InvalidSampleError (f"[Alodataset Warning] Invalid image: { image_path } error={ e } " )
26
34
return image
You can’t perform that action at this time.
0 commit comments