Spaces:
Runtime error
Runtime error
update first test
Browse files- __pycache__/app.cpython-38.pyc +0 -0
- app.py +54 -16
__pycache__/app.cpython-38.pyc
ADDED
Binary file (2.41 kB). View file
|
|
app.py
CHANGED
@@ -4,26 +4,49 @@ import gradio as gr
|
|
4 |
import torch
|
5 |
from diffusers import DiffusionPipeline
|
6 |
|
7 |
-
|
8 |
-
#pipe = pipe.to("mps")
|
9 |
-
pipe = pipe.to("cuda")
|
10 |
|
11 |
-
|
12 |
-
pipe.
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
demo = gr.Blocks()
|
25 |
|
26 |
-
title = '# 3D print
|
27 |
description = 'App for detect errors in the 3D printing'
|
28 |
|
29 |
with demo:
|
@@ -31,15 +54,30 @@ with demo:
|
|
31 |
gr.Markdown(description)
|
32 |
|
33 |
with gr.Row():
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
|
39 |
with gr.Row():
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
-
button.click(
|
43 |
|
44 |
|
45 |
|
|
|
4 |
import torch
|
5 |
from diffusers import DiffusionPipeline
|
6 |
|
7 |
+
inCloud = true
|
|
|
|
|
8 |
|
9 |
+
if inCloud:
|
10 |
+
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
11 |
+
#pipe = pipe.to("mps")
|
12 |
+
#pipe = pipe.to("cuda")
|
13 |
|
14 |
+
# Recommended if your computer has < 64 GB of RAM
|
15 |
+
pipe.enable_attention_slicing()
|
16 |
|
17 |
+
textos = [
|
18 |
+
'''脡rase una vez un hombre muy rico que vendi贸 todo lo que ten铆a a cambio de varios lingotes de oro. Y para que nadie le robara, enterr贸 el oro en un bosque. Todos los d铆as acud铆a al lugar para comprobar que su oro segu铆a all铆, sin saber que un ladr贸n lo vigilaba escondido.
|
19 |
|
20 |
+
Una noche, el ladr贸n desenterr贸 el oro y se lo llev贸. Cuando el rico descubri贸 el robo, dio tal grito que un vecino se acerc贸 a ver qu茅 pasaba. El hombre rico lloraba, desesperado. Entonces el vecino tom贸 unas piedras, las enterr贸 en el mismo lugar y dijo:
|
21 |
|
22 |
+
鈥擜qu铆 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 generate_text_array(text):
|
30 |
+
text_array = text.split('\n\n')
|
31 |
+
return text_array
|
32 |
+
|
33 |
+
def generation(text_array):
|
34 |
+
images = []
|
35 |
+
images.append(pipe(text_array[0]).images[0])
|
36 |
+
images.append(pipe(text_array[0]).images[0])
|
37 |
+
images.append(pipe(text_array[0]).images[0])
|
38 |
+
return images
|
39 |
+
|
40 |
+
def generation_test(img):
|
41 |
+
images = []
|
42 |
+
images.append(img)
|
43 |
+
images.append(img)
|
44 |
+
images.append(img)
|
45 |
+
return images
|
46 |
|
47 |
demo = gr.Blocks()
|
48 |
|
49 |
+
title = '# 3D print '
|
50 |
description = 'App for detect errors in the 3D printing'
|
51 |
|
52 |
with demo:
|
|
|
54 |
gr.Markdown(description)
|
55 |
|
56 |
with gr.Row():
|
57 |
+
with gr.Column():
|
58 |
+
text_input = gr.Textbox ( label="Cuento",
|
59 |
+
info="Escribe una historia",
|
60 |
+
lines=5,
|
61 |
+
value='Erase una vez..')
|
62 |
+
#img_input = gr.Image (type='pil')
|
63 |
+
button = gr.Button(value="Generate")
|
64 |
+
|
65 |
+
gr.Examples(
|
66 |
+
examples=textos,
|
67 |
+
inputs=text_input,
|
68 |
+
#outputs=im_2,
|
69 |
|
70 |
+
)
|
71 |
+
|
72 |
|
73 |
|
74 |
with gr.Row():
|
75 |
+
imgs_output = []
|
76 |
+
imgs_output.append(gr.Image())
|
77 |
+
imgs_output.append(gr.Image())
|
78 |
+
imgs_output.append(gr.Image())
|
79 |
|
80 |
+
button.click(generation, inputs=text_input, outputs=imgs_output)
|
81 |
|
82 |
|
83 |
|