Spaces:
Paused
Paused
test gradio
Browse files
app.py
CHANGED
|
@@ -16,22 +16,19 @@ login(token=token)
|
|
| 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,
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 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,8 +41,9 @@ interface = gr.Interface(
|
|
| 44 |
fn=generate_image,
|
| 45 |
inputs=[
|
| 46 |
gr.Textbox(label="Prompt"),
|
| 47 |
-
gr.
|
| 48 |
-
gr.
|
|
|
|
| 49 |
],
|
| 50 |
outputs="image",
|
| 51 |
title="Image Generation with Stable Diffusion 3 medium and ControlNet",
|
|
|
|
| 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-plus-face_sdxl_vit-h.safetensors")
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
@spaces.GPU
|
| 24 |
+
def generate_image(prompt, reference_image, controlnet_conditioning_scale):
|
| 25 |
+
style_images = [load_image(f.name) for f in reference_image]
|
| 26 |
+
|
| 27 |
+
pipeline.set_ip_adapter_scale(controlnet_conditioning_scale)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
image = pipeline(
|
| 30 |
prompt=prompt,
|
| 31 |
+
ip_adapter_image=[style_images],
|
| 32 |
negative_prompt="",
|
| 33 |
guidance_scale=5,
|
| 34 |
num_inference_steps=30,
|
|
|
|
| 41 |
fn=generate_image,
|
| 42 |
inputs=[
|
| 43 |
gr.Textbox(label="Prompt"),
|
| 44 |
+
# gr.Image( type= "filepath",label="Reference Image (Style)"),
|
| 45 |
+
gr.inputs.File(file_count="multiple",label="Reference Image (Style)"),
|
| 46 |
+
gr.Slider(label="Control Net Conditioning Scale", minimum=0, maximum=1.0, step=0.1, value=1.0),
|
| 47 |
],
|
| 48 |
outputs="image",
|
| 49 |
title="Image Generation with Stable Diffusion 3 medium and ControlNet",
|