@@ -88,14 +88,14 @@ internal sealed class Options : TransformInputBase
88
88
/// <param name="env">The host environment.</param>
89
89
/// <param name="imageFolder">Folder where to look for images.</param>
90
90
/// <param name="columns">Names of input and output columns.</param>
91
- internal ImageLoadingTransformer ( IHostEnvironment env , string imageFolder , params ( string outputColumnName , string inputColumnName ) [ ] columns )
91
+ internal ImageLoadingTransformer ( IHostEnvironment env , string imageFolder = null , params ( string outputColumnName , string inputColumnName ) [ ] columns )
92
92
: base ( Contracts . CheckRef ( env , nameof ( env ) ) . Register ( nameof ( ImageLoadingTransformer ) ) , columns )
93
93
{
94
- if ( String . IsNullOrWhiteSpace ( imageFolder ) || ! File . Exists ( imageFolder ) )
95
- {
96
- throw new ArgumentException ( "The provided ImageFolder path {0} is invalid." , imageFolder ) ;
97
- }
98
- ImageFolder = imageFolder ;
94
+ // Throws ArgumentException if given imageFolder path is invalid or empty. Note: imageFolder may be null in this case.
95
+ if ( imageFolder != null )
96
+ ImageFolder = Path . GetFullPath ( imageFolder ) ;
97
+ else
98
+ ImageFolder = null ;
99
99
_useImageType = true ;
100
100
}
101
101
@@ -106,11 +106,14 @@ internal ImageLoadingTransformer(IHostEnvironment env, string imageFolder, param
106
106
/// <param name="imageFolder">Folder where to look for images.</param>
107
107
/// <param name="type">Image type flag - true for ImageDataViewType or false for VectorDataViewType. Defaults to true i.e. ImageDataViewType if not specified.</param>
108
108
/// <param name="columns">Names of input and output columns.</param>
109
- internal ImageLoadingTransformer ( IHostEnvironment env , string imageFolder , bool type = true , params ( string outputColumnName , string inputColumnName ) [ ] columns )
109
+ internal ImageLoadingTransformer ( IHostEnvironment env , string imageFolder = null , bool type = true , params ( string outputColumnName , string inputColumnName ) [ ] columns )
110
110
: base ( Contracts . CheckRef ( env , nameof ( env ) ) . Register ( nameof ( ImageLoadingTransformer ) ) , columns )
111
111
{
112
- // Throws ArgumentException if given path is invalid/empty, ArgumentNullException if given path is null
113
- ImageFolder = Path . GetFullPath ( imageFolder ) ;
112
+ // Throws ArgumentException if given imageFolder path is invalid or empty. Note: imageFolder may be null in this case.
113
+ if ( imageFolder != null )
114
+ ImageFolder = Path . GetFullPath ( imageFolder ) ;
115
+ else
116
+ ImageFolder = null ;
114
117
_useImageType = type ;
115
118
}
116
119
0 commit comments