forked from DeepLabCut/DeepLabCut
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
52 deletions.
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
1 change: 1 addition & 0 deletions
1
deeplabcut/pose_estimation_tensorflow/models/pretrained/download.sh
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# legacy. | ||
#!/bin/sh | ||
|
||
curl http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz | tar xvz | ||
|
2 changes: 2 additions & 0 deletions
2
deeplabcut/pose_estimation_tensorflow/models/pretrained/pretrained_model_urls.yaml
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,2 @@ | ||
resnet_50: http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz | ||
resnet_101: http://download.tensorflow.org/models/resnet_v1_101_2016_08_28.tar.gz |
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,46 @@ | ||
""" | ||
DeepLabCut Toolbox | ||
https://github.com/AlexEMG/DeepLabCut | ||
A Mathis, [email protected] | ||
M Mathis, [email protected] | ||
""" | ||
|
||
from deeplabcut.utils import auxiliaryfunctions | ||
|
||
def Check4weights(modeltype,parent_path,num_shuffles): | ||
''' gets local path to network weights and checks if they are present. If not, downloads them from tensorflow.org ''' | ||
if 'resnet_50' == modeltype: | ||
model_path = parent_path / 'pose_estimation_tensorflow/models/pretrained/resnet_v1_50.ckpt' | ||
elif 'resnet_101' == modeltype: | ||
model_path = parent_path / 'pose_estimation_tensorflow/models/pretrained/resnet_v1_101.ckpt' | ||
else: | ||
print("Currently only ResNet 50 or 101 supported, please change 'resnet' entry in config.yaml!") | ||
num_shuffles=-1 #thus the loop below is empty... | ||
model_path=parent_path | ||
|
||
if num_shuffles>0: | ||
if not model_path.is_file(): | ||
Downloadweights(modeltype,model_path) | ||
|
||
return str(model_path),num_shuffles | ||
|
||
def Downloadweights(modeltype,model_path): | ||
""" | ||
Downloads the ImageNet pretrained weights for ResNet. | ||
""" | ||
|
||
import urllib | ||
import tarfile | ||
from io import BytesIO | ||
|
||
target_dir = model_path.parents[0] | ||
neturls=auxiliaryfunctions.read_plainconfig(target_dir / 'pretrained_model_urls.yaml') | ||
try: | ||
url = neturls[modeltype] | ||
print("Downloading a ImageNet-pretrained model from {}....".format(url)) | ||
response = urllib.request.urlopen(url) | ||
with tarfile.open(fileobj=BytesIO(response.read()), mode='r:gz') as tar: | ||
tar.extractall(path=target_dir) | ||
except KeyError: | ||
print("Model does not exist", modeltype) |
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