Spaces:
Runtime error
Runtime error
Commit
·
abdc685
1
Parent(s):
ea10931
Update app.py
Browse files
app.py
CHANGED
@@ -9,13 +9,13 @@ has_cuda = torch.cuda.is_available()
|
|
9 |
device = torch.device('cpu' if not has_cuda else 'cuda')
|
10 |
pipe = pipe.to(device)
|
11 |
|
12 |
-
def
|
13 |
samples = 4
|
14 |
generator = torch.Generator(device=device)
|
15 |
torch.cuda.empty_cache()
|
16 |
with autocast("cuda"):
|
17 |
images_list = pipe(
|
18 |
-
[
|
19 |
height=256, width=384,
|
20 |
num_inference_steps=50,
|
21 |
)
|
@@ -25,15 +25,7 @@ def inference(diffusion_prompt):
|
|
25 |
return images
|
26 |
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
lines=1,
|
33 |
-
placeholder="Enter your prompt..",
|
34 |
-
interactive=True,
|
35 |
-
label="Prompt"
|
36 |
-
)
|
37 |
-
submit = gr.Button("Run")
|
38 |
-
submit.click(fn=inference, inputs=[prompt], outputs=[images])
|
39 |
-
demo.launch()
|
|
|
9 |
device = torch.device('cpu' if not has_cuda else 'cuda')
|
10 |
pipe = pipe.to(device)
|
11 |
|
12 |
+
def convert(prompt):
|
13 |
samples = 4
|
14 |
generator = torch.Generator(device=device)
|
15 |
torch.cuda.empty_cache()
|
16 |
with autocast("cuda"):
|
17 |
images_list = pipe(
|
18 |
+
[prompt] * samples,
|
19 |
height=256, width=384,
|
20 |
num_inference_steps=50,
|
21 |
)
|
|
|
25 |
return images
|
26 |
|
27 |
|
28 |
+
gr.Interface(convert,
|
29 |
+
inputs = [gr.inputs.Textbox(label="Enter text")],
|
30 |
+
outputs = [gr.outputs.Image(label="Generated Image")],
|
31 |
+
title="Text to Image Generation").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|