File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -669,6 +669,16 @@ def parse_args(input_args=None):
669
669
),
670
670
)
671
671
672
+ parser .add_argument (
673
+ "--image_interpolation_mode" ,
674
+ type = str ,
675
+ default = "lanczos" ,
676
+ choices = [
677
+ f .lower () for f in dir (transforms .InterpolationMode ) if not f .startswith ("__" ) and not f .endswith ("__" )
678
+ ],
679
+ help = "The image interpolation method to use for resizing images." ,
680
+ )
681
+
672
682
if input_args is not None :
673
683
args = parser .parse_args (input_args )
674
684
else :
@@ -790,7 +800,12 @@ def __init__(
790
800
self .original_sizes = []
791
801
self .crop_top_lefts = []
792
802
self .pixel_values = []
793
- train_resize = transforms .Resize (size , interpolation = transforms .InterpolationMode .BILINEAR )
803
+
804
+ interpolation = getattr (transforms .InterpolationMode , args .image_interpolation_mode .upper (), None )
805
+ if interpolation is None :
806
+ raise ValueError (f"Unsupported interpolation mode { interpolation = } ." )
807
+ train_resize = transforms .Resize (size , interpolation = interpolation )
808
+
794
809
train_crop = transforms .CenterCrop (size ) if center_crop else transforms .RandomCrop (size )
795
810
train_flip = transforms .RandomHorizontalFlip (p = 1.0 )
796
811
train_transforms = transforms .Compose (
You can’t perform that action at this time.
0 commit comments