Spaces:
Sleeping
Sleeping
Upload 13 files
Browse files- app.py +50 -19
- controlnetmockup_tab.py +36 -0
- gen_tab.py +40 -15
- ipadapter_tab.py +5 -1
- mail_tab.py +102 -0
- model_dict.json +3 -2
- virtualtryon_tab.py +12 -2
app.py
CHANGED
|
@@ -4,9 +4,13 @@ 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 pattern_ip_adapter import sam_zest_tab
|
| 8 |
from dotenv import load_dotenv, find_dotenv
|
| 9 |
import os
|
|
|
|
| 10 |
from src.utils import convert_to_pil
|
| 11 |
gallery_list=[]
|
| 12 |
|
|
@@ -18,30 +22,56 @@ def update_gallery(img):
|
|
| 18 |
|
| 19 |
|
| 20 |
theme= gr.themes.Soft(
|
| 21 |
-
|
| 22 |
primary_hue=gr.themes.colors.emerald,
|
| 23 |
secondary_hue=gr.themes.colors.green)
|
| 24 |
-
css
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
.
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
_ = load_dotenv(find_dotenv())
|
| 38 |
with gr.Blocks(theme=theme,css=css) as demo:
|
|
|
|
|
|
|
| 39 |
with gr.Tabs() as tabs:
|
| 40 |
-
gen_out,move_to_vto,move_to_fs,move_to_ip
|
| 41 |
input_ip,output_ip=create_ipadaptor_tab()
|
| 42 |
input_vto,output_vto=create_virtualtryon_tab()
|
| 43 |
-
input_zest,output_zest=sam_zest_tab()
|
| 44 |
input_fs,output_fs=create_faceswap_tab()
|
|
|
|
| 45 |
#create_train_tab()
|
| 46 |
|
| 47 |
|
|
@@ -49,15 +79,16 @@ with gr.Blocks(theme=theme,css=css) as demo:
|
|
| 49 |
move_to_vto.click(lambda x:x, inputs=gen_out,outputs=input_vto)
|
| 50 |
move_to_fs.click(lambda x:x, inputs=gen_out,outputs=input_fs)
|
| 51 |
move_to_ip.click(lambda x:x, inputs=gen_out,outputs=input_ip)
|
| 52 |
-
|
| 53 |
-
|
| 54 |
#Gallery
|
| 55 |
-
image_gallery = gr.Gallery(label="Generated Images Gallery",type="pil")
|
| 56 |
#Gallery updates get all outputs
|
| 57 |
gen_out.change(update_gallery,inputs=gen_out,outputs=image_gallery)
|
| 58 |
output_vto.change(update_gallery,inputs=output_vto,outputs=image_gallery)
|
| 59 |
output_fs.change(update_gallery,inputs=output_fs,outputs=image_gallery)
|
| 60 |
output_ip.change(update_gallery,inputs=output_ip,outputs=image_gallery)
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
|
| 63 |
demo.launch(share=True,show_error=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
|
|
|
|
| 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 |
|
|
|
|
| 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 |
+
max-height: 200px;
|
| 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_fs,move_to_ip= 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 |
|
|
|
|
| 79 |
move_to_vto.click(lambda x:x, inputs=gen_out,outputs=input_vto)
|
| 80 |
move_to_fs.click(lambda x:x, inputs=gen_out,outputs=input_fs)
|
| 81 |
move_to_ip.click(lambda x:x, inputs=gen_out,outputs=input_ip)
|
| 82 |
+
# move_to_zest.click(lambda x:x, inputs=gen_out,outputs=input_zest)
|
|
|
|
| 83 |
#Gallery
|
| 84 |
+
image_gallery = gr.Gallery(label="Generated Images Gallery",type="pil",elem_id="output_image")
|
| 85 |
#Gallery updates get all outputs
|
| 86 |
gen_out.change(update_gallery,inputs=gen_out,outputs=image_gallery)
|
| 87 |
output_vto.change(update_gallery,inputs=output_vto,outputs=image_gallery)
|
| 88 |
output_fs.change(update_gallery,inputs=output_fs,outputs=image_gallery)
|
| 89 |
output_ip.change(update_gallery,inputs=output_ip,outputs=image_gallery)
|
| 90 |
+
output_cnmu.change(update_gallery,inputs=output_cnmu,outputs=image_gallery)
|
| 91 |
+
#output_zest.change(update_gallery,inputs=output_zest,outputs=image_gallery)
|
| 92 |
+
|
| 93 |
|
| 94 |
demo.launch(share=True,show_error=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
|
controlnetmockup_tab.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from src.utils import add_to_prompt
|
| 3 |
+
from src.rep_api import replicate_bgcontrolnet,replicate_caption_api
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def create_cnmu_tab():
|
| 9 |
+
with gr.TabItem("Control net mockup Generator"):
|
| 10 |
+
with gr.Accordion("HowTo",open=False):
|
| 11 |
+
gr.Markdown("How to Goes Here")
|
| 12 |
+
with gr.Row():
|
| 13 |
+
with gr.Column():
|
| 14 |
+
in_img = gr.Image(label="Input Image")
|
| 15 |
+
object_prompt = gr.Textbox(label="Object Prompt",info="日本語対応は可能")
|
| 16 |
+
background_prompt = gr.Textbox(label="Background Prompt",info="日本語対応は可能")
|
| 17 |
+
style_image = gr.Image(label="Style Image",visible=False)
|
| 18 |
+
btn = gr.Button("Generate")
|
| 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 |
+
)
|
| 25 |
+
|
| 26 |
+
with gr.Row():
|
| 27 |
+
out_img= gr.Image(label="OutputImage")
|
| 28 |
+
|
| 29 |
+
btn.click(replicate_bgcontrolnet,inputs=[in_img,object_prompt,background_prompt],outputs=[out_img])
|
| 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 |
+
|
| 36 |
+
|
gen_tab.py
CHANGED
|
@@ -20,8 +20,9 @@ prompt_dict_kp ={
|
|
| 20 |
lora_style_support = [
|
| 21 |
["ps1","Test_images/lora_support_examples/ps1.png"],
|
| 22 |
["cyberpunk","Test_images/lora_support_examples/cyberpunk.png"],
|
| 23 |
-
["
|
| 24 |
-
["
|
|
|
|
| 25 |
["half-illustration","Test_images/lora_support_examples/halfillust.png"]
|
| 26 |
]
|
| 27 |
|
|
@@ -37,10 +38,33 @@ prompt_support = [
|
|
| 37 |
|
| 38 |
def create_gen_tab():
|
| 39 |
with gr.TabItem("Image Generator"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
with gr.Row():
|
| 41 |
with gr.Column():
|
| 42 |
inp = gr.Textbox(label="Prompt",info="日本語対応は可能")
|
| 43 |
-
aspect_ratio = gr.Dropdown(list(["1:1","16:9","9:16","5:4"]),value="1:1", label="Aspect Ratio", info="Aspect Ratio")
|
| 44 |
btn = gr.Button("Generate")
|
| 45 |
with gr.Accordion("extra", open=False):
|
| 46 |
#Control net
|
|
@@ -48,11 +72,15 @@ def create_gen_tab():
|
|
| 48 |
control_net_type=gr.Dropdown(["depth","canny","soft_edge"],value="depth",label="Control net type")
|
| 49 |
control_net_img= gr.Image(label="Control net image",type="pil")
|
| 50 |
control_net_strength = gr.Slider(0,1,value=0.4,label="control net strength")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
with gr.Column():
|
| 54 |
|
| 55 |
-
style_mode = gr.Dropdown(list(model_dict.keys()),label="Style lore",value="Base",info="style model")
|
| 56 |
with gr.Accordion("Style Imgaes",open=False):
|
| 57 |
# with gr.Column(elem_id="prompt_support_column"):
|
| 58 |
for i,lora in enumerate(lora_style_support):
|
|
@@ -61,7 +89,7 @@ def create_gen_tab():
|
|
| 61 |
with row:
|
| 62 |
lora_img = gr.Image(value=lora[1], label=lora[0],width=200,height=200, interactive=False)
|
| 63 |
lora_img.select(lambda x:x, inputs=gr.Textbox(value=lora[0],visible=False),outputs=style_mode)
|
| 64 |
-
api_path = gr.Textbox(label="Other_style",info="Style lora
|
| 65 |
|
| 66 |
style_strength = gr.Slider(0,2,value=1,label="Style Strength")
|
| 67 |
|
|
@@ -78,24 +106,21 @@ def create_gen_tab():
|
|
| 78 |
btn_ps=gr.Button(item[1],elem_id="prompt_support_button")
|
| 79 |
img_ps.select(lambda x:x, inputs=gr.Textbox(item[1],visible=False),outputs=inp)
|
| 80 |
btn_ps.click(lambda x:x, inputs=gr.Textbox(item[1],visible=False),outputs=inp)
|
| 81 |
-
|
| 82 |
-
#gr.Button(key,interactive=False)
|
| 83 |
-
#for value in values:
|
| 84 |
-
# gr.Button(value).click(add_to_prompt, inputs=[inp, gr.Textbox(value,visible=False)], outputs=inp)
|
| 85 |
|
| 86 |
with gr.Row():
|
| 87 |
-
gen_out = gr.Image(label="Generated Image",type="filepath")
|
| 88 |
-
|
| 89 |
-
# gen_gallery = gr.Gallery(label="Generated Images Gallery", type="filepath")
|
| 90 |
|
| 91 |
with gr.Row(): #Move gen out row
|
| 92 |
move_to_vto =gr.Button("Move to Virtual Try On")
|
| 93 |
-
move_to_fs =gr.Button("Move to Face Swap")
|
| 94 |
move_to_ip =gr.Button("Move to Cloth IP Adapter")
|
| 95 |
-
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
btn.click(generate_image_control_net,
|
| 99 |
inputs=[inp,style_mode,api_path,aspect_ratio,style_strength,use_control_net,control_net_type,control_net_img,control_net_strength],
|
| 100 |
outputs=[gen_out])
|
| 101 |
-
|
|
|
|
|
|
| 20 |
lora_style_support = [
|
| 21 |
["ps1","Test_images/lora_support_examples/ps1.png"],
|
| 22 |
["cyberpunk","Test_images/lora_support_examples/cyberpunk.png"],
|
| 23 |
+
["Sioux","Test_images/lora_support_examples/Raylene.png"],
|
| 24 |
+
["RetroAnime1","Test_images/lora_support_examples/appleseed.png"],
|
| 25 |
+
["RetroAnime2","Test_images/lora_support_examples/appleseed.png"],
|
| 26 |
["half-illustration","Test_images/lora_support_examples/halfillust.png"]
|
| 27 |
]
|
| 28 |
|
|
|
|
| 38 |
|
| 39 |
def create_gen_tab():
|
| 40 |
with gr.TabItem("Image Generator"):
|
| 41 |
+
#Gen how too row
|
| 42 |
+
with gr.Row():
|
| 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():
|
| 66 |
inp = gr.Textbox(label="Prompt",info="日本語対応は可能")
|
| 67 |
+
aspect_ratio = gr.Dropdown(list(["1:1","16:9","9:16","5:4"]),value="1:1", label="Aspect Ratio", info="Image size Aspect Ratio 画像サイズ アスペクト比")
|
| 68 |
btn = gr.Button("Generate")
|
| 69 |
with gr.Accordion("extra", open=False):
|
| 70 |
#Control net
|
|
|
|
| 72 |
control_net_type=gr.Dropdown(["depth","canny","soft_edge"],value="depth",label="Control net type")
|
| 73 |
control_net_img= gr.Image(label="Control net image",type="pil")
|
| 74 |
control_net_strength = gr.Slider(0,1,value=0.4,label="control net strength")
|
| 75 |
+
control_net_examples = gr.Examples(
|
| 76 |
+
examples=["Test_images/Walk_3.png","Test_images/example_outputs/input_2.png","Test_images/Sit_1.png"],
|
| 77 |
+
inputs=[control_net_img]
|
| 78 |
+
)
|
| 79 |
|
| 80 |
|
| 81 |
with gr.Column():
|
| 82 |
|
| 83 |
+
style_mode = gr.Dropdown(list(model_dict.keys()),label="Style lore",value="Base",info="style model スタイルのモデル")
|
| 84 |
with gr.Accordion("Style Imgaes",open=False):
|
| 85 |
# with gr.Column(elem_id="prompt_support_column"):
|
| 86 |
for i,lora in enumerate(lora_style_support):
|
|
|
|
| 89 |
with row:
|
| 90 |
lora_img = gr.Image(value=lora[1], label=lora[0],width=200,height=200, interactive=False)
|
| 91 |
lora_img.select(lambda x:x, inputs=gr.Textbox(value=lora[0],visible=False),outputs=style_mode)
|
| 92 |
+
api_path = gr.Textbox(label="Other_style",info="Style lora .safetensors route goes here or replicate link goes here スタイルのローラの.safetensorsのルートはこちら。",value=None)
|
| 93 |
|
| 94 |
style_strength = gr.Slider(0,2,value=1,label="Style Strength")
|
| 95 |
|
|
|
|
| 106 |
btn_ps=gr.Button(item[1],elem_id="prompt_support_button")
|
| 107 |
img_ps.select(lambda x:x, inputs=gr.Textbox(item[1],visible=False),outputs=inp)
|
| 108 |
btn_ps.click(lambda x:x, inputs=gr.Textbox(item[1],visible=False),outputs=inp)
|
| 109 |
+
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
with gr.Row():
|
| 112 |
+
gen_out = gr.Image(label="Generated Image",type="filepath",elem_id="output_image")
|
| 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 |
+
move_to_fs =gr.Button("Move to Face Swap")
|
| 119 |
+
# move_to_zest=gr.Button("Move to Zest IP Adapter")
|
| 120 |
|
| 121 |
|
| 122 |
btn.click(generate_image_control_net,
|
| 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,move_to_fs,move_to_ip #,move_to_zest
|
ipadapter_tab.py
CHANGED
|
@@ -46,11 +46,15 @@ def create_ipadaptor_tab():
|
|
| 46 |
["Test_images/pattern_2.jpg"],
|
| 47 |
["Test_images/pattern_3.jpg"],
|
| 48 |
["Test_images/pattern_4.jpg"],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
],
|
| 50 |
inputs=[ip_image]
|
| 51 |
)
|
| 52 |
with gr.Row():
|
| 53 |
-
api_out = gr.Image(label="Output",type="filepath")
|
| 54 |
|
| 55 |
ip_btn.click(fal_ipadapter_api,inputs=[api_inp,ip_image,ap_prompt],outputs=api_out)
|
| 56 |
|
|
|
|
| 46 |
["Test_images/pattern_2.jpg"],
|
| 47 |
["Test_images/pattern_3.jpg"],
|
| 48 |
["Test_images/pattern_4.jpg"],
|
| 49 |
+
["https://replicate.delivery/pbxt/Kl23gJODaW7EuxrDzBG9dcgqRdMaYSWmBQ9UexnwPiL7AnIr/3.jpg"],
|
| 50 |
+
["https://replicate.delivery/pbxt/Kl2WefehduxwWcQc5OrrBH6AkojQ6OqyQSKBvBLrroSpEBim/f2f0488a-180e-4d7e-9907-f26f92ac5f16.jpg"],
|
| 51 |
+
["https://replicate.delivery/pbxt/Kl2VlUibviSP8Kq5ULLJmMOWorog1YFu0zTreqhqX97c62ku/572a1fc9-a114-4d5b-8c7c-85aa5648c7b4.jpg"],
|
| 52 |
+
["https://replicate.delivery/pbxt/Kl2VCw1UVIJsYw9r8iqSYUMm65ePJhfYOLNolOE8CwxfRjX2/28481ff0-0829-42af-a658-fb96be2abb3d.jpg"],
|
| 53 |
],
|
| 54 |
inputs=[ip_image]
|
| 55 |
)
|
| 56 |
with gr.Row():
|
| 57 |
+
api_out = gr.Image(label="Output",type="filepath",elem_id="output_image")
|
| 58 |
|
| 59 |
ip_btn.click(fal_ipadapter_api,inputs=[api_inp,ip_image,ap_prompt],outputs=api_out)
|
| 60 |
|
mail_tab.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import smtplib
|
| 3 |
+
import numpy as np
|
| 4 |
+
from email.mime.text import MIMEText
|
| 5 |
+
from email.mime.image import MIMEImage
|
| 6 |
+
from email.mime.multipart import MIMEMultipart
|
| 7 |
+
from email.utils import formatdate
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
def send_email(email, selected_images):
|
| 11 |
+
# Email configuration (replace with your SMTP server details)
|
| 12 |
+
smtp_server = "smtp.gmail.com"
|
| 13 |
+
smtp_port = 587
|
| 14 |
+
# Create the email message
|
| 15 |
+
msg = MIMEMultipart()
|
| 16 |
+
msg['Subject'] = 'Selected Image'
|
| 17 |
+
msg['From'] = os.getenv("sender_email")
|
| 18 |
+
msg['To'] = email
|
| 19 |
+
msg['Date'] = formatdate()
|
| 20 |
+
|
| 21 |
+
# Add text to the email
|
| 22 |
+
text = MIMEText(f"""
|
| 23 |
+
今日はブースを訪れてくれてありがとうございました。。
|
| 24 |
+
以下は、あなたが生成した{len(selected_images)}枚の画像です。
|
| 25 |
+
""",_charset="utf-8")
|
| 26 |
+
msg.attach(text)
|
| 27 |
+
print(selected_images)
|
| 28 |
+
for i,image in enumerate(selected_images):
|
| 29 |
+
image=np.array(image)[0]
|
| 30 |
+
print(image)
|
| 31 |
+
with open(image, 'rb') as f:
|
| 32 |
+
img_data = f.read()
|
| 33 |
+
image = MIMEImage(img_data, name=f"image_{i+1}.jpg")
|
| 34 |
+
msg.attach(image)
|
| 35 |
+
|
| 36 |
+
# Send the email
|
| 37 |
+
try:
|
| 38 |
+
with smtplib.SMTP(smtp_server, smtp_port) as server:
|
| 39 |
+
server.starttls()
|
| 40 |
+
server.login( os.getenv("sender_email"), os.getenv("sender_password"))
|
| 41 |
+
server.send_message(msg)
|
| 42 |
+
return "Email sent successfully!"
|
| 43 |
+
except smtplib.SMTPAuthenticationError:
|
| 44 |
+
raise Exception("SMTP Authentication failed. Please check your email and password.")
|
| 45 |
+
except smtplib.SMTPException as e:
|
| 46 |
+
raise Exception(f"SMTP error occurred: {str(e)}")
|
| 47 |
+
except Exception as e:
|
| 48 |
+
raise Exception(f"Failed to send email: {str(e)}")
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
examples= ["Test_images/Woman_1.png","Test_images/prompt_support_examples/Man_1.png"]
|
| 54 |
+
select_list=[]
|
| 55 |
+
|
| 56 |
+
from src.utils import convert_to_pil
|
| 57 |
+
def update_gallery(img,select_list=select_list):
|
| 58 |
+
#img=convert_to_pil(img)
|
| 59 |
+
if select_list is None:
|
| 60 |
+
select_list=[]
|
| 61 |
+
select_list.append(img)
|
| 62 |
+
return select_list
|
| 63 |
+
|
| 64 |
+
def clear_selection(select_list=select_list):
|
| 65 |
+
if select_list is not None:
|
| 66 |
+
select_list=[]
|
| 67 |
+
return select_list
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def create_mail_tab():
|
| 71 |
+
|
| 72 |
+
with gr.TabItem("Mail", id="mail"):
|
| 73 |
+
email_input = gr.Textbox(label="Enter your email:")
|
| 74 |
+
image_gallery = gr.Gallery(label="Selected Images", show_label=True, elem_id="gallery")
|
| 75 |
+
with gr.Row():
|
| 76 |
+
clear_button = gr.Button("Clear Selection")
|
| 77 |
+
send_button = gr.Button("Send Email")
|
| 78 |
+
result_output = gr.Textbox(label="Result")
|
| 79 |
+
|
| 80 |
+
# Examples
|
| 81 |
+
with gr.Row():
|
| 82 |
+
print(examples)
|
| 83 |
+
examples=np.array(examples)
|
| 84 |
+
for example in examples:
|
| 85 |
+
print(example)
|
| 86 |
+
img=gr.Image(value=example, interactive=False, label=os.path.basename(example),type="filepath")
|
| 87 |
+
img.select(update_gallery,inputs=img,outputs=image_gallery)
|
| 88 |
+
|
| 89 |
+
# Connect the send button to the send_email function
|
| 90 |
+
send_button.click(
|
| 91 |
+
fn=send_email,
|
| 92 |
+
inputs=[email_input, image_gallery],
|
| 93 |
+
outputs=result_output
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# Clear the selected images
|
| 97 |
+
clear_button.click(
|
| 98 |
+
fn=clear_selection,
|
| 99 |
+
inputs=None,
|
| 100 |
+
outputs=image_gallery,
|
| 101 |
+
|
| 102 |
+
)
|
model_dict.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
| 2 |
"Base":["xlabs-ai/flux-dev-realism:39b3434f194f87a900d1bc2b6d4b983e90f0dde1d5022c27b52c143d670758fa","https://huggingface.co/XLabs-AI/flux-RealismLora/resolve/main/lora.safetensors","REALISM"],
|
| 3 |
"ps1":["veryvanya/flux-ps1-style:e785bcd326ea7a2c6efef8c43122a289f2c344370a4b74b2c7fa1a5ff4c38fea","https://huggingface.co/veryVANYA/ps1-style-flux/resolve/main/ps1_style_flux_v1.safetensors","ps1 game screenshot"],
|
| 4 |
"cyberpunk":["fofr/flux-80s-cyberpunk:5d0cefd0746b833042b384c3a310bc4d1f9d1304ec59ba93e75097d40b967180","https://huggingface.co/fofr/flux-80s-cyberpunk/resolve/main/lora.safetensors","style of 80s cyberpunk"],
|
| 5 |
-
"
|
| 6 |
-
"
|
|
|
|
| 7 |
"half-illustration":["davisbrown/flux-half-illustration:687458266007b196a490e79a77bae4b123c1792900e1cb730a51344887ad9832","https://huggingface.co/davisbro/half_illustration/resolve/main/flux_train_replicate.safetensors?download=true","In the style of TOK,vibrant illustration"]
|
| 8 |
}
|
|
|
|
| 2 |
"Base":["xlabs-ai/flux-dev-realism:39b3434f194f87a900d1bc2b6d4b983e90f0dde1d5022c27b52c143d670758fa","https://huggingface.co/XLabs-AI/flux-RealismLora/resolve/main/lora.safetensors","REALISM"],
|
| 3 |
"ps1":["veryvanya/flux-ps1-style:e785bcd326ea7a2c6efef8c43122a289f2c344370a4b74b2c7fa1a5ff4c38fea","https://huggingface.co/veryVANYA/ps1-style-flux/resolve/main/ps1_style_flux_v1.safetensors","ps1 game screenshot"],
|
| 4 |
"cyberpunk":["fofr/flux-80s-cyberpunk:5d0cefd0746b833042b384c3a310bc4d1f9d1304ec59ba93e75097d40b967180","https://huggingface.co/fofr/flux-80s-cyberpunk/resolve/main/lora.safetensors","style of 80s cyberpunk"],
|
| 5 |
+
"Sioux": ["jarvis-labs2024/sioux-flux:19afc63be3ff9838cf9d1225617f8ab0d6f8a9b2b8d6e836ee08d4a0f109c33f","https://replicate.delivery/yhqm/l8drADSeN6S2ekAF5cofeB7yn4C6X57r0VlvYjEbFVjTJbpNB/trained_model.tar"," SOK"],
|
| 6 |
+
"RetroAnime1": ["jarvis-labs2024/flux-appleseed:0aecb9fdfb17a2517112cc70b4a1898aa7791da84a010419782ce7043481edec","https://replicate.delivery/yhqm/6v6JOdXtArJZEBbsjPoYSC6lezM2Is12eghIoQBhlnWNI0UTA/trained_model.tar","style of APPLESEED anime"],
|
| 7 |
+
"RetroAnime2": ["galverse/mama-flux-v1:dec77f91f71155f16c6bfe7df2cbacec18d0e4816ee772be48738ea9f9423a30","https://replicate.delivery/yhqm/Jg4kWsYyHnIwMl7XgeWY280o6lfNk3LMh0MxOSo2mUV2q5VTA/trained_model.tar","Retro anime style, GALVERSE"],
|
| 8 |
"half-illustration":["davisbrown/flux-half-illustration:687458266007b196a490e79a77bae4b123c1792900e1cb730a51344887ad9832","https://huggingface.co/davisbro/half_illustration/resolve/main/flux_train_replicate.safetensors?download=true","In the style of TOK,vibrant illustration"]
|
| 9 |
}
|
virtualtryon_tab.py
CHANGED
|
@@ -60,8 +60,18 @@ def create_virtualtryon_tab():
|
|
| 60 |
with gr.Row():
|
| 61 |
tryon_btn = gr.Button("Try-on")
|
| 62 |
with gr.Row():
|
| 63 |
-
tryon_out = gr.Image(label="Output", type="filepath")
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
tryon_btn.click(virtual_try_on, inputs=[crop, seed, steps, category, garm_img, human_img,garment_des],outputs=tryon_out)
|
| 67 |
|
|
|
|
| 60 |
with gr.Row():
|
| 61 |
tryon_btn = gr.Button("Try-on")
|
| 62 |
with gr.Row():
|
| 63 |
+
tryon_out = gr.Image(label="Output", type="filepath",elem_id="output_image")
|
| 64 |
+
with gr.Row():
|
| 65 |
+
tryon_examples = gr.Examples(
|
| 66 |
+
examples=[
|
| 67 |
+
["Test_images/example_outputs/input_1.webp",True,"Test_images/pink_jumper.png","pink jumper","upper_body","Test_images/example_outputs/input_1_VTO_Pink.jpg"],
|
| 68 |
+
["Test_images/example_outputs/input_3.png",True,"Test_images/Jacket_2.png","jacket","upper_body","Test_images/example_outputs/input_3_VTO_whiteJacket.jpg"],
|
| 69 |
+
["Test_images/example_outputs/input_4.png",True,"Test_images/Jacket_1.png","colorfull leather jacket","upper_body","Test_images/example_outputs/Input_4_VTO_ColorFullJacket.jpg"],
|
| 70 |
+
["Test_images/example_outputs/input_4.png",True,"Test_images/dress_1.png","dress","dresses","Test_images/example_outputs/Input_3_VTO_LoritaDress.jpg"],
|
| 71 |
+
["Test_images/example_outputs/input_4.png",True,"Test_images/Shirt_1.png"," Shirt","upper_body","Test_images/example_outputs/Input_3_VTO_Shirt.jpg"],
|
| 72 |
+
],
|
| 73 |
+
inputs=[human_img,crop,garm_img,garment_des,category,tryon_out],
|
| 74 |
+
)
|
| 75 |
|
| 76 |
tryon_btn.click(virtual_try_on, inputs=[crop, seed, steps, category, garm_img, human_img,garment_des],outputs=tryon_out)
|
| 77 |
|