Spaces:
Configuration error
Configuration error
Download models/encoder4editing/utils/train_utils.py from miguelmuzo/HairSwapModel: direct link, hf CLI and curl.
- Browser
- Download file 377 Bytes
-
https://huggingface.co/spaces/miguelmuzo/HairSwapModel/resolve/main/models/encoder4editing/utils/train_utils.py
- Command line
-
hf download hf://spaces/miguelmuzo/HairSwapModel/models/encoder4editing/utils/train_utils.py
-
curl -L -o train_utils.py https://huggingface.co/spaces/miguelmuzo/HairSwapModel/resolve/main/models/encoder4editing/utils/train_utils.py
377 Bytes
| def aggregate_loss_dict(agg_loss_dict): | |
| mean_vals = {} | |
| for output in agg_loss_dict: | |
| for key in output: | |
| mean_vals[key] = mean_vals.setdefault(key, []) + [output[key]] | |
| for key in mean_vals: | |
| if len(mean_vals[key]) > 0: | |
| mean_vals[key] = sum(mean_vals[key]) / len(mean_vals[key]) | |
| else: | |
| print('{} has no value'.format(key)) | |
| mean_vals[key] = 0 | |
| return mean_vals | |