JarvisLabs commited on
Commit
34492bf
1 Parent(s): 6ff9f3e

Upload 12 files

Browse files
Files changed (11) hide show
  1. app.py +34 -13
  2. faceswap_tab.py +1 -7
  3. fal_api.py +61 -0
  4. gen_tab.py +58 -21
  5. ipadapter_tab.py +56 -54
  6. mockup_tab.py +0 -0
  7. model_dict.json +8 -8
  8. pattern_ip_adapter.py +47 -0
  9. requirments.txt +8 -0
  10. style_tab.py +24 -0
  11. virtualtryon_tab.py +8 -10
app.py CHANGED
@@ -4,39 +4,60 @@ 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 dotenv import load_dotenv, find_dotenv
8
  import os
9
-
10
  gallery_list=[]
 
11
  def update_gallery(img):
 
 
12
  gallery_list.append(img)
13
  return gallery_list
14
 
15
- _ = load_dotenv(find_dotenv())
16
- with gr.Blocks(theme=gr.themes.Soft(
17
  radius_size=gr.themes.sizes.radius_none,
18
  primary_hue=gr.themes.colors.emerald,
19
- secondary_hue=gr.themes.colors.green
20
- )) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  with gr.Tabs() as tabs:
22
- gen_out,move_to_vto,move_to_fs,move_to_ip = create_gen_tab()
 
23
  input_vto,output_vto=create_virtualtryon_tab()
 
24
  input_fs,output_fs=create_faceswap_tab()
25
- input_ip,output_ip=create_ipadaptor_tab()
26
- create_train_tab()
27
 
28
- #Buttons
 
29
  move_to_vto.click(lambda x:x, inputs=gen_out,outputs=input_vto)
30
  move_to_fs.click(lambda x:x, inputs=gen_out,outputs=input_fs)
31
  move_to_ip.click(lambda x:x, inputs=gen_out,outputs=input_ip)
 
32
 
33
-
34
  #Gallery
35
- image_gallery = gr.Gallery(label="Generated Images Gallery", type="filepath")
36
- #Gallery updates
37
  gen_out.change(update_gallery,inputs=gen_out,outputs=image_gallery)
38
  output_vto.change(update_gallery,inputs=output_vto,outputs=image_gallery)
39
  output_fs.change(update_gallery,inputs=output_fs,outputs=image_gallery)
40
  output_ip.change(update_gallery,inputs=output_ip,outputs=image_gallery)
 
41
 
