Spaces:
Runtime error
Runtime error
Commit
·
f5bd4a2
1
Parent(s):
93efdd0
Delete utils.py
Browse files
utils.py
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
import torch
|
3 |
-
from huggan.pytorch.lightweight_gan.lightweight_gan import LightweightGAN
|
4 |
-
|
5 |
-
def carga_modelo(model_name = 'ceyda/butterfly_cropped_uniq1K_512', model_version = None):
|
6 |
-
gan = LightweightGAN(model_name, model_version)
|
7 |
-
gan.eval()
|
8 |
-
return gan
|
9 |
-
|
10 |
-
def genera(gan, batch_size = 1):
|
11 |
-
with torch.no_grad(): #no queremos entrenar el modelo
|
12 |
-
ims = gan.G(torch.randn(batch_size, gan.latent_dim)).clamp(0.0,1.0) * 255 #generamos imágenes y las aplastamos entre 0 y 1
|
13 |
-
ims = ims.permute(0,2,3,1).detach().cpu().numpy().astype(np.uint8) #las pasamos a numpy
|
14 |
-
return ims
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|