Spaces:
Sleeping
Sleeping
texts
Browse files
app.py
CHANGED
@@ -23,7 +23,6 @@ def GenerateImage(prompt,steps,progress,model):
|
|
23 |
vae = pipe_txt2img.vae
|
24 |
|
25 |
def latents_callback(i, t, latents):
|
26 |
-
print("Latents...");
|
27 |
latents = 1 / 0.18215 * latents
|
28 |
image = vae.decode(latents).sample[0]
|
29 |
image = (image / 2 + 0.5).clamp(0, 1)
|
@@ -43,14 +42,11 @@ def GenerateImage(prompt,steps,progress,model):
|
|
43 |
print("Waiting next item");
|
44 |
nextItem = queue.get()
|
45 |
|
46 |
-
print(f"NextItem: {nextItem}");
|
47 |
-
|
48 |
if nextItem['type'] == 'end':
|
49 |
break;
|
50 |
|
51 |
Image = nextItem['image']
|
52 |
Step = nextItem['step']
|
53 |
-
print(f"Image: {Image}")
|
54 |
yield [Image,Step];
|
55 |
|
56 |
print("Waiting thread finish...");
|
@@ -61,9 +57,14 @@ def GenerateImage(prompt,steps,progress,model):
|
|
61 |
|
62 |
|
63 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
64 |
with gr.Row():
|
65 |
-
prompt = gr.Text(label="
|
66 |
-
TotalSteps = gr.Slider(label="
|
67 |
ProgressSteps = gr.Number(label="Progress steps", value = 2);
|
68 |
model = gr.Text(label="Model", value="dreamlike-art/dreamlike-photoreal-2.0")
|
69 |
|
|
|
23 |
vae = pipe_txt2img.vae
|
24 |
|
25 |
def latents_callback(i, t, latents):
|
|
|
26 |
latents = 1 / 0.18215 * latents
|
27 |
image = vae.decode(latents).sample[0]
|
28 |
image = (image / 2 + 0.5).clamp(0, 1)
|
|
|
42 |
print("Waiting next item");
|
43 |
nextItem = queue.get()
|
44 |
|
|
|
|
|
45 |
if nextItem['type'] == 'end':
|
46 |
break;
|
47 |
|
48 |
Image = nextItem['image']
|
49 |
Step = nextItem['step']
|
|
|
50 |
yield [Image,Step];
|
51 |
|
52 |
print("Waiting thread finish...");
|
|
|
57 |
|
58 |
|
59 |
with gr.Blocks() as demo:
|
60 |
+
gr.Markdown("""
|
61 |
+
This is a lab to demonstrate how we can implement a text-to-image generation using Gradio and Diffusers, showing the progress of each image produced at each step.
|
62 |
+
Type a prompt, choose the maximum number of steps and the frequency (in steps) at which progress is shown. You will see the diffusion process live!
|
63 |
+
""")
|
64 |
+
|
65 |
with gr.Row():
|
66 |
+
prompt = gr.Text(label="prompt");
|
67 |
+
TotalSteps = gr.Slider(label="Steps", minimum=1,maximum=150,value=10);
|
68 |
ProgressSteps = gr.Number(label="Progress steps", value = 2);
|
69 |
model = gr.Text(label="Model", value="dreamlike-art/dreamlike-photoreal-2.0")
|
70 |
|