Skip to content

Commit b3bc752

Browse files
committed
Added capability to refine BM parameters obtained from somwhere else.
1 parent 2b1f23a commit b3bc752

File tree

4 files changed

+453
-1
lines changed

4 files changed

+453
-1
lines changed

Readme.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,38 @@ The dataset you want to fit needs to be defined in `datasets.py` as a torch data
162162
<br>
163163

164164

165+
166+
### ↺ Refine fitting
167+
168+
If you already have body model parameters (pose, shape, translation and scale) given, but they are not ideal, you can refine them.
169+
The optimization-specific configuration to refine the parmaeters is set under `refine_bm_fitting` in `config.yaml` with the following variables:
170+
171+
- `iterations` - (int) number of iterations
172+
- `start_lr_decay_iteration` - (int) iteration when to start the learning rate decay calculated as `lr *(iterations-current iteration)/iterations`
173+
- `body_model` - (string) which BM to use (smpl, smplx,..). See [Notes](##-📝-Notes) for supported models
174+
- `use_landmarks` - (string / list) which body landmarks to use for fitting. Can be `nul` to not use landmarks, `All` to use all possible landmarks, `{BM}_INDEX_LANDMARKS` defined in landmarks.py, or list of landmark names e.g. `["Lt. 10th Rib", "Lt. Dactylion",..]` defined in landmarks.py
175+
- `refine_params` - (list of strings) of parameters you want to refine, can contiain: pose, shape, transl, scale
176+
- `use_losses` - (list) losses to use. The complete list of losses is `["data","smooth","landmark","normal","partial_data"]`. Check [notes on losses](##-📝-Notes).
177+
- `loss_weight_option` - (string) the strategy for the loss weights, defined in `loss_weights_configs.yaml` under `fit_verts_loss_weight_strategy`
178+
- `prior_folder` - (string) path to the gmm prior loss .pkl file
179+
- `num_gaussians` - (float) number of gaussians to use for the prior
180+
- `lr` - (float) learning rate
181+
- `normal_threshold_angle` - (float) used if normal loss included in `use_losses`. Penalizes knn points only if angle is lower than this threshold. Otherwise points are ignored
182+
183+
<br>
184+
185+
186+
187+
#### 👥 Refine parameters fitted to dataset
188+
189+
```bash
190+
python refine_fitting.py onto_dataset --dataset_name {dataset-name}
191+
```
192+
193+
<br>
194+
<br>
195+
196+
165197
## ⚖️ Evaluate
166198
Use the `evaluate_fitting.py` script to evaluate the fitting.
167199

@@ -275,7 +307,14 @@ If you additionally want to evaluate the per vertex error (pve) after fitting (c
275307
- `vertices_gt` - (np.ndarray) ground truth vertices of the BM
276308
- `faces_gt` - (np.ndarray) ground truth faces of the BM
277309

278-
We provide the FAUST and CAESAR dataset implementations in `datasets.py`. You can obtain the datasets from [here](https://faust-leaderboard.is.tuebingen.mpg.de/) and [here](https://bodysizeshape.com/page-1855750).
310+
If you want to refine the parameters that have already been fitted, the dataset needs to additionally return:
311+
312+
- `pose` - (torch.tensor) fitted pose parameters dim 1 x 72
313+
- `shape` - (torch.tensor) fitted shape parameters dim 1 x 10
314+
- `trans` - (torch.tensor) fitted translation dim 1 x 3
315+
- `gender` - (str) gender of the body model
316+
317+
We provide the FAUST and CAESAR and 4DHumanOutfit dataset implementations in `datasets.py`. You can obtain the datasets from [here](https://faust-leaderboard.is.tuebingen.mpg.de/), [here](https://bodysizeshape.com/page-1855750) and [here](https://kinovis.inria.fr/4dhumanoutfit/).
279318

280319
<br>
281320

configs/config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ fit_vertices_optimization:
2222
normal_threshold_distance: null
2323
partial_data_threshold: null
2424

25+
refine_bm_fitting:
26+
loss_weight_option: fourDhumanoutfit # check options in loss_weight_configs.yaml
27+
iterations: 500
28+
lr: 0.01
29+
start_lr_decay_iteration: 450
30+
body_model: smpl
31+
use_landmarks: null # either "All", name of dict from landmarks.py or list of landmark names ["Lt. 10th Rib", "Lt. Dactylion",..]
32+
refine_params: ["pose"] #["pose", "shape", "transl", "scale"]
33+
use_losses: ["normal"]
34+
prior_folder: /SMPL-Fitting/data/prior
35+
num_gaussians: 8
36+
normal_threshold_angle: 30
37+
2538
general:
2639
verbose: False
2740
default_dtype: torch.float32

configs/loss_weight_configs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ fit_bm_loss_weight_strategy:
2929
"beta": 3}
3030
}
3131

32+
fourDhumanoutfit: {0: {"data": 5,
33+
"prior": 2.5,
34+
"normal": 3},
35+
36+
# 30: {"data": 1,
37+
# "prior": 0.1},
38+
39+
# 100: {"data": 0.2,
40+
# "prior": 0.1},
41+
42+
# # fit shape
43+
# 200: {"data": 1,
44+
# "prior": 0.1},
45+
46+
# 300: {"data": 1000,
47+
# "prior": 0.1}
48+
}
49+
3250
fit_verts_loss_weight_strategy:
3351

3452
default_option: {

0 commit comments

Comments
 (0)