11import numpy as np
2+ import cv2
23
34from blazebase import BlazeLandmarkBase
45
@@ -141,8 +142,8 @@ def load_model(self, model_path):
141142 #[BlazeDetector.load_model] Output[ 3 ] Shape : (1,)
142143
143144 self .inputShape = self .input_vstream_infos [0 ].shape
144- self .outputShape1 = tuple (self .output_vstream_infos [0 ].shape )
145- self .outputShape2 = tuple (self .output_vstream_infos [1 ].shape )
145+ self .outputShape1 = tuple (self .output_vstream_infos [2 ].shape )
146+ self .outputShape2 = tuple (self .output_vstream_infos [0 ].shape )
146147
147148 if self .DEBUG :
148149 print ("[BlazeLandmark.load_model] Input Shape : " ,self .inputShape )
@@ -173,9 +174,11 @@ def predict(self, x):
173174
174175 # 1. Preprocess the images into tensors:
175176 start = timer ()
176- xi = np .expand_dims (x [i ,:,:,:], axis = 0 )
177- xi = xi * 255.0
178- input_data = {self .input_vstream_infos [0 ].name : xi }
177+ image_rgb = cv2 .cvtColor (x [i ,:,:,:], cv2 .COLOR_BGR2RGB )
178+ image_norm = image_rgb * 255.0
179+ image_input = np .expand_dims (image_norm , axis = 0 )
180+ image_input = image_input .astype (np .uint8 )
181+ input_data = {self .input_vstream_infos [0 ].name : image_input }
179182 self .profile_pre += timer ()- start
180183
181184 # 2. Run the neural network:
@@ -193,11 +196,10 @@ def predict(self, x):
193196 # Create input and output virtual streams params
194197 # Quantized argument signifies whether or not the incoming data is already quantized.
195198 # Data is quantized by HailoRT if and only if quantized == False .
196- self .input_vstreams_params = InputVStreamParams .make (self .network_group , quantized = False ,
197- format_type = FormatType .FLOAT32 )
198- self .output_vstreams_params = OutputVStreamParams .make (self .network_group , quantized = True ,
199- format_type = FormatType .UINT8 )
200- #format_type=FormatType.FLOAT32)
199+ #self.input_vstreams_params = InputVStreamParams.make(self.network_group, quantized=False, format_type=FormatType.FLOAT32)
200+ #self.output_vstreams_params = OutputVStreamParams.make(self.network_group, quantized=True, format_type=FormatType.UINT8)
201+ self .input_vstreams_params = InputVStreamParams .make (self .network_group )
202+ self .output_vstreams_params = OutputVStreamParams .make (self .network_group , format_type = FormatType .FLOAT32 )
201203
202204 with InferVStreams (self .network_group , self .input_vstreams_params , self .output_vstreams_params ) as infer_pipeline :
203205 with self .network_group .activate (self .network_group_params ):
@@ -210,12 +212,12 @@ def predict(self, x):
210212 out1 = infer_results [self .output_vstream_infos [2 ].name ]
211213 handedness = infer_results [self .output_vstream_infos [3 ].name ]
212214 out2 = infer_results [self .output_vstream_infos [0 ].name ]
213- out2 = out2 .reshape (1 ,21 ,- 1 ) # 42 => [1,21,2]
215+ out2 = out2 .reshape (1 ,21 ,- 1 ) # 42 => [1,21,2] | 63 => [1,21,3]
214216 out2 = out2 / self .resolution
215217 elif self .blaze_app == "blazefacelandmark" :
216218 out1 = infer_results [self .output_vstream_infos [0 ].name ]
217219 out2 = infer_results [self .output_vstream_infos [1 ].name ]
218- out2 = out2 .reshape (1 ,- 1 ,3 ) # 1404 => [1,356,2 ]
220+ out2 = out2 .reshape (1 ,- 1 ,3 ) # 1404 => [1,356,3 ]
219221 out2 = out2 / self .resolution
220222 elif self .blaze_app == "blazeposelandmark" :
221223 out1 = infer_results [self .output_vstream_infos [0 ].name ]
0 commit comments