42
- demo.launch(share=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 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
+
13
  def update_gallery(img):
14
+ img=convert_to_pil(img)
15
+
16
  gallery_list.append(img)
17
  return gallery_list
18
 
19
+
20
+ theme= gr.themes.Soft(
21
  radius_size=gr.themes.sizes.radius_none,
22
  primary_hue=gr.themes.colors.emerald,
23
+ secondary_hue=gr.themes.colors.green)
24
+ css = """
25
+ h1{font-size: 2em}
26
+ h3{margin-top: 10}
27
+ #component-1{text-align:left}
28
+ .main_ui_logged_out{opacity: 0.3; pointer-events: none}
29
+ .tabitem{border: 20px}
30
+ .tabitem h1 {
31
+ font-size: 5em; /* Adjust this value to make the headings bigger */
32
+ }
33
+
34
+ .group_padding{padding: .55em}
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,move_to_zest= create_gen_tab()
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
+
48
+ # Move to Buttons
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
+ move_to_zest.click(lambda x:x, inputs=gen_out,outputs=input_zest)
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
+ output_zest.change(update_gallery,inputs=output_zest,outputs=image_gallery)
62
 
63
+ demo.launch(share=True,show_error=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
faceswap_tab.py CHANGED
@@ -14,13 +14,7 @@ def create_faceswap_tab():
14
  with gr.Row():
15
  face_out = gr.Image(label="Output",type="filepath")
16
 
17
- with gr.Row():
18
- examples = gr.Examples(
19
- examples=[
20
- [ "Test_images/person_2.jpg", "Test_images/person_1.jpg"],
21
- ],
22
- inputs=[ fs_base_inp,face_image]
23
- )
24
 
25
  face_btn.click(fal_faceswap_api,inputs=[fs_base_inp,face_image],outputs=face_out)
26
 
 
14
  with gr.Row():
15
  face_out = gr.Image(label="Output",type="filepath")
16
 
17
+
 
 
 
 
 
 
18
 
19
  face_btn.click(fal_faceswap_api,inputs=[fs_base_inp,face_image],outputs=face_out)
20
 
fal_api.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import base64
3
+ from fal_client import FalClient
4
+ from src.utils import numpy_to_base64,resize_image
5
+ import json
6
+ # Initialize FalClient
7
+ fal_client = FalClient()
8
+ styles_dic= json.dump(open("src/styles.json"))
9
+
10
+ def fal_api(prompt,ar,nis,seed,style,model="fal-ai/flux-general"):
11
+ inputs={
12
+ "prompt":prompt,
13
+
14
+ "num_inference_steps":nis,
15
+
16
+ }
17
+ if ar is not None:
18
+ inputs["image_size"]=ar
19
+
20
+ if seed is not None:
21
+ inputs["seed"]=seed
22
+ if style is not None:
23
+ style_type=styles_dic[style][1]
24
+ if style_type=="model":
25
+ model=styles_dic[style][0]
26
+ if style_type=="lora":
27
+ #inputs["LoraWeight"]=styles_dic[style][0]
28
+ inputs["loras"]= { "path": styles_dic[style][0]},
29
+ if len(styles_dic[style])==3: #Add in prompt triggers
30
+ inputs["prompt"]+=styles_dic[style][2]
31
+
32
+ if style_type=="prompt":
33
+ inputs["prompt"]+=styles_dic[style][0]
34
+
35
+ handler = fal_client.submit(
36
+ model,
37
+ arguments=inputs
38
+ )
39
+ return handler.get()["images"][0]["url"]
40
+
41
+
42
+ def fal_ipadapter_api(input_image,ip_image,seg_prompt):
43
+ print(input_image,ip_image,seg_prompt)
44
+
45
+ handler = fal_client.submit(
46
+ "comfy/JarvisSan22/cloth_ipadapter",
47
+ arguments={
48
+ "loadimage_1":numpy_to_base64(input_image),
49
+ "loadimage_2":numpy_to_base64(ip_image),
50
+ "groundingdinosamsegment (segment anything)_prompt":seg_prompt
51
+ },
52
+ )
53
+ print(handler)
54
+ result= handler.get()
55
+ #image_urls=[]
56
+ print(result["outputs"])
57
+
58
+ #print(result)
59
+ return result["outputs"]["20"]["images"][0]["url"]
60
+
61
+
gen_tab.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  from src.utils import add_to_prompt
3
- from src.rep_api import generate_image_replicate, model_dict
4
  import os
5
 
6
  # The dictionary data
@@ -17,37 +17,71 @@ prompt_dict_kp ={
17
  "Scene": ["シンプルな白背景", "ファッションランウェイ", "ビジネス会議の中", "宇宙船の内部"]
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  def create_gen_tab():
23
  with gr.TabItem("Image Generator"):
24
  with gr.Row():
25
  with gr.Column():
26
- inp = gr.Textbox(label="Prompt")
 
 
27
  with gr.Accordion("extra", open=False):
28
- replicate_api_key = gr.Textbox(
29
- label="Replicate API Key",
30
- info="API key for Replicate",
31
- value=os.environ.get("REPLICATE_API_TOKEN", ""),
32
- type="password",
33
- )
34
- model_type= gr.Dropdown(["dev","schnell"],value="dev",label="flux model base", info="dev - higher quailty but longer \n schnell lower quaility but faster")
35
 
36
-
37
- btn = gr.Button("Generate")
38
  with gr.Column():
39
- aspect_ratio = gr.Dropdown(list(["1:1","16:9","9:16","5:4"]),value="1:1", label="Aspect Ratio", info="Aspect Ratio")
40
  style_mode = gr.Dropdown(list(model_dict.keys()),label="Style lore",value="Base",info="style model")
 
 
 
 
 
 
 
 
 
 
41
  style_strength = gr.Slider(0,2,value=1,label="Style Strength")
42
- api_path = gr.Textbox(label="Other_style",info="Style lora safytensor route goes here or replicate link goes here",value=None)
43
-
44
 
 
 
 
45
  with gr.Accordion("Prompt Support", open=False):
46
- for key, values in prompt_dict.items():
47
- with gr.Row():
48
- gr.Button(key,interactive=False)
49
- for value in values:
50
- gr.Button(value).click(add_to_prompt, inputs=[inp, gr.Textbox(value,visible=False)], outputs=inp)
 
 
 
 
 
 
 
 
51
 
52
  with gr.Row():
53
  gen_out = gr.Image(label="Generated Image",type="filepath")
@@ -58,7 +92,10 @@ def create_gen_tab():
58
  move_to_vto =gr.Button("Move to Virtual Try On")
59
  move_to_fs =gr.Button("Move to Face Swap")
60
  move_to_ip =gr.Button("Move to Cloth IP Adapter")
 
61
 
62
 
63
- btn.click(generate_image_replicate, inputs=[inp,style_mode,api_path,aspect_ratio,model_type,style_strength], outputs=[gen_out])
64
- return gen_out,move_to_vto,move_to_fs,move_to_ip
 
 
 
1
  import gradio as gr
2
  from src.utils import add_to_prompt
3
+ from src.rep_api import generate_image_replicate,generate_image_control_net, model_dict
4
  import os
5
 
6
  # The dictionary data
 
17
  "Scene": ["シンプルな白背景", "ファッションランウェイ", "ビジネス会議の中", "宇宙船の内部"]
18
  }
19
 
20
+ lora_style_support = [
21
+ ["ps1","Test_images/lora_support_examples/ps1.png"],
22
+ ["cyberpunk","Test_images/lora_support_examples/cyberpunk.png"],
23
+ ["Raylean","Test_images/lora_support_examples/Raylene.png"],
24
+ ["AppleSeed","Test_images/lora_support_examples/appleseed.png"],
25
+ ["half-illustration","Test_images/lora_support_examples/halfillust.png"]
26
+ ]
27
+
28
+ prompt_support = [
29
+ ["Test_images/prompt_support_examples/Man_1.png","A full body photo man standing with blond hair wearing a suit"],
30
+ ["Test_images/prompt_support_examples/Woman_1.png","A full body photo girl standing with blond hair wearing a suit "],
31
+ ["Test_images/prompt_support_examples/Woman_2.png","a Asian girl as at a fashion show walking down the cat walk, wearing a red dress"],
32
+ ["Test_images/prompt_support_examples/Man_2.png","A High exposure photo of a Asian man wearing a blue shirt at a business conference, blue shirt, short black hair, hands out welcoming people into a booth, booth with a green and white color scheme "],
33
+ ["Test_images/prompt_support_examples/Shoes_1.png","a product photo of high tech shoes with lights and a wifi symbol on the side, low angle shot, front view of walking down stairs "],
34
+ ["Test_images/prompt_support_examples/Jacket_1.png","a product photo of green checked jacked being on a man from behind , furry collar, large cute character logo of a cat on back of jacket, simple background,"],
35
+ ]
36
 
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
47
+ use_control_net=gr.Checkbox(label="Use Control net",value=False)
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):
59
+ if i % 3 == 0:
60
+ row = gr.Row() # Start a new row
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 safytensor route goes here or replicate link goes here",value=None)
65
+
66
  style_strength = gr.Slider(0,2,value=1,label="Style Strength")
 
 
67
 
68
+
69
+
70
+
71
  with gr.Accordion("Prompt Support", open=False):
72
+ for i,item in enumerate(prompt_support):
73
+ if i % 6 ==0:
74
+ row=gr.Row()
75
+ with row:
76
+ with gr.Column(elem_id="prompt_support_column"):
77
+ img_ps=gr.Image(value=item[0],label="",interactive=False)
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")
 
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
+ move_to_zest=gr.Button("Move to Zest IP Adapter")
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
+ return gen_out,move_to_vto,move_to_fs,move_to_ip,move_to_zest
ipadapter_tab.py CHANGED
@@ -1,55 +1,57 @@
1
- from src.fal_api import fal_ipadapter_api
2
- import gradio as gr
3
-
4
-
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")
11
- ap_prompt = gr.Textbox(label="clothe prompt")
12
- with gr.Accordion("Example People", open=False):
13
- human_examples = gr.Examples(
14
- examples=[
15
- ["Test_images/Woman_1.png"],
16
- ["Test_images/man_1.png"],
17
- ["Test_images/Woman_2.png"],
18
-
19
- ["Test_images/Woman_3.png"],
20
-
21
- ["Test_images/Woman_4.png"],
22
- ["Test_images/Woman_5.png"],
23
- ["Test_images/anime_woman_1.png"],
24
- ["Test_images/anime_woman_2.png"],
25
- ["Test_images/anime_woman_3.png"],
26
- ["Test_images/Jump.png"],
27
- ["Test_images/Walk_1.png"],
28
- ["Test_images/Walk_2.png"],
29
- ["Test_images/Walk_girl_1.png"],
30
- ["Test_images/Walk_girl_2.png"]
31
- ],
32
- inputs=[api_inp]
33
- )
34
-
35
- with gr.Column():
36
- ip_image = gr.Image(label="IP Adapter Image")
37
- ip_btn = gr.Button("Process")
38
- with gr.Accordion("Example Stles and clothes ", open=False):
39
- ip_examples = gr.Examples(
40
- examples=[
41
- ["Test_images/style_1.jpg"],
42
- ["Test_images/style_2.png"],
43
- ["Test_images/Style_3.png"],
44
- ["Test_images/Style_4.png"],
45
- ["Test_images/dress_5.png"],
46
- ["Test_images/Jacket_1.png"]
47
- ],
48
- inputs=[ip_image]
49
- )
50
- with gr.Row():
51
- api_out = gr.Image(label="Output",type="filepath")
52
-
53
- ip_btn.click(fal_ipadapter_api,inputs=[api_inp,ip_image,ap_prompt],outputs=api_out)
54
-
 
 
55
  return api_inp,api_out
 
1
+ from src.fal_api import fal_ipadapter_api
2
+ import gradio as gr
3
+
4
+
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")
11
+ ap_prompt = gr.Textbox(label="clothe prompt")
12
+ with gr.Accordion("Example People", open=False):
13
+ human_examples = gr.Examples(
14
+ examples=[
15
+ ["Test_images/Woman_1.png"],
16
+ ["Test_images/man_1.jpg"],
17
+ ["Test_images/Woman_2.png"],
18
+ ["Test_images/person_2.jpg"],
19
+ ["Test_images/Woman_3.png"],
20
+ ["Test_images/man_1.png"],
21
+ ["Test_images/Woman_4.png"],
22
+ ["Test_images/Woman_5.png"],
23
+ ["Test_images/anime_woman_1.png"],
24
+ ["Test_images/anime_woman_2.png"],
25
+ ["Test_images/anime_woman_3.png"],
26
+ ["Test_images/Jump.png"],
27
+ ["Test_images/Walk_1.png"],
28
+ ["Test_images/Walk_2.png"],
29
+ ["Test_images/Walk_girl_1.png"],
30
+ ["Test_images/Walk_girl_2.png"]
31
+ ],
32
+ inputs=[api_inp]
33
+ )
34
+
35
+ with gr.Column():
36
+ ip_image = gr.Image(label="IP Adapter Image")
37
+ ip_btn = gr.Button("Process")
38
+ with gr.Accordion("Example Stles and clothes ", open=False):
39
+ ip_examples = gr.Examples(
40
+ examples=[
41
+ ["Test_images/style_1.jpg"],
42
+ ["Test_images/style_2.png"],
43
+ ["Test_images/Style_3.png"],
44
+ ["Test_images/Style_4.png"],
45
+ ["Test_images/pattern_1.png"],
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
+
57
  return api_inp,api_out
mockup_tab.py ADDED
File without changes
model_dict.json CHANGED
@@ -1,8 +1,8 @@
1
- {
2
- "Base":"xlabs-ai/flux-dev-realism:39b3434f194f87a900d1bc2b6d4b983e90f0dde1d5022c27b52c143d670758fa",
3
- "ps1":"veryvanya/flux-ps1-style:e785bcd326ea7a2c6efef8c43122a289f2c344370a4b74b2c7fa1a5ff4c38fea",
4
- "mystic-animals":"halimalrasihi/flux-mystic-animals:294de709b06655e61bb0149ec61ef8b5d3ca030517528ac34f8252b18b09b7ad",
5
- "cyberpunk":"fofr/flux-80s-cyberpunk:5d0cefd0746b833042b384c3a310bc4d1f9d1304ec59ba93e75097d40b967180",
6
- "Raylean": "jarvis-labs2024/flux-raylene:5574556226d11e0f10855a957d91f118a9178c8fc77e7e7b18830627ce3184f1",
7
- "AppleSeed": "jarvis-labs2024/flux-appleseed:0aecb9fdfb17a2517112cc70b4a1898aa7791da84a010419782ce7043481edec"
8
- }
 
1
+ {
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
+ "Raylean": ["jarvis-labs2024/flux-raylene:5574556226d11e0f10855a957d91f118a9178c8fc77e7e7b18830627ce3184f1","https://replicate.delivery/yhqm/jpM5dp9JqOoYPdvF2lXsdWC0cV0XBHWQHmflBYz9L3IegyTTA/trained_model.tar"," SOK"],
6
+ "AppleSeed": ["jarvis-labs2024/flux-appleseed:0aecb9fdfb17a2517112cc70b4a1898aa7791da84a010419782ce7043481edec","https://replicate.delivery/yhqm/6v6JOdXtArJZEBbsjPoYSC6lezM2Is12eghIoQBhlnWNI0UTA/trained_model.tar","style of APPLESEED anime"],
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
+ }
pattern_ip_adapter.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from src.rep_api import sam_segment,replicate_zest
3
+ from src.utils import open_image_from_url,image_to_base64,cut_alpha_from_image
4
+ from src.utils import convert_to_pil
5
+
6
+ def sam_zest(image,prompt,negative_prompt,material_img):
7
+ outputs=sam_segment(image,prompt,negative_prompt)
8
+ mask = open_image_from_url(outputs["inverted_mask"])
9
+ mask_ = mask.convert("L").point(lambda x: 255 - x)
10
+ img=image.copy()
11
+ img=convert_to_pil(img)
12
+ img.putalpha(mask_)
13
+ output=replicate_zest(cut_alpha_from_image(img),material_img=material_img)
14
+ zest_img=open_image_from_url(output)
15
+ zest_img=zest_img.resize((img.size))
16
+ zest_img.putalpha(mask_)
17
+ image.paste(zest_img,(0,0),mask_)
18
+ return image
19
+
20
+ def sam_zest_tab():
21
+ with gr.TabItem("Zest Segment",id="zest_seg"):
22
+ with gr.Row():
23
+ with gr.Column():
24
+ image=gr.Image(label="Base Image")
25
+ seg_prompt=gr.Textbox(label="Segment area")
26
+ seg_negative=gr.Textbox(label="Dont seg area")
27
+
28
+ zest_image=gr.Image(label="Zest image")
29
+ zest_examples= gr.Examples(
30
+ examples=[
31
+ "https://replicate.delivery/pbxt/Kl23gJODaW7EuxrDzBG9dcgqRdMaYSWmBQ9UexnwPiL7AnIr/3.jpg",
32
+ "https://replicate.delivery/pbxt/Kl2WefehduxwWcQc5OrrBH6AkojQ6OqyQSKBvBLrroSpEBim/f2f0488a-180e-4d7e-9907-f26f92ac5f16.jpg",
33
+ "https://replicate.delivery/pbxt/Kl2VlUibviSP8Kq5ULLJmMOWorog1YFu0zTreqhqX97c62ku/572a1fc9-a114-4d5b-8c7c-85aa5648c7b4.jpg",
34
+ "https://replicate.delivery/pbxt/Kl2VCw1UVIJsYw9r8iqSYUMm65ePJhfYOLNolOE8CwxfRjX2/28481ff0-0829-42af-a658-fb96be2abb3d.jpg",
35
+ "Test_images/pattern_1.png",
36
+ "Test_images/pattern_2.jpg",
37
+ "Test_images/pattern_3.jpg",
38
+ "Test_images/pattern_4.jpg"],
39
+
40
+ inputs=[zest_image])
41
+ with gr.Column():
42
+ gen_zest=gr.Button("Add ZEST")
43
+ output_img=gr.Image(label="output")
44
+
45
+ gen_zest.click(sam_zest,inputs=[image,seg_prompt,seg_negative,zest_image],outputs=[output_img])
46
+ return image,output_img
47
+
requirments.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ fal
3
+ fal-client
4
+ numpy
5
+ replicate
6
+ python-dotenv
7
+ langdetect
8
+ deepl
style_tab.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def create_style_tab(demo):
4
+ with gr.TabItem("Style Customization"):
5
+ theme_dropdown = gr.Dropdown(choices=["Default", "Glass", "Monochrome", "Soft"], label="Choose a Theme")
6
+ custom_css = gr.Textbox(label="Custom CSS", placeholder="Enter custom CSS here...")
7
+ apply_button = gr.Button("Apply Style")
8
+
9
+ def apply_style(theme, css):
10
+ if theme == "Default":
11
+ demo.theme = gr.themes.Default()
12
+ elif theme == "Glass":
13
+ demo.theme = gr.themes.Glass()
14
+ elif theme == "Monochrome":
15
+ demo.theme = gr.themes.Monochrome()
16
+ elif theme == "Soft":
17
+ demo.theme = gr.themes.Soft()
18
+
19
+ if css:
20
+ demo.css = css
21
+
22
+ apply_button.click(apply_style, inputs=[theme_dropdown, custom_css], outputs=[])
23
+
24
+ return demo
virtualtryon_tab.py CHANGED
@@ -7,16 +7,18 @@ def create_virtualtryon_tab():
7
  with gr.Row():
8
  with gr.Column():
9
  human_img = gr.Image(label="Human Image")
10
- crop = gr.Checkbox(label="Crop", value=False)
11
  seed = gr.Number(label="Seed", value=42)
12
  steps = gr.Number(label="Steps", value=30)
 
 
13
  with gr.Accordion("Example People", open=False):
14
  human_examples = gr.Examples(
15
  examples=[
16
  ["Test_images/Woman_1.png"],
17
- ["Test_images/person_1.jpg"],
18
  ["Test_images/Woman_2.png"],
19
- ["Test_images/person_2.jpg"],
20
  ["Test_images/Woman_3.png"],
21
  ["Test_images/man_1.png"],
22
  ["Test_images/Woman_4.png"],
@@ -25,19 +27,15 @@ def create_virtualtryon_tab():
25
  ["Test_images/anime_woman_2.png"],
26
  ["Test_images/anime_woman_3.png"],
27
  ["Test_images/Jump.png"],
28
- ["Test_images/Walk_1.png"],
29
- ["Test_images/Walk_2.png"],
30
- ["Test_images/Walk_girl_1.png"],
31
- ["Test_images/Walk_girl_2.png"]
32
  ],
33
  inputs=[human_img],
34
  examples_per_page=24
35
  )
36
  with gr.Column():
37
  garm_img = gr.Image(label="Garment Image")
38
- category = gr.Dropdown(["upper_body", "lower_body", "dresses"], label="Category", value="upper_body")
39
- garment_des = gr.Textbox(label="Garment Description")
40
- with gr.Accordion("Example Clothes", open=False):
41
  cloth_examples = gr.Examples(
42
  examples=[
43
  ["Test_images/pink_jumper.png","pink jumper","upper_body"],
 
7
  with gr.Row():
8
  with gr.Column():
9
  human_img = gr.Image(label="Human Image")
10
+ crop = gr.Checkbox(label="Crop", value=True)
11
  seed = gr.Number(label="Seed", value=42)
12
  steps = gr.Number(label="Steps", value=30)
13
+ category = gr.Dropdown(["upper_body", "lower_body", "dresses"], label="Category", value="upper_body")
14
+ garment_des = gr.Textbox(label="Garment Description")
15
  with gr.Accordion("Example People", open=False):
16
  human_examples = gr.Examples(
17
  examples=[
18
  ["Test_images/Woman_1.png"],
19
+ ["Test_images/prompt_support_examples/Man_1.png"],
20
  ["Test_images/Woman_2.png"],
21
+ ["Test_images/prompt_support_examples/Man2_2.png"],
22
  ["Test_images/Woman_3.png"],
23
  ["Test_images/man_1.png"],
24
  ["Test_images/Woman_4.png"],
 
27
  ["Test_images/anime_woman_2.png"],
28
  ["Test_images/anime_woman_3.png"],
29
  ["Test_images/Jump.png"],
30
+
31
+
 
 
32
  ],
33
  inputs=[human_img],
34
  examples_per_page=24
35
  )
36
  with gr.Column():
37
  garm_img = gr.Image(label="Garment Image")
38
+ with gr.Accordion("Example Clothes", open=True):
 
 
39
  cloth_examples = gr.Examples(
40
  examples=[
41
  ["Test_images/pink_jumper.png","pink jumper","upper_body"],