Spaces:
Runtime error
Runtime error
espejelomar
commited on
Commit
•
315db2e
1
Parent(s):
9b08ee7
Update utils.py
Browse files
utils.py
CHANGED
@@ -3,16 +3,16 @@ import torch
|
|
3 |
from huggan.pytorch.lightweight_gan.lightweight_gan import LightweightGAN
|
4 |
|
5 |
|
6 |
-
|
7 |
def carga_modelo(model_name="ceyda/butterfly_cropped_uniq1K_512", model_version=None):
|
8 |
gan = LightweightGAN.from_pretrained(model_name, version=model_version)
|
9 |
gan.eval()
|
10 |
return gan
|
11 |
|
12 |
|
13 |
-
|
14 |
def genera(gan, batch_size=1):
|
15 |
with torch.no_grad():
|
16 |
ims = gan.G(torch.randn(batch_size, gan.latent_dim)).clamp_(0.0, 1.0) * 255
|
17 |
-
ims = ims.permute(0,
|
18 |
-
return
|
|
|
3 |
from huggan.pytorch.lightweight_gan.lightweight_gan import LightweightGAN
|
4 |
|
5 |
|
6 |
+
|
7 |
def carga_modelo(model_name="ceyda/butterfly_cropped_uniq1K_512", model_version=None):
|
8 |
gan = LightweightGAN.from_pretrained(model_name, version=model_version)
|
9 |
gan.eval()
|
10 |
return gan
|
11 |
|
12 |
|
13 |
+
|
14 |
def genera(gan, batch_size=1):
|
15 |
with torch.no_grad():
|
16 |
ims = gan.G(torch.randn(batch_size, gan.latent_dim)).clamp_(0.0, 1.0) * 255
|
17 |
+
ims = ims.permute(0,2,3,1).detach().cpu().numpy().astype(np.uint8)
|
18 |
+
return
|