Spaces:
Runtime error
Runtime error
update
Browse files- __pycache__/app.cpython-38.pyc +0 -0
- app.py +18 -8
__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
|
@@ -1,5 +1,6 @@
|
|
| 1 |
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
import torch
|
| 5 |
from diffusers import DiffusionPipeline
|
|
@@ -8,6 +9,9 @@ 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
|
|
@@ -25,11 +29,8 @@ Una noche, el ladrón desenterró el oro y se lo llevó. Cuando el rico descubri
|
|
| 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 = []
|
|
@@ -45,10 +46,14 @@ def generate_texts_array(text, max_length = 70):
|
|
| 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):
|
|
@@ -56,6 +61,8 @@ def generation_test(img):
|
|
| 56 |
images.append(img)
|
| 57 |
images.append(img)
|
| 58 |
images.append(img)
|
|
|
|
|
|
|
| 59 |
return images
|
| 60 |
|
| 61 |
demo = gr.Blocks()
|
|
@@ -73,6 +80,7 @@ with demo:
|
|
| 73 |
info="Escribe una historia",
|
| 74 |
lines=5,
|
| 75 |
value='Erase una vez..')
|
|
|
|
| 76 |
#img_input = gr.Image (type='pil')
|
| 77 |
button = gr.Button(value="Generate")
|
| 78 |
|
|
@@ -88,6 +96,8 @@ with demo:
|
|
| 88 |
imgs_output.append(gr.Image())
|
| 89 |
imgs_output.append(gr.Image())
|
| 90 |
imgs_output.append(gr.Image())
|
|
|
|
|
|
|
| 91 |
|
| 92 |
button.click(generation, inputs=text_input, outputs=imgs_output)
|
| 93 |
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
+
#from transformers import pipeline
|
| 4 |
|
| 5 |
import torch
|
| 6 |
from diffusers import DiffusionPipeline
|
|
|
|
| 9 |
|
| 10 |
inCloud = True
|
| 11 |
|
| 12 |
+
#translator = pipeline("translation", model = "Helsinki-NLP/opus-mt-es-en")
|
| 13 |
+
pipe = ''
|
| 14 |
+
|
| 15 |
if inCloud:
|
| 16 |
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
| 17 |
if platform.system() == "Darwin": #Apple OS
|
|
|
|
| 29 |
—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.'''
|
| 30 |
]
|
| 31 |
|
| 32 |
+
#def translate(text):
|
| 33 |
+
# return translator(text)[0]["translation_text"]
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
def generate_texts_array(text, max_length = 70):
|
| 36 |
text_array = []
|
|
|
|
| 46 |
|
| 47 |
def generation(text):
|
| 48 |
images = []
|
| 49 |
+
steps = 5
|
| 50 |
+
#translate_text = translate(text)
|
| 51 |
text_array = generate_texts_array(text)
|
| 52 |
+
images.append(pipe(text_array[0],num_inference_steps=steps).images[0])
|
| 53 |
+
images.append(pipe(text_array[1],num_inference_steps=steps).images[0])
|
| 54 |
+
images.append(pipe(text_array[2],num_inference_steps=steps).images[0])
|
| 55 |
+
images.append(pipe(text_array[3],num_inference_steps=steps).images[0])
|
| 56 |
+
images.append(pipe(text_array[4],num_inference_steps=steps).images[0])
|
| 57 |
return images
|
| 58 |
|
| 59 |
def generation_test(img):
|
|
|
|
| 61 |
images.append(img)
|
| 62 |
images.append(img)
|
| 63 |
images.append(img)
|
| 64 |
+
images.append(img)
|
| 65 |
+
images.append(img)
|
| 66 |
return images
|
| 67 |
|
| 68 |
demo = gr.Blocks()
|
|
|
|
| 80 |
info="Escribe una historia",
|
| 81 |
lines=5,
|
| 82 |
value='Erase una vez..')
|
| 83 |
+
#steps_input = gr.Number(value=20)
|
| 84 |
#img_input = gr.Image (type='pil')
|
| 85 |
button = gr.Button(value="Generate")
|
| 86 |
|
|
|
|
| 96 |
imgs_output.append(gr.Image())
|
| 97 |
imgs_output.append(gr.Image())
|
| 98 |
imgs_output.append(gr.Image())
|
| 99 |
+
imgs_output.append(gr.Image())
|
| 100 |
+
imgs_output.append(gr.Image())
|
| 101 |
|
| 102 |
button.click(generation, inputs=text_input, outputs=imgs_output)
|
| 103 |
|