Spaces:
Build error
Build error
sabrinabenas
commited on
Commit
β’
bfd77fa
1
Parent(s):
9a8a433
add url
Browse files
model/__pycache__/models.cpython-310.pyc
ADDED
Binary file (2.33 kB). View file
|
|
model/models.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import urllib.request
|
2 |
+
import tarfile
|
3 |
+
from tqdm import tqdm
|
4 |
+
import os
|
5 |
+
import yaml
|
6 |
+
from ruamel.yaml import YAML
|
7 |
+
|
8 |
+
def read_plainconfig(configname):
|
9 |
+
if not os.path.exists(configname):
|
10 |
+
raise FileNotFoundError(
|
11 |
+
f"Config {configname} is not found. Please make sure that the file exists."
|
12 |
+
)
|
13 |
+
with open(configname) as file:
|
14 |
+
return YAML().load(file)
|
15 |
+
|
16 |
+
def DownloadModel(modelname, target_dir):
|
17 |
+
"""
|
18 |
+
Downloads a DeepLabCut Model Zoo Project
|
19 |
+
"""
|
20 |
+
|
21 |
+
def show_progress(count, block_size, total_size):
|
22 |
+
pbar.update(block_size)
|
23 |
+
|
24 |
+
def tarfilenamecutting(tarf):
|
25 |
+
"""' auxfun to extract folder path
|
26 |
+
ie. /xyz-trainsetxyshufflez/
|
27 |
+
"""
|
28 |
+
for memberid, member in enumerate(tarf.getmembers()):
|
29 |
+
if memberid == 0:
|
30 |
+
parent = str(member.path)
|
31 |
+
l = len(parent) + 1
|
32 |
+
if member.path.startswith(parent):
|
33 |
+
member.path = member.path[l:]
|
34 |
+
yield member
|
35 |
+
|
36 |
+
neturls = read_plainconfig("/home/sabrina/MegaDetector_DeepLabCut/model/pretrained_model_urls.yaml") #FIXME
|
37 |
+
|
38 |
+
if modelname in neturls.keys():
|
39 |
+
url = neturls[modelname]
|
40 |
+
print(url)
|
41 |
+
response = urllib.request.urlopen(url)
|
42 |
+
print(
|
43 |
+
"Downloading the model from the DeepLabCut server @Harvard -> Go Crimson!!! {}....".format(
|
44 |
+
url
|
45 |
+
)
|
46 |
+
)
|
47 |
+
total_size = int(response.getheader("Content-Length"))
|
48 |
+
pbar = tqdm(unit="B", total=total_size, position=0)
|
49 |
+
filename, _ = urllib.request.urlretrieve(url, reporthook=show_progress)
|
50 |
+
with tarfile.open(filename, mode="r:gz") as tar:
|
51 |
+
tar.extractall(target_dir, members=tarfilenamecutting(tar))
|
52 |
+
else:
|
53 |
+
models = [
|
54 |
+
fn
|
55 |
+
for fn in neturls.keys()
|
56 |
+
if "resnet_" not in fn and "mobilenet_" not in fn
|
57 |
+
]
|
58 |
+
print("Model does not exist: ", modelname)
|
59 |
+
print("Pick one of the following: ", models)
|
60 |
+
return target_dir
|
model/pretrained_model_urls.yaml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Model Zoo from where the Charles flow(s)
|
2 |
+
full_human: http://deeplabcut.rowland.harvard.edu/models/DLC_human_fullbody_resnet_101.tar.gz
|
3 |
+
full_dog: http://deeplabcut.rowland.harvard.edu/models/DLC_Dog_resnet_50_iteration-0_shuffle-0.tar.gz
|
4 |
+
full_cat: http://deeplabcut.rowland.harvard.edu/models/DLC_Cat_resnet_50_iteration-0_shuffle-0.tar.gz
|
5 |
+
primate_face: http://deeplabcut.rowland.harvard.edu/models/DLC_primate_face_resnet_50_iteration-1_shuffle-1.tar.gz
|
6 |
+
mouse_pupil_vclose: http://deeplabcut.rowland.harvard.edu/models/DLC_mouse_pupil_vclose_resnet_50_iteration-0_shuffle-1.tar.gz
|
7 |
+
horse_sideview: http://deeplabcut.rowland.harvard.edu/models/DLC_Horses_resnet_50_iteration-1_shuffle-1.tar.gz
|
8 |
+
full_macaque: http://deeplabcut.rowland.harvard.edu/models/DLC_macaque_full_resnet50.tar.gz
|
9 |
+
full_cheetah: http://deeplabcut.rowland.harvard.edu/models/DLC_full_cheetah_resnet_152.tar.
|