-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify ImageClassification API to use a workspace for saving data #4410
Conversation
src/Microsoft.ML.Dnn/DnnUtils.cs
Outdated
if (arch == Architecture.InceptionV3) | ||
{ | ||
DownloadIfNeeded(env, @"tfhub_modules.zip",currentDirectory,@"tfhub_modules.zip",timeout); | ||
DownloadIfNeeded(env, @"tfhub_modules.zip",path,@"tfhub_modules.zip",timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
",path,@" [](start = 57, length = 9)
ctrl + K + D will set spaces. #Resolved
src/Microsoft.ML.Dnn/DnnUtils.cs
Outdated
if (path == null) | ||
{ | ||
path = GetTemporaryDirectory(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} [](start = 12, length = 1)
new lines #Resolved
src/Microsoft.ML.Dnn/DnnUtils.cs
Outdated
@@ -494,5 +498,11 @@ public Tensor[] Run() | |||
|
|||
} | |||
|
|||
internal static string GetTemporaryDirectory() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal [](start = 8, length = 8)
private #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot change to private as it is used in ImageClassificationTrainer.cs, and thus must remain internal
In reply to: 340255936 [](ancestors = 340255936)
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Show resolved
Hide resolved
if (options.WorkspacePath == null) | ||
{ | ||
options.WorkspacePath = GetTemporaryDirectory(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline #Resolved
@@ -602,12 +605,14 @@ private protected override ImageClassificationModelParameters TrainModelCore(Tra | |||
var validationSet = trainContext.ValidationSet?.Data ?? _options.ValidationSet; | |||
var imageProcessor = new ImageProcessor(_session, _jpegDataTensorName, _resizedImageTensorName); | |||
int trainingsetSize = -1; | |||
string trainSetBottleneckCachedValuesFilePath = Path.Combine(_options.WorkspacePath, _options.TrainSetBottleneckCachedValuesFileName); | |||
string validationSetBottleneckCachedValuesFilePath = Path.Combine(_options.WorkspacePath, _options.ValidationSetBottleneckCachedValuesFileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for null for train/test file names #Resolved
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Show resolved
Hide resolved
@@ -390,10 +390,10 @@ public sealed class Options : TrainerInputBaseWithLabel | |||
public Action<ImageClassificationMetrics> MetricsCallback = null; | |||
|
|||
/// <summary> | |||
/// Indicates the path where the newly retrained model should be saved. | |||
/// Indicates the path where the models get downloaded and cache files saved | |||
/// </summary> | |||
[Argument(ArgumentType.AtMostOnce, HelpText = "Indicates the path where the newly retrained model should be saved.", SortOrder = 15)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HelpText
should be updated. #Resolved
@@ -390,10 +390,10 @@ public sealed class Options : TrainerInputBaseWithLabel | |||
public Action<ImageClassificationMetrics> MetricsCallback = null; | |||
|
|||
/// <summary> | |||
/// Indicates the path where the newly retrained model should be saved. | |||
/// Indicates the path where the models get downloaded and cache files saved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably explain the default behavior, so callers know what to expect if this isn't specified. #Resolved
src/Microsoft.ML.Dnn/DnnUtils.cs
Outdated
int timeout = 10 * 60 * 1000; | ||
string currentDirectory = Directory.GetCurrentDirectory(); | ||
DownloadIfNeeded(env, modelFileName, currentDirectory, modelFileName, timeout); | ||
if (path == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (string.IsNullOrEmpty(path))
#Resolved
@@ -87,8 +87,7 @@ public TransformerChain<KeyToValueMappingTransformer> TrainResnetV250() | |||
BatchSize = 10, | |||
LearningRate = 0.01f, | |||
EarlyStoppingCriteria = new ImageClassificationTrainer.EarlyStopping(minDelta: 0.001f, patience: 20, metric: ImageClassificationTrainer.EarlyStoppingMetric.Loss), | |||
ValidationSet = testDataset, | |||
ModelSavePath = assetsPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, assetsPath
no longer needs to be an instance variable. #Resolved
Originally this API saved data to the same directory as the DLL, this could cause issues if the DLL was in a read only path. Instead moving to default to a temporary workspace path which can be defined in the options by the user. This will allow all the data to be saved in one path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
…tnet#4410) Originally this API saved data to the same directory as the DLL, this could cause issues if the DLL was in a read only path. Instead moving to default to a temporary workspace path which can be defined in the options by the user. This will allow all the data to be saved in one path.
…tnet#4410) Originally this API saved data to the same directory as the DLL, this could cause issues if the DLL was in a read only path. Instead moving to default to a temporary workspace path which can be defined in the options by the user. This will allow all the data to be saved in one path.
Originally this API saved data to the same directory as the DLL, this
could cause issues if the DLL was in a read only path. Instead moving to
default to a temporary workspace path which can be defined in the
options by the user. This will allow all the data to be saved in one
path.