Spaces:
Running on Zero
Running on Zero
Download shape_models/encoder.py from daidedou/diffumatch: direct link, hf CLI and curl.
- Browser
- Download file 864 Bytes
-
https://huggingface.co/spaces/daidedou/diffumatch/resolve/3ccb54bbeec344157c8e15f61823efec01fdec05/shape_models/encoder.py
- Command line
-
hf download hf://spaces/daidedou/diffumatch@3ccb54bbeec344157c8e15f61823efec01fdec05/shape_models/encoder.py
-
curl -L -o encoder.py https://huggingface.co/spaces/daidedou/diffumatch/resolve/3ccb54bbeec344157c8e15f61823efec01fdec05/shape_models/encoder.py
864 Bytes
| import torch | |
| import torch.nn as nn | |
| from .layers import DiffusionNet | |
| class Encoder(nn.Module): | |
| def __init__(self, with_grad=True, key_verts="vertices"): | |
| super(Encoder, self).__init__() | |
| self.diff_net = DiffusionNet( | |
| C_in=3, | |
| C_out=512, | |
| C_width=128, | |
| N_block=4, | |
| dropout=True, | |
| with_gradient_features=with_grad, | |
| with_gradient_rotations=with_grad, | |
| ) | |
| self.key_verts = key_verts | |
| def forward(self, shape_dict): | |
| feats = self.diff_net(shape_dict[self.key_verts], shape_dict["mass"], shape_dict["L"], evals=shape_dict["evals"], | |
| evecs=shape_dict["evecs"], gradX=shape_dict["gradX"], gradY=shape_dict["gradY"], faces=shape_dict["faces"]) | |
| x_out = torch.max(feats, dim=0).values | |
| return x_out |