Skip to content

Commit

Permalink
Clean dependencies and add to README
Browse files Browse the repository at this point in the history
  • Loading branch information
hassony2 committed Jun 10, 2019
1 parent a170617 commit 2a96f74
Show file tree
Hide file tree
Showing 5 changed files with 463 additions and 457 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ obman_train/
- Download model files from TODO
- unzip `unzip release_models.zip`

## Install python dependencies

- create conda environment with dependencies: `conda env create -f environment.yml`
- activate environment: `conda activate obman_train`


## Install the MANO PyTorch layer

- Follow the instructions from [here](https://github.com/hassony2/manopth)


### Download the MANO model files

- Go to [MANO website](http://mano.is.tue.mpg.de/)
Expand All @@ -59,6 +65,8 @@ obman_render/
```




# Launch

## Training
Expand Down Expand Up @@ -113,6 +121,19 @@ Note that the model trained on First Hand Action Benchmark strongly overfits to
- In addition to the models, we also provide a hand-only model trained on various hand datasets, including our ObMan dataset, that captures a wider variety of hand poses
- to try it, launch `python webcam_demo.py --resume release_models/hands_only/checkpoint.pth.tar`

# Citations

If you find this code useful for your research, consider citing:

```
@INPROCEEDINGS{hasson19_obman,
title = {Learning joint reconstruction of hands and manipulated objects},
author = {Hasson, Yana and Varol, G{\"u}l and Tzionas, Dimitris and Kalevatykh, Igor and Black, Michael J. and Laptev, Ivan and Schmid, Cordelia},
booktitle = {CVPR},
year = {2019}
}
```

# Acknowledgements

## AtlasNet code
Expand Down
18 changes: 18 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: obman_train
channels:
- menpo
- defaults
- conda-forge
dependencies:
- opencv
- python=3.7
- matplotlib
- numpy
- pillow
- pytorch
- trimesh
- tqdm
- pip
- pip:
- git+https://github.com/hassony2/chumpy.git
- opencv-python
85 changes: 22 additions & 63 deletions handobjectdatasets/viz3d.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
import numpy as np
import plotly.graph_objs as go


def equal_aspect_3d(ax):
extents = np.array(
[getattr(ax, 'get_{}lim'.format(dim))() for dim in 'xyz'])
[getattr(ax, "get_{}lim".format(dim))() for dim in "xyz"]
)
sz = extents[:, 1] - extents[:, 0]
centers = np.mean(extents, axis=1)
maxsize = max(abs(sz))
r = maxsize / 2
for ctr, dim in zip(centers, 'xyz'):
getattr(ax, 'set_{}lim'.format(dim))(ctr - r, ctr + r)
for ctr, dim in zip(centers, "xyz"):
getattr(ax, "set_{}lim".format(dim))(ctr - r, ctr + r)


def visualize_joints_3d(ax,
joints,
joint_idxs=True,
alpha=1,
links=None,
scatter_color='r'):
def visualize_joints_3d(
ax, joints, joint_idxs=True, alpha=1, links=None, scatter_color="r"
):
"""
Args:
ax = fig.add_subplot(111, projection='3d')
"""
if links is None:
links = [(0, 1, 2, 3, 4), (0, 5, 6, 7, 8), (0, 9, 10, 11, 12),
(0, 13, 14, 15, 16), (0, 17, 18, 19, 20)]
links = [
(0, 1, 2, 3, 4),
(0, 5, 6, 7, 8),
(0, 9, 10, 11, 12),
(0, 13, 14, 15, 16),
(0, 17, 18, 19, 20),
]
# Scatter hand joints on image
x = joints[:, 0]
y = joints[:, 1]
Expand All @@ -43,7 +43,7 @@ def visualize_joints_3d(ax,


def _draw3djoints(ax, annots, links, alpha=1):
colors = ['r', 'm', 'b', 'c', 'g']
colors = ["r", "m", "b", "c", "g"]

for finger_idx, finger_links in enumerate(links):
for idx in range(len(finger_links) - 1):
Expand All @@ -53,57 +53,16 @@ def _draw3djoints(ax, annots, links, alpha=1):
finger_links[idx],
finger_links[idx + 1],
c=colors[finger_idx],
alpha=alpha)
alpha=alpha,
)


def _draw3dseg(ax, annot, idx1, idx2, c='r', alpha=1):
def _draw3dseg(ax, annot, idx1, idx2, c="r", alpha=1):
ax.plot(
[annot[idx1, 0], annot[idx2, 0]], [annot[idx1, 1], annot[idx2, 1]],
[annot[idx1, 0], annot[idx2, 0]],
[annot[idx1, 1], annot[idx2, 1]],
[annot[idx1, 2], annot[idx2, 2]],
c=c,
alpha=alpha,
linewidth=1)


def pyplot_hands(joints):
joint_nb = joints.shape[0]
if joint_nb == 21:
links = [(0, 1, 2, 3, 4), (0, 5, 6, 7, 8), (0, 9, 10, 11, 12),
(0, 13, 14, 15, 16), (0, 17, 18, 19, 20)]
elif joint_nb == 20:
links = [(0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11), (12, 13, 14, 15),
(16, 17, 18, 19)]
else:
raise ValueError('{} joints not supported for pyplot visualization'.
format(joint_nb))
trace1 = go.Scatter3d(
x=joints[:, 0],
y=joints[:, 1],
z=joints[:, 2],
marker=dict(size=1),
mode='markers',
name='markers')

def add_trace(finger_links, joints):
x_lines = list()
y_lines = list()
z_lines = list()
# create the coordinate list for the lines
for idx in finger_links:
# print(idx)
x_lines.append(joints[idx, 0])
y_lines.append(joints[idx, 1])
z_lines.append(joints[idx, 2])
x_lines.append(None)
y_lines.append(None)
z_lines.append(None)
trace = go.Scatter3d(
x=x_lines, y=y_lines, z=z_lines, mode='lines', name='lines')
return trace

traces = []
for finger_idx, finger_links in enumerate(links):
trace = add_trace(finger_links, joints)
traces.append(trace)
hand_traces = [trace1, *traces]
return hand_traces
linewidth=1,
)
Loading

0 comments on commit 2a96f74

Please sign in to comment.