amos1088 commited on
Commit
cd0d25d
·
1 Parent(s): 7d9ea7a

test gradio

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -4,19 +4,34 @@ from diffusers import StableDiffusion3ControlNetPipeline, SD3ControlNetModel, Un
4
  from huggingface_hub import login
5
  import os
6
  import spaces
7
- from diffusers import StableDiffusion3ControlNetPipeline
8
- from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel
9
- from diffusers.utils import load_image
 
 
10
 
11
  # Log in to Hugging Face with your token
12
  token = os.getenv("HF_TOKEN")
13
  login(token=token)
14
 
15
- controlnet = SD3ControlNetModel.from_pretrained("alimama-creative/SD3-Controlnet-Softedge", torch_dtype=torch.float16)
16
 
17
- pipe = StableDiffusion3ControlNetPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet)
 
 
 
 
 
 
 
 
 
18
  pipe.to("cuda", torch.float16)
19
 
 
 
 
 
 
20
 
21
  @spaces.GPU
22
  def generate_image(prompt, reference_image, controlnet_conditioning_scale):
 
4
  from huggingface_hub import login
5
  import os
6
  import spaces
7
+ from diffusers.utils import load_image, make_image_grid
8
+ import torch
9
+ from diffusers import StableDiffusionXLAdapterPipeline,T2IAdapter
10
+ from diffusers.models import T2IAdapter
11
+ from diffusers.schedulers import UniPCMultistepScheduler
12
 
13
  # Log in to Hugging Face with your token
14
  token = os.getenv("HF_TOKEN")
15
  login(token=token)
16
 
 
17
 
18
+
19
+ # Load the T2I-Style Adapter and the SDXL pipeline
20
+ adapter = T2IAdapter.from_pretrained("TencentARC/t2i-adapter-style-sdxl")
21
+ pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
22
+ "stabilityai/stable-diffusion-xl-base-1.0",
23
+ adapter=adapter,
24
+ )
25
+
26
+ # Set up the scheduler and device
27
+ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
28
  pipe.to("cuda", torch.float16)
29
 
30
+ # controlnet = SD3ControlNetModel.from_pretrained("alimama-creative/SD3-Controlnet-Softedge", torch_dtype=torch.float16)
31
+ #
32
+ # pipe = StableDiffusion3ControlNetPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet)
33
+ # pipe.to("cuda", torch.float16)
34
+
35
 
36
  @spaces.GPU
37
  def generate_image(prompt, reference_image, controlnet_conditioning_scale):