Spaces:
Paused
Paused
test gradio
Browse files
app.py
CHANGED
@@ -16,22 +16,22 @@ login(token=token)
|
|
16 |
|
17 |
|
18 |
pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16).to("cuda")
|
19 |
-
pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin")
|
20 |
|
21 |
|
22 |
|
23 |
@spaces.GPU
|
24 |
-
def generate_image(prompt,
|
25 |
-
|
|
|
26 |
# reference_image.resize((512, 512))
|
27 |
scale = {
|
28 |
-
"up": {"block_0": [0.0, controlnet_conditioning_scale, 0.0]},
|
29 |
}
|
30 |
-
pipeline.set_ip_adapter_scale(scale)
|
31 |
|
32 |
image = pipeline(
|
33 |
prompt=prompt,
|
34 |
-
ip_adapter_image=
|
35 |
negative_prompt="",
|
36 |
guidance_scale=5,
|
37 |
num_inference_steps=30,
|
@@ -44,7 +44,7 @@ interface = gr.Interface(
|
|
44 |
fn=generate_image,
|
45 |
inputs=[
|
46 |
gr.Textbox(label="Prompt"),
|
47 |
-
gr.
|
48 |
gr.Slider(label="Control Net Conditioning Scale", minimum=0, maximum=1.0, step=0.1, value=0.6),
|
49 |
],
|
50 |
outputs="image",
|
|
|
16 |
|
17 |
|
18 |
pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16).to("cuda")
|
|
|
19 |
|
20 |
|
21 |
|
22 |
@spaces.GPU
|
23 |
+
def generate_image(prompt, reference_images, controlnet_conditioning_scale):
|
24 |
+
pipeline.load_ip_adapter(["h94/IP-Adapter"]*len(reference_images), subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin")
|
25 |
+
style_images = [Image.open(reference_image) for reference_image in reference_images]
|
26 |
# reference_image.resize((512, 512))
|
27 |
scale = {
|
28 |
+
"up": {"block_0": [0.0, controlnet_conditioning_scale/len(reference_images), 0.0]},
|
29 |
}
|
30 |
+
pipeline.set_ip_adapter_scale([scale]*len(reference_images))
|
31 |
|
32 |
image = pipeline(
|
33 |
prompt=prompt,
|
34 |
+
ip_adapter_image=style_images,
|
35 |
negative_prompt="",
|
36 |
guidance_scale=5,
|
37 |
num_inference_steps=30,
|
|
|
44 |
fn=generate_image,
|
45 |
inputs=[
|
46 |
gr.Textbox(label="Prompt"),
|
47 |
+
gr.inputs.File(file_count="multiple"),
|
48 |
gr.Slider(label="Control Net Conditioning Scale", minimum=0, maximum=1.0, step=0.1, value=0.6),
|
49 |
],
|
50 |
outputs="image",
|