Visitar URL original
Pull demo data from Zenodo (#2440) · DeepLabCut/DeepLabCut@96a30c5 · GitHub
Skip to content

Commit 96a30c5

Browse files
authored
Pull demo data from Zenodo (#2440)
1 parent 3ba648f commit 96a30c5

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

‎examples/COLAB/COLAB_transformer_reID.ipynb‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,21 @@
6767
"outputs": [],
6868
"source": [
6969
"# Download our demo project:\n",
70-
"import urllib.request\n",
70+
"import requests\n",
7171
"from io import BytesIO\n",
7272
"from zipfile import ZipFile\n",
7373
"\n",
74-
"def unzip_from_url(url, dest_folder=''):\n",
75-
" # Directly extract files without writing the archive to disk\n",
76-
" resp = urllib.request.urlopen(url)\n",
77-
" with ZipFile(BytesIO(resp.read())) as zf:\n",
78-
" zf.extractall(path=dest_folder)\n",
79-
"\n",
80-
"\n",
81-
"project_url = \"http://deeplabcut.rowland.harvard.edu/datasets/demo-me-2021-07-14.zip\"\n",
82-
"unzip_from_url(project_url, \"/content\")"
74+
"url_record = 'https://zenodo.org/api/records/7883589'\n",
75+
"response = requests.get(url_record)\n",
76+
"if response.status_code == 200:\n",
77+
" file = response.json()['files'][0]\n",
78+
" title = file['key']\n",
79+
" print(f\"Downloading {title}...\")\n",
80+
" with requests.get(file['links']['self'], stream=True) as r:\n",
81+
" with ZipFile(BytesIO(r.content)) as zf:\n",
82+
" zf.extractall(path='/content')\n",
83+
"else:\n",
84+
" raise ValueError(f'The URL {url_record} could not be reached.')"
8385
]
8486
},
8587
{
@@ -138,10 +140,10 @@
138140
"outputs": [],
139141
"source": [
140142
"#Filter the predictions to remove small jitter, if desired:\n",
141-
"dlc.filterpredictions(config_path, \n",
142-
" [video], \n",
143+
"dlc.filterpredictions(config_path,\n",
144+
" [video],\n",
143145
" shuffle=0,\n",
144-
" videotype='mp4', \n",
146+
" videotype='mp4',\n",
145147
" )\n",
146148
"\n",
147149
"dlc.create_labeled_video(\n",
@@ -230,8 +232,8 @@
230232
},
231233
"outputs": [],
232234
"source": [
233-
"dlc.plot_trajectories(config_path, [video], \n",
234-
" shuffle=0,videotype='mp4', \n",
235+
"dlc.plot_trajectories(config_path, [video],\n",
236+
" shuffle=0,videotype='mp4',\n",
235237
" track_method=\"transformer\"\n",
236238
" )"
237239
]

0 commit comments

Comments
 (0)