Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from src.rep_api import replicate_iclight_BG,light_source_options | |
| def gen_relighting_tab(): | |
| with gr.TabItem("Re-Lighting"): | |
| gr.Markdown("### Upload Images and Set Light Source") | |
| with gr.Accordion("HowTo",open=False): | |
| gr.Markdown(""" | |
| # Relight 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(label=None,value="HowTo/ReLight.png",interactive=False) | |
| img_input = gr.Image(label="Input Image", type="pil") | |
| bg_img_input = gr.Image(label="Background Image", type="pil") | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Examples( | |
| label="example Images ", | |
| examples=[ | |
| ["Test_images/anime_woman_2.png"], | |
| ["Test_images/prompt_support_examples/Woman_1.png"], | |
| ["Test_images/example_outputs/Input_4_VTO_ColorFullJacket.jpg"], | |
| ["Test_images/Woman_5.png"], | |
| ["Test_images/Walk_4.png"] | |
| ],inputs=[img_input]) | |
| with gr.Column(): | |
| gr.Examples( | |
| label="Example Light Source", | |
| examples= | |
| [ | |
| ["https://replicate.delivery/pbxt/KxPIbJUjSmVBlvn0M3C8PAz6brN5Z0eyZSGcKIVw3XfJ6vNV/7.webp"], | |
| ["Test_images/Lighting/Ligthing_1.webp"], | |
| ["Test_images/Lighting/Lighting_2.webp"], | |
| ["Test_images/Lighting/Lighing_3.webp"], | |
| [ "Test_images/Lighting/Lighing_4.webp"] | |
| ] | |
| ,inputs=[bg_img_input]) | |
| prompt_input = gr.Textbox(label="Prompt", placeholder="Enter prompt here") | |
| light_source = gr.Dropdown(label="Light Source", choices=light_source_options, value="Use Background Image") | |
| bg_img_input.change( lambda x: "Use Background Image",inputs=bg_img_input, outputs=light_source) | |
| submit_btn = gr.Button("Generate",elem_id="gen-btn") | |
| output_image = gr.Image(label="Output Image") | |
| # Link the submit button to the replicate_iclight_BG function | |
| submit_btn.click( | |
| replicate_iclight_BG, | |
| inputs=[img_input, prompt_input, bg_img_input, light_source], | |
| outputs=output_image | |
| ) | |
| examples = gr.Examples( | |
| examples=[ | |
| ["Test_images/Walk_4.png","Test_images/Lighting/Lighing_3.webp","Use Background Image","A girl walking","Test_images/example_outputs/Re_light_output1.png"], | |
| ["Test_images/prompt_support_examples/Woman_1.png","https://replicate.delivery/pbxt/KxPIbJUjSmVBlvn0M3C8PAz6brN5Z0eyZSGcKIVw3XfJ6vNV/7.webp","Use Background Image","a girl wearing a jacket ","Test_images/example_outputs/Re_light_output2.png"], | |
| ["Test_images/example_outputs/Input_4_VTO_ColorFullJacket.jpg",None,"Bottom Light","a girl wearing a jacket","Test_images/example_outputs/Re_light_output3.png"], | |
| ["Test_images/Woman_5.png",None,"Right Light","a image of a girl from the side","Test_images/example_outputs/Re_light_output4.png"], | |
| ["Test_images/Woman_5.png","Test_images/Lighting/Ligthing_1.webp","Use Background Image","a image of a girl from the side","Test_images/example_outputs/Re_light_output5.png"], | |
| ], | |
| inputs=[img_input,bg_img_input,light_source,prompt_input,output_image], | |
| ) | |
| return img_input, output_image |