Spaces:
Runtime error
Runtime error
macadeliccc
commited on
Commit
·
7f45d73
1
Parent(s):
94c19a4
test
Browse files
app.py
CHANGED
@@ -9,14 +9,6 @@ import uuid
|
|
9 |
import io
|
10 |
import os
|
11 |
|
12 |
-
# Load the base & refiner pipelines
|
13 |
-
base = DiffusionPipeline.from_pretrained(
|
14 |
-
"stabilityai/stable-diffusion-xl-base-1.0",
|
15 |
-
torch_dtype=torch.float16,
|
16 |
-
variant="fp16",
|
17 |
-
use_safetensors=True
|
18 |
-
)
|
19 |
-
base.to("cuda:0")
|
20 |
|
21 |
# Load your model
|
22 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
@@ -25,6 +17,7 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
25 |
use_safetensors=True,
|
26 |
variant="fp16"
|
27 |
)
|
|
|
28 |
pipe.to("cuda:0")
|
29 |
|
30 |
|
@@ -45,19 +38,6 @@ def generate_and_save_image(prompt, negative_prompt=''):
|
|
45 |
# Return the path of the saved image to display in Gradio interface
|
46 |
return image_path
|
47 |
|
48 |
-
def generate_image_with_refinement(prompt):
|
49 |
-
n_steps = 40
|
50 |
-
high_noise_frac = 0.8
|
51 |
-
|
52 |
-
# run both experts
|
53 |
-
image = base(prompt=prompt).images[0]
|
54 |
-
# Save the image as before
|
55 |
-
unique_id = str(uuid.uuid4())
|
56 |
-
image_path = f"generated_images_refined/{unique_id}.jpeg"
|
57 |
-
os.makedirs('generated_images_refined', exist_ok=True)
|
58 |
-
image.save(image_path, format='JPEG')
|
59 |
-
|
60 |
-
return image_path
|
61 |
|
62 |
# Start of the Gradio Blocks interface
|
63 |
with gr.Blocks() as demo:
|
@@ -83,25 +63,6 @@ with gr.Blocks() as demo:
|
|
83 |
outputs=output_image1
|
84 |
)
|
85 |
|
86 |
-
with gr.Column():
|
87 |
-
gr.Markdown("## SDXL 1.0")
|
88 |
-
gr.Markdown("Enter a prompt to generate an image.")
|
89 |
-
|
90 |
-
# Input field for the prompt
|
91 |
-
prompt2 = gr.Textbox(label="Enter prompt for refined generation")
|
92 |
-
|
93 |
-
# Button for generating the refined image
|
94 |
-
generate_button2 = gr.Button("Generate Refined Image")
|
95 |
-
|
96 |
-
# Output refined image display, set to a larger default size
|
97 |
-
output_image2 = gr.Image(label="Generated Refined Image")
|
98 |
-
|
99 |
-
# Click event for the generate button
|
100 |
-
generate_button2.click(
|
101 |
-
generate_image_with_refinement,
|
102 |
-
inputs=[prompt2],
|
103 |
-
outputs=output_image2
|
104 |
-
)
|
105 |
|
106 |
# Launch the combined Gradio app
|
107 |
demo.launch()
|
|
|
9 |
import io
|
10 |
import os
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Load your model
|
14 |
pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
|
17 |
use_safetensors=True,
|
18 |
variant="fp16"
|
19 |
)
|
20 |
+
|
21 |
pipe.to("cuda:0")
|
22 |
|
23 |
|
|
|
38 |
# Return the path of the saved image to display in Gradio interface
|
39 |
return image_path
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
# Start of the Gradio Blocks interface
|
43 |
with gr.Blocks() as demo:
|
|
|
63 |
outputs=output_image1
|
64 |
)
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
# Launch the combined Gradio app
|
68 |
demo.launch()
|