lmellory commited on
Commit
d945d1f
·
verified ·
1 Parent(s): d8ad324

update file

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -2,24 +2,23 @@ import gradio as gr
2
  from diffusers import StableDiffusionXLPipeline
3
  import torch
4
 
5
- # Load SDXL-Turbo (super fast, 4–10 sec per image, great quality)
6
- pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
 
 
7
  pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
8
 
9
- # Optimizations for free tier
10
- pipe.enable_model_cpu_offload()
11
-
12
  def generate(prompt, steps=4, guidance=0.0, seed=42):
13
  generator = torch.Generator("cuda").manual_seed(seed) if torch.cuda.is_available() else None
14
  image = pipe(prompt, num_inference_steps=steps, guidance_scale=guidance, generator=generator).images[0]
15
  return image
16
 
17
  with gr.Blocks() as demo:
18
- gr.Markdown("# Мой Epic AI Generator 🔥")
19
  gr.Markdown("Сделано для моей девушки ❤️ Генерирует арты за секунды! Попробуй на русском или английском.")
20
 
21
  with gr.Row():
22
- prompt = gr.Textbox(label="Prompt (описание)", placeholder="рыжий кот космонавт, highly detailed")
23
  steps = gr.Slider(1, 10, value=4, step=1, label="Шаги (steps) — 4 для скорости")
24
  guidance = gr.Slider(0, 5, value=0.0, step=0.5, label="Guidance (0 для Turbo)")
25
  seed = gr.Slider(0, 999999, value=42, label="Seed")
@@ -32,7 +31,7 @@ with gr.Blocks() as demo:
32
 
33
  gr.Markdown("### Примеры:")
34
  gr.Markdown("- 'милый рыжий кот в космосе'")
35
- gr.Markdown("- 'романтическая пара на закате пляжа'")
36
  gr.Markdown("- 'супергеройская пара в городе'")
37
 
38
  demo.launch()
 
2
  from diffusers import StableDiffusionXLPipeline
3
  import torch
4
 
5
+ # Load Turbo model with optimizations
6
+ pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", safety_checker=None)
7
+ pipe.enable_model_cpu_offload() # Ключ для бесплатного tier
8
+ pipe.enable_vae_slicing()
9
  pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
10
 
 
 
 
11
  def generate(prompt, steps=4, guidance=0.0, seed=42):
12
  generator = torch.Generator("cuda").manual_seed(seed) if torch.cuda.is_available() else None
13
  image = pipe(prompt, num_inference_steps=steps, guidance_scale=guidance, generator=generator).images[0]
14
  return image
15
 
16
  with gr.Blocks() as demo:
17
+ gr.Markdown("# Epic AI Art Generator 🔥")
18
  gr.Markdown("Сделано для моей девушки ❤️ Генерирует арты за секунды! Попробуй на русском или английском.")
19
 
20
  with gr.Row():
21
+ prompt = gr.Textbox(label="Prompt (описание)", placeholder="рыжий кот космонавт или romantic couple at sunset")
22
  steps = gr.Slider(1, 10, value=4, step=1, label="Шаги (steps) — 4 для скорости")
23
  guidance = gr.Slider(0, 5, value=0.0, step=0.5, label="Guidance (0 для Turbo)")
24
  seed = gr.Slider(0, 999999, value=42, label="Seed")
 
31
 
32
  gr.Markdown("### Примеры:")
33
  gr.Markdown("- 'милый рыжий кот в космосе'")
34
+ gr.Markdown("- 'романтическая пара на пляже на закате'")
35
  gr.Markdown("- 'супергеройская пара в городе'")
36
 
37
  demo.launch()