Student3331 commited on
Commit
bcafb3a
·
verified ·
1 Parent(s): 94cb0ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -18,11 +18,11 @@ def generate_image(prompt, negative_prompt, seed, randomize_seed, width, height,
18
  seed = random.randint(0, MAX_SEED)
19
 
20
  # Initialize the generator with the seed
21
- generator = torch.Generator().manual_seed(seed)
22
 
23
- # Load the diffusion pipeline
24
  print("Loading model...")
25
- pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
26
  pipe.enable_xformers_memory_efficient_attention()
27
  pipe = pipe.to(device) # Move the model to the GPU (or CPU if no GPU available)
28
 
@@ -124,7 +124,7 @@ with gr.Blocks(css=css) as demo:
124
  guidance_scale = gr.Slider(
125
  label="Guidance scale",
126
  minimum=0.0,
127
- maximum=10.0,
128
  step=0.1,
129
  value=7.5, # Set a higher value for better image guidance
130
  )
 
18
  seed = random.randint(0, MAX_SEED)
19
 
20
  # Initialize the generator with the seed
21
+ generator = torch.Generator(device=device).manual_seed(seed) # Ensure generator is on the correct device
22
 
23
+ # Load the diffusion pipeline with float32 precision (avoiding issues with fp16)
24
  print("Loading model...")
25
+ pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
26
  pipe.enable_xformers_memory_efficient_attention()
27
  pipe = pipe.to(device) # Move the model to the GPU (or CPU if no GPU available)
28
 
 
124
  guidance_scale = gr.Slider(
125
  label="Guidance scale",
126
  minimum=0.0,
127
+ maximum=20.0, # Increase max value to allow better guidance
128
  step=0.1,
129
  value=7.5, # Set a higher value for better image guidance
130
  )