This repository was archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Upload Pre-trained Models for Fine Tuning. #896
Merged
lukeyeager
merged 1 commit into
NVIDIA:master
from
Lucaszw:uploadPretrainedModelForTraining
Aug 9, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
from __future__ import absolute_import | ||
from .job import PretrainedModelJob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
from __future__ import absolute_import | ||
|
||
from . import tasks | ||
import digits.frameworks | ||
from digits.job import Job | ||
from digits.utils import subclass, override | ||
from digits.pretrained_model.tasks import UploadPretrainedModelTask | ||
|
||
@subclass | ||
class PretrainedModelJob(Job): | ||
""" | ||
A Job that uploads a pretrained model | ||
""" | ||
|
||
def __init__(self, weights_path, model_def_path, labels_path=None,framework="caffe",**kwargs): | ||
super(PretrainedModelJob, self).__init__(persistent = False, **kwargs) | ||
|
||
self.has_labels = labels_path is not None | ||
self.framework = framework | ||
self.tasks = [] | ||
self.tasks.append(UploadPretrainedModelTask( | ||
weights_path, | ||
model_def_path, | ||
labels_path, | ||
framework, | ||
job_dir=self.dir() | ||
)) | ||
|
||
def get_weights_path(self): | ||
if self.framework == "caffe": | ||
return self.dir()+"/model.caffemodel" | ||
else: | ||
return self.dir()+"/_Model.t7" | ||
|
||
def get_model_def_path(self): | ||
if self.framework == "caffe": | ||
return self.dir()+"/original.prototxt" | ||
else: | ||
return self.dir()+"/original.lua" | ||
|
||
@override | ||
def job_type(self): | ||
return "Pretrained Model" | ||
|
||
@override | ||
def __getstate__(self): | ||
fields_to_save = ['_id', '_name', 'username', 'tasks', 'status_history', 'has_labels', 'framework'] | ||
full_state = super(PretrainedModelJob, self).__getstate__() | ||
state_to_save = {} | ||
for field in fields_to_save: | ||
state_to_save[field] = full_state[field] | ||
return state_to_save | ||
|
||
@override | ||
def __setstate__(self, state): | ||
super(PretrainedModelJob, self).__setstate__(state) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. | ||
from __future__ import absolute_import | ||
from .upload_pretrained import UploadPretrainedModelTask |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we use
network_file
instead ofmodel_file
here? I try to be consistent in calling the .prototxt file a "network description" and not calling it a model unless it has weights attached to it.The nomenclature I'd like to migrate to (but don't fully support yet) is:
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.
Oh nevermind. We do the same for Torch. Rats.
However, you will want to be more careful with the upgrade path here.
__setstate__
, upgrade fromoriginal_file
tomodel_file
appropriately