macadeliccc commited on
Commit
767f83e
1 Parent(s): cd34978
Files changed (1) hide show
  1. app.py +4 -25
app.py CHANGED
@@ -27,18 +27,9 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
27
  )
28
  pipe.to("cuda:0")
29
 
30
- refiner = DiffusionPipeline.from_pretrained(
31
- "stabilityai/stable-diffusion-xl-refiner-1.0",
32
- text_encoder_2=base.text_encoder_2,
33
- torch_dtype=torch.float16,
34
- vae=base.vae,
35
- use_safetensors=True,
36
- variant="fp16",
37
- )
38
- refiner.to("cuda:0")
39
 
40
 
41
- @spaces.GPU # Apply the GPU decorator
42
  def generate_and_save_image(prompt, negative_prompt=''):
43
  # Generate image using the provided prompts
44
  image = pipe(prompt=prompt, negative_prompt=negative_prompt).images[0]
@@ -59,19 +50,7 @@ def generate_image_with_refinement(prompt):
59
  high_noise_frac = 0.8
60
 
61
  # run both experts
62
- image = base(
63
- prompt=prompt,
64
- num_inference_steps=n_steps,
65
- denoising_end=high_noise_frac,
66
- output_type="latent",
67
- ).images
68
- image = refiner(
69
- prompt=prompt,
70
- num_inference_steps=n_steps,
71
- denoising_start=high_noise_frac,
72
- image=image,
73
- ).images[0]
74
-
75
  # Save the image as before
76
  unique_id = str(uuid.uuid4())
77
  image_path = f"generated_images_refined/{unique_id}.jpeg"
@@ -105,8 +84,8 @@ with gr.Blocks() as demo:
105
  )
106
 
107
  with gr.Column():
108
- gr.Markdown("## Refined Image Generation")
109
- gr.Markdown("Enter a prompt to generate a refined image.")
110
 
111
  # Input field for the prompt
112
  prompt2 = gr.Textbox(label="Enter prompt for refined generation")
 
27
  )
28
  pipe.to("cuda:0")
29
 
 
 
 
 
 
 
 
 
 
30
 
31
 
32
+ @spaces.GPU
33
  def generate_and_save_image(prompt, negative_prompt=''):
34
  # Generate image using the provided prompts
35
  image = pipe(prompt=prompt, negative_prompt=negative_prompt).images[0]
 
50
  high_noise_frac = 0.8
51
 
52
  # run both experts
53
+ image = pipe(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"
 
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")