Spaces:
Sleeping
Sleeping
small changes by Sara
Browse files247 unmodified lines24824925025125225325425525625725825926039 unmodified lines3003013023033043053063073083093103113123134 unmodified lines318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378247 unmodified linesuse_concpet_from_file_3 = False):if base_image is None:raise gr.Error("please upload a base image")if concept_image1 is None:raise gr.Error("choose at least one concept image")if concept_image1 is None:raise gr.Error("choose at least one concept type")modified_images = process_images(base_image,39 unmodified lines"""with gr.Blocks(css=css) as demo:gr.Markdown(f"""# IP Composer 🌅✚🖌️### compose new images with visual conceptsfollowing the algorithm proposed in [*IP-Composer: Semantic Composition of Visual Concepts* by Dorfman et al.](https://arxiv.org/pdf/2502.13951)#### 1. upload a base image#### 2. upload 1-3 concept images#### 3. select concept type to extract from each concept image[[project page](https://ip-composer.github.io/IP-Composer/)] [[arxiv](https://arxiv.org/pdf/2502.13951)]""")concpet_from_file_1 = gr.State()concpet_from_file_2 = gr.State()4 unmodified lineswith gr.Row():with gr.Column():base_image = gr.Image(label="Base Image (Required)", type="numpy")with gr.Tab("concept 1"):with gr.Group():concept_image1 = gr.Image(label="Concept Image 1", type="numpy")with gr.Row():concept_name1 = gr.Dropdown(concept_options, label="concept 1", value=None, info="pick concept type")with gr.Accordion("💡 or use a new concept 👇", open=False):gr.Markdown("1. upload a file with text variations of your concept (e.g. ask an LLM)")gr.Markdown("2. prefereably with > 100 variations.")with gr.Accordion("file example for the concept 'emotions'", open=False):gr.Markdown(example)concept_file_1 = gr.File(label="concept variations", file_types=["text"])with gr.Tab("concept 2 (optional)"):with gr.Group():concept_image2 = gr.Image(label="Concept Image 2", type="numpy")with gr.Row():concept_name2 = gr.Dropdown(concept_options, label="concept 2", value=None, info="pick concept type")with gr.Accordion("💡 or use a new concept 👇", open=False):gr.Markdown("1. upload a file with text variations of your concept (e.g. ask an LLM)")gr.Markdown("2. prefereably with > 100 variations.")with gr.Accordion("file example for the concept 'emotions'", open=False):gr.Markdown(example)concept_file_2 = gr.File(label="concept variations", file_types=["text"])with gr.Tab("concept 3 (optional)"):with gr.Group():concept_image3 = gr.Image(label="Concept Image 3", type="numpy")with gr.Row():concept_name3 = gr.Dropdown(concept_options, label="concept 3", value= None, info="pick concept type")with gr.Accordion("💡 or use a new concept 👇", open=False):gr.Markdown("1. upload a file with text variations of your concept (e.g. ask an LLM)")gr.Markdown("2. prefereably with > 100 variations.")with gr.Accordion("file example for the concept 'emotions'", open=False):gr.Markdown(example)concept_file_3 = gr.File(label="concept variations", file_types=["text"])with gr.Accordion("Advanced options", open=False):prompt = gr.Textbox(label="Guidance Prompt (Optional)", placeholder="Optional text prompt to guide generation")num_inference_steps = gr.Slider(minimum=1, maximum=50, value=30, step=1, label="num steps")with gr.Row():scale = gr.Slider(minimum=0.1, maximum=2.0, value=1.0, step=0.1, label="Scale")randomize_seed = gr.Checkbox(value=True, label="Randomize seed")seed = gr.Number(value=0, label="Seed", precision=0)with gr.Column():gr.Markdown("if concept is not showing enough try to increase the rank")with gr.Row():rank1 = gr.Slider(minimum=1, maximum=150, value=30, step=1, label="rank concept 1")rank2 = gr.Slider(minimum=1, maximum=150, value=30, step=1, label="rank concept 2")rank3 = gr.Slider(minimum=1, maximum=150, value=30, step=1, label="rank concept 3")with gr.Column():output_image = gr.Image(label="composed output", show_label=True)submit_btn = gr.Button("Generate")gr.Examples(247 unmodified lines24824925025125225325425525625725825926039 unmodified lines3003013023033043053063073083093103113123133143153163173184 unmodified lines323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383247 unmodified linesuse_concpet_from_file_3 = False):if base_image is None:raise gr.Error("Please upload a base image")if concept_image1 is None:raise gr.Error("Choose at least one concept image")if concept_image1 is None:raise gr.Error("Choose at least one concept type")modified_images = process_images(base_image,39 unmodified lines"""with gr.Blocks(css=css) as demo:gr.Markdown(f"""# IP Composer 🌅✚🖌️### Compose new images with visual conceptsFollowing the algorithm proposed in [*IP-Composer: Semantic Composition of Visual Concepts* by Dorfman et al.](https://arxiv.org/pdf/2502.13951)(Built on IP-Adapter)#### 🛠️ How to Use:#### 1. Upload a base image#### 2. Upload 1–3 concept images#### 3. Select a concept type to extract from each concept image:- Choose a **predefined concept type** from the dropdown (e.g. pattern, emotion, pose), **or**- Upload a **file with text variations of your concept** (e.g. prompts from an LLM).- 👉 If you're uploading a **new concept**, don't forget to **adjust the "rank" value** under **Advanced Options** for better results.[[Project page](https://ip-composer.github.io/IP-Composer/)] [[arxiv](https://arxiv.org/pdf/2502.13951)]""")concpet_from_file_1 = gr.State()concpet_from_file_2 = gr.State()4 unmodified lineswith gr.Row():with gr.Column():base_image = gr.Image(label="Base Image (Required)", type="numpy")with gr.Tab("Concept 1"):with gr.Group():concept_image1 = gr.Image(label="Concept Image 1", type="numpy")with gr.Row():concept_name1 = gr.Dropdown(concept_options, label="Concept 1", value=None, info="Pick concept type")with gr.Accordion("💡 Or use a new concept 👇", open=False):gr.Markdown("1. Upload a file with text variations of your concept (e.g. ask an LLM)")gr.Markdown("2. Prefereably with > 100 variations.")with gr.Accordion("File example for the concept 'emotions'", open=False):gr.Markdown(example)concept_file_1 = gr.File(label="Concept variations", file_types=["text"])with gr.Tab("Concept 2 (Optional)"):with gr.Group():concept_image2 = gr.Image(label="Concept Image 2", type="numpy")with gr.Row():concept_name2 = gr.Dropdown(concept_options, label="Concept 2", value=None, info="Pick concept type")with gr.Accordion("💡 Or use a new concept 👇", open=False):gr.Markdown("1. Upload a file with text variations of your concept (e.g. ask an LLM)")gr.Markdown("2. Prefereably with > 100 variations.")with gr.Accordion("File example for the concept 'emotions'", open=False):gr.Markdown(example)concept_file_2 = gr.File(label="Concept variations", file_types=["text"])with gr.Tab("Concept 3 (optional)"):with gr.Group():concept_image3 = gr.Image(label="Concept Image 3", type="numpy")with gr.Row():concept_name3 = gr.Dropdown(concept_options, label="Concept 3", value= None, info="Pick concept type")with gr.Accordion("💡 Or use a new concept 👇", open=False):gr.Markdown("1. Upload a file with text variations of your concept (e.g. ask an LLM)")gr.Markdown("2. Prefereably with > 100 variations.")with gr.Accordion("File example for the concept 'emotions'", open=False):gr.Markdown(example)concept_file_3 = gr.File(label="Concept variations", file_types=["text"])with gr.Accordion("Advanced options", open=False):prompt = gr.Textbox(label="Guidance Prompt (Optional)", placeholder="Optional text prompt to guide generation")num_inference_steps = gr.Slider(minimum=1, maximum=50, value=30, step=1, label="Num steps")with gr.Row():scale = gr.Slider(minimum=0.1, maximum=2.0, value=1.0, step=0.1, label="Scale")randomize_seed = gr.Checkbox(value=True, label="Randomize seed")seed = gr.Number(value=0, label="Seed", precision=0)with gr.Column():gr.Markdown("If a concept is not showing enough, try to increase the rank")with gr.Row():rank1 = gr.Slider(minimum=1, maximum=150, value=30, step=1, label="Rank concept 1")rank2 = gr.Slider(minimum=1, maximum=150, value=30, step=1, label="Rank concept 2")rank3 = gr.Slider(minimum=1, maximum=150, value=30, step=1, label="Rank concept 3")with gr.Column():output_image = gr.Image(label="Composed output", show_label=True)submit_btn = gr.Button("Generate")gr.Examples(
app.py+43-38