Spaces:
Runtime error
Runtime error
Upload model/archs/mlp_head.py with huggingface_hub
Browse files- model/archs/mlp_head.py +40 -0
model/archs/mlp_head.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch.nn as nn
|
| 2 |
+
import torch.nn.functional as F
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class SdfMlp(nn.Module):
|
| 6 |
+
def __init__(self, input_dim, hidden_dim=512, bias=True):
|
| 7 |
+
super().__init__()
|
| 8 |
+
self.input_dim = input_dim
|
| 9 |
+
self.hidden_dim = hidden_dim
|
| 10 |
+
|
| 11 |
+
self.fc1 = nn.Linear(input_dim, hidden_dim, bias=bias)
|
| 12 |
+
self.fc2 = nn.Linear(hidden_dim, hidden_dim, bias=bias)
|
| 13 |
+
self.fc3 = nn.Linear(hidden_dim, 4, bias=bias)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def forward(self, input):
|
| 17 |
+
x = F.relu(self.fc1(input))
|
| 18 |
+
x = F.relu(self.fc2(x))
|
| 19 |
+
out = self.fc3(x)
|
| 20 |
+
return out
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class RgbMlp(nn.Module):
|
| 24 |
+
def __init__(self, input_dim, hidden_dim=512, bias=True):
|
| 25 |
+
super().__init__()
|
| 26 |
+
self.input_dim = input_dim
|
| 27 |
+
self.hidden_dim = hidden_dim
|
| 28 |
+
|
| 29 |
+
self.fc1 = nn.Linear(input_dim, hidden_dim, bias=bias)
|
| 30 |
+
self.fc2 = nn.Linear(hidden_dim, hidden_dim, bias=bias)
|
| 31 |
+
self.fc3 = nn.Linear(hidden_dim, 3, bias=bias)
|
| 32 |
+
|
| 33 |
+
def forward(self, input):
|
| 34 |
+
x = F.relu(self.fc1(input))
|
| 35 |
+
x = F.relu(self.fc2(x))
|
| 36 |
+
out = self.fc3(x)
|
| 37 |
+
|
| 38 |
+
return out
|
| 39 |
+
|
| 40 |
+
|