amos1088 commited on
Commit
6c3f566
·
1 Parent(s): de93c44

test gradio

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -1,9 +1,9 @@
1
  import gradio as gr
2
  import torch
3
  from diffusers import (
4
- StableDiffusionControlNetPipeline,
5
  ControlNetModel,
6
- UNet2DConditionModel,
7
  AutoencoderKL,
8
  UniPCMultistepScheduler,
9
  )
@@ -21,18 +21,18 @@ controlnet_id = "lllyasviel/control_v11p_sd15_inpaint"
21
 
22
  # Load each model component required by the pipeline
23
  controlnet = ControlNetModel.from_pretrained(controlnet_id, torch_dtype=torch.float16)
24
- unet = UNet2DConditionModel.from_pretrained(model_id, subfolder="unet", torch_dtype=torch.float16)
25
  vae = AutoencoderKL.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float16)
26
  feature_extractor = CLIPFeatureExtractor.from_pretrained(model_id)
27
  text_encoder = CLIPTextModel.from_pretrained(model_id, subfolder="text_encoder")
28
  tokenizer = CLIPTokenizer.from_pretrained(model_id)
29
 
30
  # Initialize the pipeline with all components
31
- pipeline = StableDiffusionControlNetPipeline(
 
32
  vae=vae,
33
  text_encoder=text_encoder,
34
  tokenizer=tokenizer,
35
- unet=unet,
36
  controlnet=controlnet,
37
  scheduler=UniPCMultistepScheduler.from_config({"name": "UniPCMultistepScheduler"}),
38
  feature_extractor=feature_extractor,
@@ -69,7 +69,7 @@ interface = gr.Interface(
69
  ],
70
  outputs="image",
71
  title="Image Generation with ControlNet (Reference-Only Style Transfer)",
72
- description="Generates an image based on a text prompt and style reference image using Stable Diffusion and ControlNet (reference-only mode)."
73
  )
74
 
75
  # Launch the Gradio interface
 
1
  import gradio as gr
2
  import torch
3
  from diffusers import (
4
+ StableDiffusion3Pipeline, # For SD3 models like Stable Diffusion 3.5
5
  ControlNetModel,
6
+ SD3Transformer2DModel, # Replacing UNet with SD3 transformer
7
  AutoencoderKL,
8
  UniPCMultistepScheduler,
9
  )
 
21
 
22
  # Load each model component required by the pipeline
23
  controlnet = ControlNetModel.from_pretrained(controlnet_id, torch_dtype=torch.float16)
24
+ transformer = SD3Transformer2DModel.from_pretrained(model_id, subfolder="transformer", torch_dtype=torch.float16)
25
  vae = AutoencoderKL.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float16)
26
  feature_extractor = CLIPFeatureExtractor.from_pretrained(model_id)
27
  text_encoder = CLIPTextModel.from_pretrained(model_id, subfolder="text_encoder")
28
  tokenizer = CLIPTokenizer.from_pretrained(model_id)
29
 
30
  # Initialize the pipeline with all components
31
+ pipeline = StableDiffusion3Pipeline(
32
+ transformer=transformer, # Using SD3 transformer
33
  vae=vae,
34
  text_encoder=text_encoder,
35
  tokenizer=tokenizer,
 
36
  controlnet=controlnet,
37
  scheduler=UniPCMultistepScheduler.from_config({"name": "UniPCMultistepScheduler"}),
38
  feature_extractor=feature_extractor,
 
69
  ],
70
  outputs="image",
71
  title="Image Generation with ControlNet (Reference-Only Style Transfer)",
72
+ description="Generates an image based on a text prompt and style reference image using Stable Diffusion 3.5 and ControlNet (reference-only mode)."
73
  )
74
 
75
  # Launch the Gradio interface