Spaces:
Sleeping
Sleeping
| 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 | |