Spaces:
Runtime error
Runtime error
update x
Browse files- __pycache__/app.cpython-38.pyc +0 -0
- app.py +23 -11
__pycache__/app.cpython-38.pyc
CHANGED
Binary files a/__pycache__/app.cpython-38.pyc and b/__pycache__/app.cpython-38.pyc differ
|
|
app.py
CHANGED
@@ -4,11 +4,14 @@ import gradio as gr
|
|
4 |
import torch
|
5 |
from diffusers import DiffusionPipeline
|
6 |
|
7 |
-
|
|
|
|
|
8 |
|
9 |
if inCloud:
|
10 |
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
11 |
-
|
|
|
12 |
#pipe = pipe.to("cuda")
|
13 |
|
14 |
# Recommended if your computer has < 64 GB of RAM
|
@@ -22,19 +25,30 @@ Una noche, el ladrón desenterró el oro y se lo llevó. Cuando el rico descubri
|
|
22 |
—Aquí tiene su tesoro. Sabe que nunca habría gastado sus lingotes. ¿Qué más le da, entonces, que sean piedras? Así por lo menos dejará de sufrir.'''
|
23 |
]
|
24 |
|
|
|
|
|
25 |
def translate(text):
|
26 |
new_text = text
|
27 |
return new_text
|
28 |
|
29 |
-
def
|
30 |
-
text_array =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return text_array
|
32 |
|
33 |
-
def generation(
|
34 |
images = []
|
|
|
35 |
images.append(pipe(text_array[0]).images[0])
|
36 |
-
images.append(pipe(text_array[
|
37 |
-
images.append(pipe(text_array[
|
38 |
return images
|
39 |
|
40 |
def generation_test(img):
|
@@ -46,8 +60,8 @@ def generation_test(img):
|
|
46 |
|
47 |
demo = gr.Blocks()
|
48 |
|
49 |
-
title = '#
|
50 |
-
description = '
|
51 |
|
52 |
with demo:
|
53 |
gr.Markdown(title)
|
@@ -66,10 +80,8 @@ with demo:
|
|
66 |
examples=textos,
|
67 |
inputs=text_input,
|
68 |
#outputs=im_2,
|
69 |
-
|
70 |
)
|
71 |
|
72 |
-
|
73 |
|
74 |
with gr.Row():
|
75 |
imgs_output = []
|
|
|
4 |
import torch
|
5 |
from diffusers import DiffusionPipeline
|
6 |
|
7 |
+
import platform
|
8 |
+
|
9 |
+
inCloud = True
|
10 |
|
11 |
if inCloud:
|
12 |
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
13 |
+
if platform.system() == "Darwin": #Apple OS
|
14 |
+
pipe = pipe.to("mps")
|
15 |
#pipe = pipe.to("cuda")
|
16 |
|
17 |
# Recommended if your computer has < 64 GB of RAM
|
|
|
25 |
—Aquí tiene su tesoro. Sabe que nunca habría gastado sus lingotes. ¿Qué más le da, entonces, que sean piedras? Así por lo menos dejará de sufrir.'''
|
26 |
]
|
27 |
|
28 |
+
|
29 |
+
|
30 |
def translate(text):
|
31 |
new_text = text
|
32 |
return new_text
|
33 |
|
34 |
+
def generate_texts_array(text, max_length = 70):
|
35 |
+
text_array = []
|
36 |
+
start = 0
|
37 |
+
|
38 |
+
while start < len(text):
|
39 |
+
end = start + max_length
|
40 |
+
part = text[start:end]
|
41 |
+
text_array.append(part)
|
42 |
+
start = end
|
43 |
+
|
44 |
return text_array
|
45 |
|
46 |
+
def generation(text):
|
47 |
images = []
|
48 |
+
text_array = generate_texts_array(text)
|
49 |
images.append(pipe(text_array[0]).images[0])
|
50 |
+
images.append(pipe(text_array[1]).images[0])
|
51 |
+
images.append(pipe(text_array[2]).images[0])
|
52 |
return images
|
53 |
|
54 |
def generation_test(img):
|
|
|
60 |
|
61 |
demo = gr.Blocks()
|
62 |
|
63 |
+
title = '# Generando historias graficas '
|
64 |
+
description = 'Escribe un texto y se generara una secuencia de imagenes basadas en el texto proporcionado'
|
65 |
|
66 |
with demo:
|
67 |
gr.Markdown(title)
|
|
|
80 |
examples=textos,
|
81 |
inputs=text_input,
|
82 |
#outputs=im_2,
|
|
|
83 |
)
|
84 |
|
|
|
85 |
|
86 |
with gr.Row():
|
87 |
imgs_output = []
|