File size: 3,434 Bytes
1c653a8
 
 
 
 
 
 
 
c27bc0a
1c653a8
630870d
 
c27bc0a
630870d
 
 
 
 
 
c27bc0a
1c653a8
 
 
 
 
 
c27bc0a
1c653a8
 
 
c27bc0a
630870d
1c653a8
 
 
c27bc0a
 
1c653a8
 
c27bc0a
 
1c653a8
 
 
 
 
630870d
cab0ae0
 
 
c27bc0a
 
 
cab0ae0
 
 
c27bc0a
1c653a8
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import gradio as gr
from src.utils import add_to_prompt
from src.rep_api import replicate_bgcontrolnet,replicate_caption_api
import os



def create_cnmu_tab():
    with gr.TabItem("Background changer"):
        with gr.Accordion("HowTo",open=False):
            gr.Markdown("""

                        

            # Background Generator  \n

            ・1 Select base image  ベース画像を選択します。 \n

            ・2 Update and check image object prompt 物体のプロンプトを確認と更新\n 

            ・3 Add in background prompt   背景のプロンプトを記入 \n

            ・4 Click 'Generate' to create the image. Generateをクリックして画像を生成します。\n



            """)
            gr.Image(value="HowTo/controlnetmockup.png",label=None,interactive=False)
        with gr.Row():
            with gr.Column():
                in_img = gr.Image(label="Input Image")
                object_prompt = gr.Textbox(label="Object Prompt",info="日本語対応は可能")
                background_prompt = gr.Textbox(label="Background Prompt",info="日本語対応は可能")
                style_image = gr.Image(label="Style Image",visible=False)
                
                with gr.Accordion("Examples",open=False):
                    gr.Examples(examples=[
                        ["Test_images/backgrounds/Output1.png"," in the stress of japan, 8k uhd, dslr, soft lighting, high quality, film grain , colorful decorative signs in"],
                        ["Test_images/example_outputs/mockup_BG_suitshop.png","suit shop in London, wooden inertia "]
                         
                    ],
                        inputs=[style_image,background_prompt]
                    )
        with gr.Row():
            btn = gr.Button("Generate",elem_id="gen-btn")
        with gr.Row():
            out_img= gr.Image(label="OutputImage")
        with gr.Row():
            move_to_relight= gr.Button("Move to Relight")
        
        btn.click(replicate_bgcontrolnet,inputs=[in_img,object_prompt,background_prompt],outputs=[out_img])
        in_img.change(replicate_caption_api,
                        inputs=[in_img,gr.Textbox("blip",visible=False),gr.Textbox("What item is in this image reply with a one word if u can, i.e Shoe, person, car ....",visible=False)],
                        outputs=[object_prompt])
        
        gr.Examples(
            examples=[
            ["Test_images/example_outputs/cnmu_input_1.webp","Test_images/example_outputs/cnmu_output_1.png","a  bowl of soup","on a table in a Chinese restraint, 8k, table, flowers in background "],
            ["Test_images/prompt_support_examples/Jacket_1.png","Test_images/example_outputs/mockup_BG.png","a back view of a man", " a night city streets of Tokyo"],
            ["Test_images/example_outputs/Input_3_VTO_LoritaDress.jpg","Test_images/example_outputs/mockup_BG_runway.png","a blond woman in a red and white dress is posing for a photo","on a Fashion show run way, lights "],
            ["Test_images/prompt_support_examples/Man_1.png","Test_images/example_outputs/mockup_BG_suitshop.png","a young man in a suit posing for a photo","suit shop in London, wooden inertia "]
            ],
            inputs=[in_img,out_img,object_prompt,background_prompt]
        )
    return in_img,out_img,move_to_relight