Manjushri commited on
Commit
eff24e3
·
verified ·
1 Parent(s): 5baa1fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -34
app.py CHANGED
@@ -35,42 +35,9 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed):
35
  torch.cuda.empty_cache()
36
  return image
37
 
38
- if Model == "SD3.5 Turbo":
39
- torch.cuda.max_memory_allocated(device=device)
40
- torch.cuda.empty_cache()
41
- progress=gr.Progress(track_tqdm=True)
42
- from diffusers import BitsAndBytesConfig, SD3Transformer2DModel
43
- from diffusers import StableDiffusion3Pipeline
44
-
45
-
46
- model_id = "stabilityai/stable-diffusion-3.5-large-turbo"
47
-
48
- nf4_config = BitsAndBytesConfig(
49
- load_in_4bit=True,
50
- bnb_4bit_quant_type="nf4",
51
- bnb_4bit_compute_dtype=torch.bfloat16)
52
- model_nf4 = SD3Transformer2DModel.from_pretrained(
53
- model_id,
54
- subfolder="transformer",
55
- quantization_config=nf4_config,
56
- torch_dtype=torch.bfloat16)
57
-
58
- t5_nf4 = T5EncoderModel.from_pretrained("diffusers/t5-nf4", torch_dtype=torch.bfloat16)
59
-
60
- pipe = StableDiffusion3Pipeline.from_pretrained(
61
- model_id,
62
- transformer=model_nf4,
63
- text_encoder_3=t5_nf4,
64
- torch_dtype=torch.bfloat16)
65
- pipe.enable_model_cpu_offload()
66
- pipe.vae.enable_slicing()
67
- pipe.vae.enable_tiling()
68
- torch.cuda.empty_cache()
69
- image = pipe(prompt=Prompt, negative_prompt=negative_prompt, guidance_scale=0.0, num_inference_steps=4, width=1024, height=1024, generator=generator,).images[0]
70
- torch.cuda.empty_cache()
71
  return image
72
 
73
- gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Animagine XL 4', "SD3.5 Turbo"], value='PhotoReal', label='Choose Model'),
74
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
75
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
76
  gr.Slider(512, 1024, 768, step=128, label='Height'),
 
35
  torch.cuda.empty_cache()
36
  return image
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  return image
39
 
40
+ gr.Interface(fn=genie, inputs=[gr.Radio(['PhotoReal', 'Animagine XL 4',], value='PhotoReal', label='Choose Model'),
41
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
42
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
43
  gr.Slider(512, 1024, 768, step=128, label='Height'),