@@ -36,7 +36,7 @@ def load(self):
3636 with open (os .path .join (self .model_path , 'obj.names' ), 'r' ) as f :
3737 self .labels = [line .strip () for line in f .readlines ()]
3838 self .net = cv2 .dnn .readNet (os .path .join (self .model_path , 'yolo-obj.cfg' ),
39- os .path .join (self .model_path , 'yolo-obj.weights' ))
39+ os .path .join (self .model_path , 'yolo-obj.weights' ), 'darknet' )
4040
4141 async def infer (self , input_data , draw , predict_batch ):
4242 await asyncio .sleep (0.00001 )
@@ -55,10 +55,10 @@ async def infer(self, input_data, draw, predict_batch):
5555 height , width , depth = np_image .shape
5656 # create input blob
5757 blob = cv2 .dnn .blobFromImage (
58- np_image , self . scale , (self .image_width , self .image_height ), ( self .R_mean , self . G_mean , self . B_mean ),
59- self . swapRB , self . crop )
58+ np_image , size = (self .image_width , self .image_height ), swapRB = self .swapRB , ddepth = cv2 . CV_8U )
59+
6060 # feed the blob to the network
61- self .net .setInput (blob )
61+ self .net .setInput (blob , scalefactor = self . scale , mean = [ self . R_mean , self . G_mean , self . B_mean ] )
6262 # get the output layers
6363 output_layers = self .net .forward (self .__get_output_layers__ ())
6464 # for each detection from each output layer
@@ -87,13 +87,7 @@ async def infer(self, input_data, draw, predict_batch):
8787 remaining_indices = cv2 .dnn .NMSBoxes (
8888 boxes , confidences , conf_threshold , nms_threshold )
8989
90- for i in range (len (boxes )):
91- # i = i[0]
92- box = boxes [i ]
93- x = box [0 ]
94- y = box [1 ]
95- w = box [2 ]
96- h = box [3 ]
90+
9791
9892 # release resources
9993 cv2 .destroyAllWindows ()
@@ -115,7 +109,7 @@ async def infer(self, input_data, draw, predict_batch):
115109
116110 if (left < 0 ):
117111 left = 0
118- if (right > height - 1 ):
112+ if (right > width - 1 ):
119113 right = width - 1
120114 if (top < 0 ):
121115 top = 0
0 commit comments