|
67 | 67 | "outputs": [], |
68 | 68 | "source": [ |
69 | 69 | "# Download our demo project:\n", |
70 | | - "import urllib.request\n", |
| 70 | + "import requests\n", |
71 | 71 | "from io import BytesIO\n", |
72 | 72 | "from zipfile import ZipFile\n", |
73 | 73 | "\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.')" |
83 | 85 | ] |
84 | 86 | }, |
85 | 87 | { |
|
138 | 140 | "outputs": [], |
139 | 141 | "source": [ |
140 | 142 | "#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", |
143 | 145 | " shuffle=0,\n", |
144 | | - " videotype='mp4', \n", |
| 146 | + " videotype='mp4',\n", |
145 | 147 | " )\n", |
146 | 148 | "\n", |
147 | 149 | "dlc.create_labeled_video(\n", |
|
230 | 232 | }, |
231 | 233 | "outputs": [], |
232 | 234 | "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", |
235 | 237 | " track_method=\"transformer\"\n", |
236 | 238 | " )" |
237 | 239 | ] |
|
0 commit comments