Skip to content

Commit

Permalink
Merge branch 'master' of github.com:anibali/h36m-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
anibali committed Jul 16, 2019
2 parents cb22848 + 62a38c0 commit b85e69b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ human pose dataset containing 3.6 million human poses and corresponding
images. The scripts in this repository make it easy to download,
extract, and preprocess the images and annotations from Human3.6M.

**Please do not ask me for a copy of the Human3.6M dataset. I do not own
the data, nor do I have permission to redistribute it. Please visit
http://vision.imar.ro/human3.6m/ in order to request access and contact
the maintainers of the dataset.**

## Requirements

* Python 3
* `axel`
* [`axel`](https://github.com/axel-download-accelerator/axel)
* CDF

Alternatively, a Dockerfile is provided which has all of the
Expand Down
42 changes: 32 additions & 10 deletions download_all.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python3

from subprocess import call
from os import path, makedirs
import hashlib
from tqdm import tqdm
from configparser import ConfigParser

import configparser
import requests

config = ConfigParser()
config.read('config.ini')
PHPSESSID = config['General']['PHPSESSID']

BASE_URL = 'http://vision.imar.ro/human3.6m/filebrowser.php'

Expand All @@ -30,16 +29,37 @@ def md5(filename):
return hash_md5.hexdigest()


def download_file(url, dest_file):
def download_file(url, dest_file, phpsessid):
call(['axel',
'-a',
'-n', '24',
'-H', 'COOKIE: PHPSESSID=' + PHPSESSID,
'-H', 'COOKIE: PHPSESSID=' + phpsessid,
'-o', dest_file,
url])


def download_all():
def get_phpsessid():
config = configparser.ConfigParser()
config.read('config.ini')
try:
phpsessid = config['General']['PHPSESSID']
except (KeyError, configparser.NoSectionError):
print('Could not read PHPSESSID from `config.ini`.')
phpsessid = input('Enter PHPSESSID: ')
return phpsessid


def verify_phpsessid(phpsessid):
requests.packages.urllib3.disable_warnings()
test_url = 'http://vision.imar.ro/human3.6m/filebrowser.php'
resp = requests.get(test_url, verify=False, cookies=dict(PHPSESSID=phpsessid))
fail_message = 'Failed to verify your PHPSESSID. Please ensure that you ' \
'are currently logged in at http://vision.imar.ro/human3.6m/ ' \
'and that you have copied the PHPSESSID cookie correctly.'
assert resp.url == test_url, fail_message


def download_all(phpsessid):
checksums = {}
with open('checksums.txt', 'r') as f:
for line in f.read().splitlines(keepends=False):
Expand Down Expand Up @@ -72,8 +92,10 @@ def download_all():
if checksums.get(out_file, None) == checksum:
continue

download_file(BASE_URL + '?' + query, out_file)
download_file(BASE_URL + '?' + query, out_file, phpsessid)


if __name__ == '__main__':
download_all()
phpsessid = get_phpsessid()
verify_phpsessid(phpsessid)
download_all(phpsessid)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ numpy==1.13.3
tqdm==4.19.8
h5py==2.7.1
spacepy==0.1.6
requests==2.20.0

0 comments on commit b85e69b

Please sign in to comment.