Skip to content
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

Merged
merged 1 commit into from
Oct 30, 2019
Merged

Modify ImageClassification API to use a workspace for saving data #4410

merged 1 commit into from
Oct 30, 2019

Conversation

bpstark
Copy link
Contributor

@bpstark bpstark commented Oct 29, 2019

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.

@bpstark bpstark requested a review from a team as a code owner October 29, 2019 18:23
if (arch == Architecture.InceptionV3)
{
DownloadIfNeeded(env, @"tfhub_modules.zip",currentDirectory,@"tfhub_modules.zip",timeout);
DownloadIfNeeded(env, @"tfhub_modules.zip",path,@"tfhub_modules.zip",timeout);
Copy link
Member

@codemzs codemzs Oct 29, 2019

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

if (path == null)
{
path = GetTemporaryDirectory();
}
Copy link
Member

@codemzs codemzs Oct 29, 2019

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

@@ -494,5 +498,11 @@ public Tensor[] Run()

}

internal static string GetTemporaryDirectory()
Copy link
Member

@codemzs codemzs Oct 29, 2019

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

Copy link
Contributor Author

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)

if (options.WorkspacePath == null)
{
options.WorkspacePath = GetTemporaryDirectory();
}
Copy link
Member

@codemzs codemzs Oct 29, 2019

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);
Copy link
Member

@codemzs codemzs Oct 29, 2019

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

@@ -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)]
Copy link
Member

@eerhardt eerhardt Oct 29, 2019

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
Copy link
Member

@eerhardt eerhardt Oct 29, 2019

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

int timeout = 10 * 60 * 1000;
string currentDirectory = Directory.GetCurrentDirectory();
DownloadIfNeeded(env, modelFileName, currentDirectory, modelFileName, timeout);
if (path == null)
Copy link
Member

@eerhardt eerhardt Oct 29, 2019

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
Copy link
Member

@eerhardt eerhardt Oct 29, 2019

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.
Copy link
Member

@eerhardt eerhardt left a 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.

@codemzs codemzs merged commit a40df86 into dotnet:master Oct 30, 2019
frank-dong-ms-zz pushed a commit to frank-dong-ms-zz/machinelearning that referenced this pull request Nov 4, 2019
…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.
frank-dong-ms-zz pushed a commit to frank-dong-ms-zz/machinelearning that referenced this pull request Nov 4, 2019
…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.
@bpstark bpstark deleted the fixPath branch November 18, 2019 19:31
@ghost ghost locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants