Spaces:
Sleeping
Sleeping
Upload 13 files
Browse files- app.py +95 -92
- controlnetmockup_tab.py +14 -1
- gen_tab.py +11 -20
- ipadapter_tab.py +16 -3
- virtualtryon_tab.py +12 -0
app.py
CHANGED
|
@@ -1,92 +1,95 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from gen_tab import create_gen_tab
|
| 3 |
-
from train_tab import create_train_tab
|
| 4 |
-
from virtualtryon_tab import create_virtualtryon_tab
|
| 5 |
-
from faceswap_tab import create_faceswap_tab
|
| 6 |
-
from ipadapter_tab import create_ipadaptor_tab
|
| 7 |
-
from controlnetmockup_tab import create_cnmu_tab
|
| 8 |
-
#from mail_tab import create_mail_tab
|
| 9 |
-
|
| 10 |
-
from pattern_ip_adapter import sam_zest_tab
|
| 11 |
-
from dotenv import load_dotenv, find_dotenv
|
| 12 |
-
import os
|
| 13 |
-
|
| 14 |
-
from src.utils import convert_to_pil
|
| 15 |
-
gallery_list=[]
|
| 16 |
-
|
| 17 |
-
def update_gallery(img):
|
| 18 |
-
img=convert_to_pil(img)
|
| 19 |
-
|
| 20 |
-
gallery_list.append(img)
|
| 21 |
-
return gallery_list
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
theme= gr.themes.Soft(
|
| 25 |
-
|
| 26 |
-
primary_hue=gr.themes.colors.emerald,
|
| 27 |
-
secondary_hue=gr.themes.colors.green)
|
| 28 |
-
css = """
|
| 29 |
-
.gradio-container img {
|
| 30 |
-
display: block;
|
| 31 |
-
width: 100%;
|
| 32 |
-
height: auto;
|
| 33 |
-
|
| 34 |
-
object-fit: cover;
|
| 35 |
-
border-radius: 10px;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
.gradio-container p {
|
| 39 |
-
margin: 0;
|
| 40 |
-
font-size: 16px;
|
| 41 |
-
font-weight: bold;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
.gradio-container .gr-button {
|
| 45 |
-
width: 100%;
|
| 46 |
-
background-color: #fff;
|
| 47 |
-
border: 1px solid #ddd;
|
| 48 |
-
padding: 10px;
|
| 49 |
-
border-radius: 10px;
|
| 50 |
-
}
|
| 51 |
-
.output_image {
|
| 52 |
-
display: block;
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
#
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
#
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gen_tab import create_gen_tab
|
| 3 |
+
from train_tab import create_train_tab
|
| 4 |
+
from virtualtryon_tab import create_virtualtryon_tab
|
| 5 |
+
from faceswap_tab import create_faceswap_tab
|
| 6 |
+
from ipadapter_tab import create_ipadaptor_tab
|
| 7 |
+
from controlnetmockup_tab import create_cnmu_tab
|
| 8 |
+
#from mail_tab import create_mail_tab
|
| 9 |
+
|
| 10 |
+
from pattern_ip_adapter import sam_zest_tab
|
| 11 |
+
from dotenv import load_dotenv, find_dotenv
|
| 12 |
+
import os
|
| 13 |
+
|
| 14 |
+
from src.utils import convert_to_pil
|
| 15 |
+
gallery_list=[]
|
| 16 |
+
|
| 17 |
+
def update_gallery(img):
|
| 18 |
+
img=convert_to_pil(img)
|
| 19 |
+
|
| 20 |
+
gallery_list.append(img)
|
| 21 |
+
return gallery_list
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
theme= gr.themes.Soft(
|
| 25 |
+
|
| 26 |
+
primary_hue=gr.themes.colors.emerald,
|
| 27 |
+
secondary_hue=gr.themes.colors.green)
|
| 28 |
+
css = """
|
| 29 |
+
.gradio-container img {
|
| 30 |
+
display: block;
|
| 31 |
+
width: 100%;
|
| 32 |
+
height: auto;
|
| 33 |
+
|
| 34 |
+
object-fit: cover;
|
| 35 |
+
border-radius: 10px;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.gradio-container p {
|
| 39 |
+
margin: 0;
|
| 40 |
+
font-size: 16px;
|
| 41 |
+
font-weight: bold;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.gradio-container .gr-button {
|
| 45 |
+
width: 100%;
|
| 46 |
+
background-color: #fff;
|
| 47 |
+
border: 1px solid #ddd;
|
| 48 |
+
padding: 10px;
|
| 49 |
+
border-radius: 10px;
|
| 50 |
+
}
|
| 51 |
+
.output_image {
|
| 52 |
+
display: block;
|
| 53 |
+
margin-left: auto;
|
| 54 |
+
margin-right: auto;
|
| 55 |
+
width: 100%;
|
| 56 |
+
height: auto;
|
| 57 |
+
|
| 58 |
+
}
|
| 59 |
+
.gradio-container .gr-button:hover {
|
| 60 |
+
background-color: #f0f0f0;
|
| 61 |
+
}
|
| 62 |
+
"""
|
| 63 |
+
|
| 64 |
+
_ = load_dotenv(find_dotenv())
|
| 65 |
+
with gr.Blocks(theme=theme,css=css) as demo:
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
with gr.Tabs() as tabs:
|
| 69 |
+
gen_out,move_to_vto,move_to_ip,move_to_cnmk= create_gen_tab()
|
| 70 |
+
input_ip,output_ip=create_ipadaptor_tab()
|
| 71 |
+
input_vto,output_vto=create_virtualtryon_tab()
|
| 72 |
+
#input_zest,output_zest=sam_zest_tab()
|
| 73 |
+
#input_fs,output_fs=create_faceswap_tab()
|
| 74 |
+
input_cnmu,output_cnmu=create_cnmu_tab()
|
| 75 |
+
#create_train_tab()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
# Move to Buttons
|
| 79 |
+
move_to_vto.click(lambda x:x, inputs=gen_out,outputs=input_vto)
|
| 80 |
+
move_to_cnmk.click(lambda x:x,input=gen_out,outputs=input_cnmu)
|
| 81 |
+
# move_to_fs.click(lambda x:x, inputs=gen_out,outputs=input_fs)
|
| 82 |
+
move_to_ip.click(lambda x:x, inputs=gen_out,outputs=input_ip)
|
| 83 |
+
# move_to_zest.click(lambda x:x, inputs=gen_out,outputs=input_zest)
|
| 84 |
+
#Gallery
|
| 85 |
+
image_gallery = gr.Gallery(label="Generated Images Gallery",type="pil",elem_id="output_image")
|
| 86 |
+
#Gallery updates get all outputs
|
| 87 |
+
gen_out.change(update_gallery,inputs=gen_out,outputs=image_gallery)
|
| 88 |
+
output_vto.change(update_gallery,inputs=output_vto,outputs=image_gallery)
|
| 89 |
+
#output_fs.change(update_gallery,inputs=output_fs,outputs=image_gallery)
|
| 90 |
+
output_ip.change(update_gallery,inputs=output_ip,outputs=image_gallery)
|
| 91 |
+
output_cnmu.change(update_gallery,inputs=output_cnmu,outputs=image_gallery)
|
| 92 |
+
#output_zest.change(update_gallery,inputs=output_zest,outputs=image_gallery)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
demo.launch(share=True,show_error=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
|
controlnetmockup_tab.py
CHANGED
|
@@ -8,7 +8,15 @@ import os
|
|
| 8 |
def create_cnmu_tab():
|
| 9 |
with gr.TabItem("Control net mockup Generator"):
|
| 10 |
with gr.Accordion("HowTo",open=False):
|
| 11 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
with gr.Row():
|
| 13 |
with gr.Column():
|
| 14 |
in_img = gr.Image(label="Input Image")
|
|
@@ -19,6 +27,7 @@ def create_cnmu_tab():
|
|
| 19 |
with gr.Accordion("Examples",open=False):
|
| 20 |
gr.Examples(examples=[
|
| 21 |
["Test_images/backgrounds/Output1.png"," in the stress of japan, 8k uhd, dslr, soft lighting, high quality, film grain , colorful decorative signs in"],
|
|
|
|
| 22 |
],
|
| 23 |
inputs=[style_image,background_prompt]
|
| 24 |
)
|
|
@@ -30,6 +39,10 @@ def create_cnmu_tab():
|
|
| 30 |
in_img.change(replicate_caption_api,
|
| 31 |
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)],
|
| 32 |
outputs=[object_prompt])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
return in_img,out_img
|
| 34 |
|
| 35 |
|
|
|
|
| 8 |
def create_cnmu_tab():
|
| 9 |
with gr.TabItem("Control net mockup Generator"):
|
| 10 |
with gr.Accordion("HowTo",open=False):
|
| 11 |
+
gr.Markdown("""
|
| 12 |
+
|
| 13 |
+
# Mockup Generator \n
|
| 14 |
+
・1 Select base image ベース画像を選択します。 \n
|
| 15 |
+
・2 Update and check image object prompt 物体のプロンプトを確認と更新\n
|
| 16 |
+
・3 Add in background prompt 背景のプロンプトを記入 \n
|
| 17 |
+
・4 Click 'Generate' to create the image. Generateをクリックして画像を生成します。\n
|
| 18 |
+
|
| 19 |
+
""")
|
| 20 |
with gr.Row():
|
| 21 |
with gr.Column():
|
| 22 |
in_img = gr.Image(label="Input Image")
|
|
|
|
| 27 |
with gr.Accordion("Examples",open=False):
|
| 28 |
gr.Examples(examples=[
|
| 29 |
["Test_images/backgrounds/Output1.png"," in the stress of japan, 8k uhd, dslr, soft lighting, high quality, film grain , colorful decorative signs in"],
|
| 30 |
+
|
| 31 |
],
|
| 32 |
inputs=[style_image,background_prompt]
|
| 33 |
)
|
|
|
|
| 39 |
in_img.change(replicate_caption_api,
|
| 40 |
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)],
|
| 41 |
outputs=[object_prompt])
|
| 42 |
+
|
| 43 |
+
gr.Examples(examples=[
|
| 44 |
+
["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 "]
|
| 45 |
+
])
|
| 46 |
return in_img,out_img
|
| 47 |
|
| 48 |
|
gen_tab.py
CHANGED
|
@@ -43,23 +43,13 @@ def create_gen_tab():
|
|
| 43 |
|
| 44 |
with gr.Accordion("HowTo",open=False):
|
| 45 |
with gr.Column():
|
| 46 |
-
gr.Markdown("### How to use the Image Generator\n"
|
| 47 |
-
"1. Enter a prompt in the textbox.\n"
|
| 48 |
-
"2. Choose the aspect ratio.\n"
|
| 49 |
-
"3. Options Select a style lore.\n"
|
| 50 |
-
"4. Options in extra control net.\n"
|
| 51 |
-
"5. Click 'Generate' to create the image. \n"
|
| 52 |
-
"6. click button to move image to other tab. \n")
|
| 53 |
-
|
| 54 |
-
with gr.Column():
|
| 55 |
-
|
| 56 |
-
gr.Markdown("### 画像生成器の使い方\n"
|
| 57 |
-
"1. テキストボックスにプロンプトを入力します。\n"
|
| 58 |
-
"2. アスペクト比を選択します。\n"
|
| 59 |
-
"3. スタイルロアを選択します。\n"
|
| 60 |
-
"4. 'Extra'でコントロールネットのオプションを選択します。\n"
|
| 61 |
-
"5. 'Generate'をクリックして画像を生成します。\n"
|
| 62 |
-
"6. ボタンをクリックして画像を他のタブに移動します。\n")
|
| 63 |
#Gen generatpor options
|
| 64 |
with gr.Row():
|
| 65 |
with gr.Column():
|
|
@@ -113,9 +103,10 @@ def create_gen_tab():
|
|
| 113 |
|
| 114 |
|
| 115 |
with gr.Row(): #Move gen out row
|
| 116 |
-
move_to_vto =gr.Button("Move to Virtual Try On")
|
| 117 |
move_to_ip =gr.Button("Move to Cloth IP Adapter")
|
| 118 |
-
|
|
|
|
|
|
|
| 119 |
# move_to_zest=gr.Button("Move to Zest IP Adapter")
|
| 120 |
|
| 121 |
|
|
@@ -123,4 +114,4 @@ def create_gen_tab():
|
|
| 123 |
inputs=[inp,style_mode,api_path,aspect_ratio,style_strength,use_control_net,control_net_type,control_net_img,control_net_strength],
|
| 124 |
outputs=[gen_out])
|
| 125 |
|
| 126 |
-
return gen_out,move_to_vto,
|
|
|
|
| 43 |
|
| 44 |
with gr.Accordion("HowTo",open=False):
|
| 45 |
with gr.Column():
|
| 46 |
+
gr.Markdown("### How to use the Image Generator 画像生成器の使い方 \n"
|
| 47 |
+
"1. Enter a prompt in the textbox. テキストボックスにプロンプトを入力します。\n"
|
| 48 |
+
"2. Choose the aspect ratio. アスペクト比を選択します。\n"
|
| 49 |
+
"3. Options Select a style lore. スタイルロアを選択します。\n"
|
| 50 |
+
"4. Options in extra control net. Extraでコントロールネットのオプションを選択します。\n"
|
| 51 |
+
"5. Click 'Generate' to create the image. Generateをクリックして画像を生成します。\n"
|
| 52 |
+
"6. click button to move image to other tab.ボタンをクリックして画像を他のタブに移動します。 \n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
#Gen generatpor options
|
| 54 |
with gr.Row():
|
| 55 |
with gr.Column():
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
with gr.Row(): #Move gen out row
|
|
|
|
| 106 |
move_to_ip =gr.Button("Move to Cloth IP Adapter")
|
| 107 |
+
move_to_vto =gr.Button("Move to Virtual Try On")
|
| 108 |
+
move_to_cnmk =gr.Button("Move to Control net mockup ")
|
| 109 |
+
# move_to_fs =gr.Button("Move to Face Swap")
|
| 110 |
# move_to_zest=gr.Button("Move to Zest IP Adapter")
|
| 111 |
|
| 112 |
|
|
|
|
| 114 |
inputs=[inp,style_mode,api_path,aspect_ratio,style_strength,use_control_net,control_net_type,control_net_img,control_net_strength],
|
| 115 |
outputs=[gen_out])
|
| 116 |
|
| 117 |
+
return gen_out,move_to_vto,move_to_ip,move_to_cnmk # move_to_fs,#,move_to_zest
|
ipadapter_tab.py
CHANGED
|
@@ -5,6 +5,20 @@ import gradio as gr
|
|
| 5 |
def create_ipadaptor_tab():
|
| 6 |
|
| 7 |
with gr.TabItem("Cloth IP Adapter",id="cloth_ip_adapter"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
with gr.Row():
|
| 9 |
with gr.Column():
|
| 10 |
api_inp = gr.Image(label="Base Image")
|
|
@@ -13,11 +27,10 @@ def create_ipadaptor_tab():
|
|
| 13 |
human_examples = gr.Examples(
|
| 14 |
examples=[
|
| 15 |
["Test_images/Woman_1.png"],
|
| 16 |
-
["Test_images/man_1.
|
| 17 |
["Test_images/Woman_2.png"],
|
| 18 |
-
["Test_images/person_2.jpg"],
|
| 19 |
["Test_images/Woman_3.png"],
|
| 20 |
-
["Test_images/
|
| 21 |
["Test_images/Woman_4.png"],
|
| 22 |
["Test_images/Woman_5.png"],
|
| 23 |
["Test_images/anime_woman_1.png"],
|
|
|
|
| 5 |
def create_ipadaptor_tab():
|
| 6 |
|
| 7 |
with gr.TabItem("Cloth IP Adapter",id="cloth_ip_adapter"):
|
| 8 |
+
|
| 9 |
+
with gr.Accordion("HowTo",open=False):
|
| 10 |
+
gr.Markdown("""
|
| 11 |
+
# Cloth IP Adapter 服のIPアタォーター \n
|
| 12 |
+
・1 Select base image ベース画像を選択します。 \n
|
| 13 |
+
・2 Prompt area you want the IP to be applied IPを適用するためのプロンプトエリアを選択します。 \n
|
| 14 |
+
・3 Select IP image IP画像を選択します。 \n
|
| 15 |
+
・4 Click Generate 生成をクリックします。 \n
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
""")
|
| 19 |
+
gr.Image(value="HowTo/Flow_IP_ClothAdapter.jpg",interactive=False)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
with gr.Row():
|
| 23 |
with gr.Column():
|
| 24 |
api_inp = gr.Image(label="Base Image")
|
|
|
|
| 27 |
human_examples = gr.Examples(
|
| 28 |
examples=[
|
| 29 |
["Test_images/Woman_1.png"],
|
| 30 |
+
["Test_images/man_1.png"],
|
| 31 |
["Test_images/Woman_2.png"],
|
|
|
|
| 32 |
["Test_images/Woman_3.png"],
|
| 33 |
+
["Test_images/man_2.png"],
|
| 34 |
["Test_images/Woman_4.png"],
|
| 35 |
["Test_images/Woman_5.png"],
|
| 36 |
["Test_images/anime_woman_1.png"],
|
virtualtryon_tab.py
CHANGED
|
@@ -4,6 +4,18 @@ import gradio as gr
|
|
| 4 |
|
| 5 |
def create_virtualtryon_tab():
|
| 6 |
with gr.TabItem("Virtual Try-on",id="virtual_tryon"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
with gr.Row():
|
| 8 |
with gr.Column():
|
| 9 |
human_img = gr.Image(label="Human Image")
|
|
|
|
| 4 |
|
| 5 |
def create_virtualtryon_tab():
|
| 6 |
with gr.TabItem("Virtual Try-on",id="virtual_tryon"):
|
| 7 |
+
with gr.Accordion("HowTo",open=False):
|
| 8 |
+
gr.Markdown("""
|
| 9 |
+
# Virtual Try-On Workflow バーチャル試着ワークフロー \n
|
| 10 |
+
・1 Select base image ベース画像を選択します。 \n
|
| 11 |
+
・2 Select the cloth image 服の画像を選択します \n
|
| 12 |
+
・3 Add description 説明を追加します \n
|
| 13 |
+
・4 Click Try-ON トライオンをクリックします。 \n
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
""")
|
| 17 |
+
gr.Image(value="HowTo/Vtron_Abstract.png",interactive=False)
|
| 18 |
+
|
| 19 |
with gr.Row():
|
| 20 |
with gr.Column():
|
| 21 |
human_img = gr.Image(label="Human Image")
|