Spaces:
Runtime error
Runtime error
rodragon737
commited on
Commit
•
63488c4
1
Parent(s):
47cfdde
mariposas
Browse files
app.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from utils import carga_modelo, general
|
4 |
+
|
5 |
+
## Página principal
|
6 |
+
st.title("generador de mariposas")
|
7 |
+
st.write("Modelo de Ligth Gan en streamlit")
|
utils.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.from_pretrained(model_name, versio=model_version)
|
7 |
+
gan.eval()
|
8 |
+
return gan
|
9 |
+
|
10 |
+
def general(gan, batch_size=1):
|
11 |
+
with torch.no_grad():
|
12 |
+
ims = gan.G(torch.rand(batch_size, gan.latent_dim)).clamp_(0.0, 1.0) * 255
|
13 |
+
ims = ims.permute(0,2,3,1).deatch().cpu().numpy().astype(np.uint8)
|
14 |
+
return ims
|