Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
return generated_image
|
15 |
|
|
|
16 |
iface = gr.Interface(
|
17 |
-
fn=
|
18 |
-
inputs=
|
19 |
outputs="image",
|
20 |
-
|
|
|
21 |
)
|
|
|
|
|
22 |
iface.launch()
|
23 |
|
24 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForConditionalGeneration, AutoTokenizer
|
3 |
+
import torch
|
4 |
|
5 |
+
# Cargar el modelo y el tokenizador
|
6 |
+
model = AutoModelForConditionalGeneration.from_pretrained("goofyai/3d_render_style_xl")
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("goofyai/3d_render_style_xl")
|
8 |
|
9 |
+
def generate_image(input_text):
|
10 |
+
# Tokenizar el texto de entrada
|
11 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
12 |
|
13 |
+
# Generar una imagen a partir del texto
|
14 |
+
with torch.no_grad():
|
15 |
+
generated_image = model.generate(input_ids)
|
16 |
|
17 |
return generated_image
|
18 |
|
19 |
+
# Crear una interfaz Gradio
|
20 |
iface = gr.Interface(
|
21 |
+
fn=generate_image,
|
22 |
+
inputs="text",
|
23 |
outputs="image",
|
24 |
+
title="Texto a Imagen",
|
25 |
+
description="Genera imágenes a partir de texto.",
|
26 |
)
|
27 |
+
|
28 |
+
# Ejecutar la interfaz
|
29 |
iface.launch()
|
30 |
|
31 |
|