@@ -26,7 +26,7 @@ def get_labelname(labelmap, labels):
2626 labels = [labels ]
2727 for label in labels :
2828 found = False
29- for i in xrange (0 , num_labels ):
29+ for i in range (0 , num_labels ):
3030 if label == labelmap .item [i ].label :
3131 found = True
3232 labelnames .append (labelmap .item [i ].display_name )
@@ -94,7 +94,7 @@ def detect(self, image_file, conf_thresh=0.5, topn=5):
9494 top_ymax = det_ymax [top_indices ]
9595
9696 result = []
97- for i in xrange (min (topn , top_conf .shape [0 ])):
97+ for i in range (min (topn , top_conf .shape [0 ])):
9898 xmin = top_xmin [i ] # xmin = int(round(top_xmin[i] * image.shape[1]))
9999 ymin = top_ymin [i ] # ymin = int(round(top_ymin[i] * image.shape[0]))
100100 xmax = top_xmax [i ] # xmax = int(round(top_xmax[i] * image.shape[1]))
@@ -111,22 +111,22 @@ def main(args):
111111 args .model_def , args .model_weights ,
112112 args .image_resize , args .labelmap_file )
113113 result = detection .detect (args .image_file )
114- print result
114+ print ( result )
115115
116116 img = Image .open (args .image_file )
117117 draw = ImageDraw .Draw (img )
118118 width , height = img .size
119- print width , height
119+ print ( width , height )
120120 for item in result :
121121 xmin = int (round (item [0 ] * width ))
122122 ymin = int (round (item [1 ] * height ))
123123 xmax = int (round (item [2 ] * width ))
124124 ymax = int (round (item [3 ] * height ))
125125 draw .rectangle ([xmin , ymin , xmax , ymax ], outline = (255 , 0 , 0 ))
126126 draw .text ([xmin , ymin ], item [- 1 ] + str (item [- 2 ]), (0 , 0 , 255 ))
127- print item
128- print [xmin , ymin , xmax , ymax ]
129- print [xmin , ymin ], item [- 1 ]
127+ print ( item )
128+ print ( [xmin , ymin , xmax , ymax ])
129+ print ( [xmin , ymin ], item [- 1 ])
130130 img .save ('detect_result.jpg' )
131131
132132
0 commit comments