@@ -367,6 +367,7 @@ def report(
367
367
num_images : Optional [int ] = None ,
368
368
verbosity : int = 1 ,
369
369
print_summary : bool = True ,
370
+ show_id : bool = False ,
370
371
) -> None :
371
372
"""Prints summary of the issues found in your dataset.
372
373
By default, this method depicts the images representing top-most severe instances of each issue type.
@@ -391,6 +392,9 @@ def report(
391
392
print_summary : bool, default=True
392
393
If True, prints the summary of issues found in the dataset.
393
394
395
+ show_id: bool, default=False
396
+ If True, prints the dataset ID of each image shown in the report.
397
+
394
398
Examples
395
399
--------
396
400
Default usage
@@ -446,6 +450,7 @@ def report(
446
450
issue_type ,
447
451
report_args ["num_images" ],
448
452
report_args ["cell_size" ],
453
+ show_id ,
449
454
)
450
455
else :
451
456
print (
@@ -471,6 +476,7 @@ def _visualize(
471
476
issue_type : str ,
472
477
num_images : int ,
473
478
cell_size : Tuple [int , int ],
479
+ show_id : bool ,
474
480
) -> None :
475
481
# todo: remove dependency on issue manager
476
482
issue_manager = self ._get_issue_manager (issue_type )
@@ -484,22 +490,21 @@ def _visualize(
484
490
indices = scores .index .tolist ()
485
491
images = [self ._dataset [i ] for i in indices ]
486
492
487
- titles = [ f"score : { x :.4f } " for x in scores ]
488
-
489
- # Add size information for odd sized images
490
- additional_info = None
493
+ # construct title info
494
+ title_info = { "scores" : [ f"score : { x :.4f } " for x in scores ]}
495
+ if show_id :
496
+ title_info [ "ids" ] = [ f"id : { i } " for i in indices ]
491
497
if issue_type == IssueType .ODD_SIZE .value :
492
- additional_info = []
493
- for image in images :
494
- additional_info . append ( f"original size: { image . size } " )
498
+ title_info [ "size" ] = [
499
+ f"original size: { image . size } " for image in images
500
+ ]
495
501
496
502
if images :
497
503
VizManager .individual_images (
498
504
images = images ,
499
- titles = titles ,
505
+ title_info = title_info ,
500
506
ncols = self ._config ["visualize_num_images_per_row" ],
501
507
cell_size = cell_size ,
502
- additional_info = additional_info ,
503
508
)
504
509
505
510
elif viz_name == "image_sets" :
@@ -511,15 +516,15 @@ def _visualize(
511
516
for indices in image_sets_indices :
512
517
image_sets .append ([self ._dataset [index ] for index in indices ])
513
518
514
- title_sets = [
515
- [ self . _dataset . get_name ( index ) for index in s ]
516
- for s in image_sets_indices
517
- ]
519
+ title_info_sets = []
520
+ for s in image_sets_indices :
521
+ title_info = { "name" : [ self . _dataset . get_name ( index ) for index in s ]}
522
+ title_info_sets . append ( title_info )
518
523
519
524
if image_sets :
520
525
VizManager .image_sets (
521
526
image_sets ,
522
- title_sets ,
527
+ title_info_sets ,
523
528
ncols = self ._config ["visualize_num_images_per_row" ],
524
529
cell_size = cell_size ,
525
530
)
@@ -532,6 +537,7 @@ def visualize(
532
537
issue_types : Optional [List [str ]] = None ,
533
538
num_images : int = 4 ,
534
539
cell_size : Tuple [int , int ] = (2 , 2 ),
540
+ show_id : bool = False ,
535
541
) -> None :
536
542
"""Show specific images.
537
543
@@ -599,24 +605,24 @@ def visualize(
599
605
if len (issue_types ) == 0 :
600
606
raise ValueError ("issue_types list is empty" )
601
607
for issue_type in issue_types :
602
- self ._visualize (issue_type , num_images , cell_size )
608
+ self ._visualize (issue_type , num_images , cell_size , show_id )
603
609
elif image_files is not None :
604
610
if len (image_files ) == 0 :
605
611
raise ValueError ("image_files list is empty." )
606
612
images = [Image .open (path ) for path in image_files ]
607
- titles = [path .split ("/" )[- 1 ] for path in image_files ]
613
+ title_info = { "path" : [path .split ("/" )[- 1 ] for path in image_files ]}
608
614
VizManager .individual_images (
609
615
images ,
610
- titles ,
616
+ title_info ,
611
617
ncols = self ._config ["visualize_num_images_per_row" ],
612
618
cell_size = cell_size ,
613
619
)
614
620
elif indices :
615
621
images = [self ._dataset [i ] for i in indices ]
616
- titles = [self ._dataset .get_name (i ) for i in indices ]
622
+ title_info = { "name" : [self ._dataset .get_name (i ) for i in indices ]}
617
623
VizManager .individual_images (
618
624
images ,
619
- titles ,
625
+ title_info ,
620
626
ncols = self ._config ["visualize_num_images_per_row" ],
621
627
cell_size = cell_size ,
622
628
)
@@ -628,10 +634,12 @@ def visualize(
628
634
self ._dataset .index , min (num_images , len (self ._dataset ))
629
635
)
630
636
images = [self ._dataset [i ] for i in image_indices ]
631
- titles = [self ._dataset .get_name (i ) for i in image_indices ]
637
+ title_info = {
638
+ "name" : [self ._dataset .get_name (i ) for i in image_indices ]
639
+ }
632
640
VizManager .individual_images (
633
641
images ,
634
- titles ,
642
+ title_info ,
635
643
ncols = self ._config ["visualize_num_images_per_row" ],
636
644
cell_size = cell_size ,
637
645
)
0 commit comments