@@ -339,27 +339,30 @@ def read(self, path="test", filename="test"):
339
339
340
340
341
341
def set_plt ():
342
+ # Turn interactive plotting off
343
+ plt .ioff ()
342
344
plt .rcParams ["figure.figsize" ] = (15 , 9 )
343
345
plt .rcParams ["figure.subplot.bottom" ] = 0.3
344
346
plt .rcParams ["figure.subplot.left" ] = 0.05
345
347
plt .rcParams ["figure.subplot.right" ] = 0.99
346
348
347
349
348
350
def show_statistic (obj_type , category , statistics , accuracy , path ):
349
- l1 = np .array (list (deepflatten (statistics )))
350
- max_error = accuracy
351
- print ( obj_type + ' ' + category + " max detected error" , max ( l1 [ l1 < max_error ]))
352
- print ( obj_type + ' ' + category + " mean detected error" , np . mean ( l1 [ l1 < max_error ]))
353
- print ()
354
- data_frame = pd .DataFrame (l1 )
351
+ objs = np .array (list (deepflatten (statistics )))
352
+ detected = objs [ objs < accuracy ]
353
+ frame = { " category" : category , " detected " + obj_type : len ( detected ) / len ( objs ),
354
+ "total detected " + obj_type : len ( detected ), "total " + obj_type : len ( detected ),
355
+ "average error " + obj_type : np . mean ( detected )}
356
+ data_frame = pd .DataFrame (objs )
355
357
data_frame .hist (bins = 500 )
356
358
plt .title (category + ' ' + obj_type )
357
359
plt .xlabel ('error' )
358
- plt .xticks (np .arange (0. , float (max_error )+ .25 , .25 ))
360
+ plt .xticks (np .arange (0. , float (accuracy )+ .25 , .25 ))
359
361
plt .ylabel ('frequency' )
360
362
# plt.show()
361
363
plt .savefig (path + '/' + category + '_' + obj_type + '.jpg' )
362
364
plt .close ()
365
+ return frame
363
366
364
367
365
368
def get_time ():
@@ -369,12 +372,14 @@ def get_time():
369
372
def show_statistics (distances , accuracy , dataset_path ):
370
373
output_dict = dataset_path + '/' + get_time ()
371
374
os .mkdir (output_dict )
375
+ draw_all = False
376
+ result = []
372
377
set_plt ()
373
378
for obj_type , statistics in distances .items ():
374
- # l1 = np.array(list(deepflatten(statistics[2])))
375
- show_statistic (obj_type , 'all' , statistics [2 ], accuracy , output_dict )
376
379
for category , image_names , category_statistics in zip (statistics [0 ], statistics [1 ], statistics [2 ]):
377
- show_statistic (obj_type , category , category_statistics , accuracy , output_dict )
380
+ result .append (show_statistic (obj_type , category , category_statistics , accuracy , output_dict ))
381
+ if not draw_all :
382
+ continue
378
383
if not os .path .exists (output_dict + '/' + category ):
379
384
os .mkdir (output_dict + '/' + category )
380
385
for image_name , image_statistics in zip (image_names , category_statistics ):
@@ -384,6 +389,10 @@ def show_statistics(distances, accuracy, dataset_path):
384
389
plt .ylabel ('error' )
385
390
plt .savefig (output_dict + '/' + category + '/' + obj_type + '_' + image_name + '.jpg' )
386
391
plt .close ()
392
+ result .append (show_statistic (obj_type , 'all' , statistics [2 ], accuracy , output_dict ))
393
+ data_frame = pd .DataFrame (result )
394
+ data_frame = data_frame .groupby ('category' , as_index = False , sort = False ).last ()
395
+ print (data_frame .to_string (index = False ))
387
396
388
397
389
398
def read_distances (filename ):
0 commit comments