提交 4aaf1dce 编写于 作者: D Dario Pavllo

Update setup script and instructions

上级 bc7db2c3
# Dataset setup
## Human3.6M
We provide two ways to set up the Human3.6M dataset on our pipeline. You can either use the [dataset preprocessed by Martinez et al.](https://github.com/una-dinosauria/3d-pose-baseline) (fastest way) or convert the original dataset from scratch. The two methods produce the same result. After this step, you should end up with two files in the `data` directory: `data_3d_h36m.npz` for the 3D poses, and `data_2d_h36m_gt.npz` for the ground-truth 2D poses.
We provide two ways to set up the Human3.6M dataset on our pipeline. You can either convert the original dataset (recommended) or use the [dataset preprocessed by Martinez et al.](https://github.com/una-dinosauria/3d-pose-baseline) (no longer available as of May 22nd, 2020). The two methods produce the same result. After this step, you should end up with two files in the `data` directory: `data_3d_h36m.npz` for the 3D poses, and `data_2d_h36m_gt.npz` for the ground-truth 2D poses.
### Setup from preprocessed dataset
Download the [h36m.zip archive](https://www.dropbox.com/s/e35qv3n6zlkouki/h36m.zip) (source: [3D pose baseline repository](https://github.com/una-dinosauria/3d-pose-baseline)) to the `data` directory, and run the conversion script from the same directory. This step does not require any additional dependency.
### Setup from original source (recommended)
**Update:** we have updated the instructions to simplify the procedure. MATLAB is no longer required for this step.
Register to the [Human3.6m website](http://vision.imar.ro/human3.6m/) website (or login if you already have an account) and download the dataset in its original format. You only need to download *Poses -> D3 Positions* for each subject (1, 5, 6, 7, 8, 9, 11)
##### Instructions without MATLAB (recommended)
You first need to install `cdflib` Python library via `pip install cdflib`.
Extract the archives named `Poses_D3_Positions_S*.tgz` (subjects 1, 5, 6, 7, 8, 9, 11) to a common directory. Your directory tree should look like this:
```
/path/to/dataset/S1/MyPoseFeatures/D3_Positions/Directions 1.cdf
/path/to/dataset/S1/MyPoseFeatures/D3_Positions/Directions.cdf
...
```
Then, run the preprocessing script:
```sh
cd data
wget https://www.dropbox.com/s/e35qv3n6zlkouki/h36m.zip
python prepare_data_h36m.py --from-archive h36m.zip
python prepare_data_h36m.py --from-source-cdf /path/to/dataset
cd ..
```
### Setup from original source
Alternatively, you can download the dataset from the [Human3.6m website](http://vision.imar.ro/human3.6m/) and convert it from its original format. This is useful if the other link goes down, or if you want to be sure to use the original source. MATLAB is required for this step.
If everything goes well, you are ready to go.
##### Instructions with MATLAB (old instructions)
First, we need to convert the 3D poses from `.cdf` to `.mat`, so they can be loaded from Python scripts. To this end, we have provided the MATLAB script `convert_cdf_to_mat.m` in the `data` directory. Extract the archives named `Poses_D3_Positions_S*.tgz` (subjects 1, 5, 6, 7, 8, 9, 11) to a directory named `pose`, and set up your directory tree so that it looks like this:
```
......@@ -26,13 +39,25 @@ First, we need to convert the 3D poses from `.cdf` to `.mat`, so they can be loa
```
Then run `convert_cdf_to_mat.m` from MATLAB.
Finally, as before, run the Python conversion script specifying the dataset path:
Finally, run the Python conversion script specifying the dataset path:
```sh
cd data
python prepare_data_h36m.py --from-source /path/to/dataset/pose
cd ..
```
### Setup from preprocessed dataset (old instructions)
**Update:** the link to the preprocessed dataset is no longer available; please use the procedure above. These instructions have been kept for backwards compatibility in case you already have a copy of this archive. All procedures produce the same result.
Download the [~~h36m.zip archive~~](https://www.dropbox.com/s/e35qv3n6zlkouki/h36m.zip) (source: [3D pose baseline repository](https://github.com/una-dinosauria/3d-pose-baseline)) to the `data` directory, and run the conversion script from the same directory. This step does not require any additional dependency.
```sh
cd data
wget https://www.dropbox.com/s/e35qv3n6zlkouki/h36m.zip
python prepare_data_h36m.py --from-archive h36m.zip
cd ..
```
## 2D detections for Human3.6M
We provide support for the following 2D detections:
......@@ -99,4 +124,4 @@ Since HumanEva is very small, we do not fine-tune the pretrained models. As befo
cd data
wget https://dl.fbaipublicfiles.com/video-pose-3d/data_2d_humaneva15_detectron_pt_coco.npz
cd ..
```
```
\ No newline at end of file
......@@ -30,12 +30,17 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Human3.6M dataset downloader/converter')
# Default: convert dataset preprocessed by Martinez et al. in https://github.com/una-dinosauria/3d-pose-baseline
# Convert dataset preprocessed by Martinez et al. in https://github.com/una-dinosauria/3d-pose-baseline
parser.add_argument('--from-archive', default='', type=str, metavar='PATH', help='convert preprocessed dataset')
# Alternatively, convert dataset from original source (the Human3.6M dataset path must be specified manually)
# Convert dataset from original source, using files converted to .mat (the Human3.6M dataset path must be specified manually)
# This option requires MATLAB to convert files using the provided script
parser.add_argument('--from-source', default='', type=str, metavar='PATH', help='convert original dataset')
# Convert dataset from original source, using original .cdf files (the Human3.6M dataset path must be specified manually)
# This option does not require MATLAB, but the Python library cdflib must be installed
parser.add_argument('--from-source-cdf', default='', type=str, metavar='PATH', help='convert original dataset')
args = parser.parse_args()
if args.from_archive and args.from_source:
......@@ -106,6 +111,36 @@ if __name__ == '__main__':
print('Done.')
elif args.from_source_cdf:
print('Converting original Human3.6M dataset from', args.from_source_cdf, '(CDF files)')
output = {}
import cdflib
for subject in subjects:
output[subject] = {}
file_list = glob(args.from_source_cdf + '/' + subject + '/MyPoseFeatures/D3_Positions/*.cdf')
assert len(file_list) == 30, "Expected 30 files for subject " + subject + ", got " + str(len(file_list))
for f in file_list:
action = os.path.splitext(os.path.basename(f))[0]
if subject == 'S11' and action == 'Directions':
continue # Discard corrupted video
# Use consistent naming convention
canonical_name = action.replace('TakingPhoto', 'Photo') \
.replace('WalkingDog', 'WalkDog')
hf = cdflib.CDF(f)
positions = hf['Pose'].reshape(-1, 32, 3)
positions /= 1000 # Meters instead of millimeters
output[subject][canonical_name] = positions.astype('float32')
print('Saving...')
np.savez_compressed(output_filename, positions_3d=output)
print('Done.')
else:
print('Please specify the dataset source')
exit(0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册