Spaces:
Runtime error
Runtime error
Gustavo Belfort
commited on
change interface
Browse files- interface.py +10 -14
interface.py
CHANGED
|
@@ -19,25 +19,21 @@ with open(cached_download(hf_hub_url('ykilcher/apes', 'gamma500/network-snapshot
|
|
| 19 |
G = pickle.load(f)["G_ema"] # torch.nn.Module
|
| 20 |
|
| 21 |
device = torch.device("cpu")
|
| 22 |
-
|
| 23 |
-
device = torch.device("cuda")
|
| 24 |
-
G = G.to(device)
|
| 25 |
-
else:
|
| 26 |
-
_old_forward = G.forward
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
|
| 43 |
def generate(
|
|
|
|
| 19 |
G = pickle.load(f)["G_ema"] # torch.nn.Module
|
| 20 |
|
| 21 |
device = torch.device("cpu")
|
| 22 |
+
_old_forward = G.forward
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
def _new_forward(self, *args, **kwargs):
|
| 25 |
+
kwargs["force_fp32"] = True
|
| 26 |
+
return _old_forward(*args, **kwargs)
|
| 27 |
|
| 28 |
+
G.forward = types.MethodType(_new_forward, G)
|
| 29 |
|
| 30 |
+
_old_synthesis_forward = G.synthesis.forward
|
| 31 |
|
| 32 |
+
def _new_synthesis_forward(self, *args, **kwargs):
|
| 33 |
+
kwargs["force_fp32"] = True
|
| 34 |
+
return _old_synthesis_forward(*args, **kwargs)
|
| 35 |
|
| 36 |
+
G.synthesis.forward = types.MethodType(_new_synthesis_forward, G.synthesis)
|
| 37 |
|
| 38 |
|
| 39 |
def generate(
|