Spaces:
Running
Running
JarvisLabs
commited on
Commit
•
743d32b
1
Parent(s):
85ef76c
Upload 2 files
Browse files- app.py +6 -5
- gen_tab.py +50 -47
app.py
CHANGED
@@ -2,21 +2,22 @@ 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 dotenv import load_dotenv, find_dotenv
|
6 |
import os
|
7 |
|
8 |
_ = load_dotenv(find_dotenv())
|
9 |
with gr.Blocks(theme=gr.themes.Soft(
|
10 |
radius_size=gr.themes.sizes.radius_none,
|
11 |
-
primary_hue=gr.themes.colors.emerald,
|
12 |
-
|
13 |
)) as demo:
|
14 |
with gr.Tabs() as tabs:
|
15 |
create_gen_tab()
|
16 |
-
create_train_tab()
|
17 |
create_virtualtryon_tab()
|
18 |
-
|
19 |
-
|
20 |
|
21 |
|
22 |
demo.launch(share=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
|
|
|
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 |
+
|
7 |
from dotenv import load_dotenv, find_dotenv
|
8 |
import os
|
9 |
|
10 |
_ = load_dotenv(find_dotenv())
|
11 |
with gr.Blocks(theme=gr.themes.Soft(
|
12 |
radius_size=gr.themes.sizes.radius_none,
|
13 |
+
primary_hue=gr.themes.colors.emerald,
|
14 |
+
secondary_hue=gr.themes.colors.green
|
15 |
)) as demo:
|
16 |
with gr.Tabs() as tabs:
|
17 |
create_gen_tab()
|
|
|
18 |
create_virtualtryon_tab()
|
19 |
+
create_train_tab()
|
20 |
+
|
21 |
|
22 |
|
23 |
demo.launch(share=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
|
gen_tab.py
CHANGED
@@ -1,47 +1,50 @@
|
|
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
|
7 |
-
prompt_dict = {
|
8 |
-
"Character": ["Asian girl with black hair", "A man with blond hair", "A Cat girl anime character with purple hair", "A Green Alien with big black eyes"],
|
9 |
-
"Clothes": ["Wearing a blue jacket", "Wearing a black business suit", "Wearing a purple jumpsuit", "Wearing shorts and a white T-shirt"],
|
10 |
-
"Pose": ["Close up portrait", "Standing doing a peace sign", "Folding arms", "holding a phone"],
|
11 |
-
"Style": ["Simple white background", "Fashion runway", "Inside a business conference", "Inside a spaceship"]
|
12 |
-
}
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
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
|
7 |
+
prompt_dict = {
|
8 |
+
"Character": ["Asian girl with black hair", "A man with blond hair", "A Cat girl anime character with purple hair", "A Green Alien with big black eyes"],
|
9 |
+
"Clothes": ["Wearing a blue jacket", "Wearing a black business suit", "Wearing a purple jumpsuit", "Wearing shorts and a white T-shirt"],
|
10 |
+
"Pose": ["Close up portrait", "Standing doing a peace sign", "Folding arms", "holding a phone"],
|
11 |
+
"Style": ["Simple white background", "Fashion runway", "Inside a business conference", "Inside a spaceship"],
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
def create_gen_tab():
|
16 |
+
with gr.TabItem("Image Generator"):
|
17 |
+
with gr.Row():
|
18 |
+
with gr.Column():
|
19 |
+
inp = gr.Textbox(label="Prompt")
|
20 |
+
with gr.Accordion("extra", open=False):
|
21 |
+
replicate_api_key = gr.Textbox(
|
22 |
+
label="Replicate API Key",
|
23 |
+
info="API key for Replicate",
|
24 |
+
value=os.environ.get("REPLICATE_API_TOKEN", ""),
|
25 |
+
type="password",
|
26 |
+
)
|
27 |
+
model_type= gr.Dropdown(["dev","schnell"],value="dev",label="flux model base", info="dev - higher quailty but longer \n schnell lower quaility but faster")
|
28 |
+
|
29 |
+
|
30 |
+
btn = gr.Button("Generate")
|
31 |
+
with gr.Column():
|
32 |
+
aspect_ratio = gr.Dropdown(list(["1:1","16:9","9:16","5:3"]),value="1:1", label="Aspect Ratio", info="Aspect Ratio")
|
33 |
+
style_mode = gr.Dropdown(list(model_dict.keys()),label="Style lore",value="Base",info="style model")
|
34 |
+
style_strength = gr.Slider(0,2,value=1,label="Style Strength")
|
35 |
+
api_path = gr.Textbox(label="Other_style",info="Style lora safytensor route goes here or replicate link goes here",value=None)
|
36 |
+
|
37 |
+
|
38 |
+
with gr.Accordion("Prompt Support", open=False):
|
39 |
+
for key, values in prompt_dict.items():
|
40 |
+
with gr.Row():
|
41 |
+
gr.Button(key,interactive=False)
|
42 |
+
for value in values:
|
43 |
+
gr.Button(value).click(add_to_prompt, inputs=[inp, gr.Textbox(value,visible=False)], outputs=inp)
|
44 |
+
|
45 |
+
with gr.Row():
|
46 |
+
gen_out = gr.Image(label="Generated Image",type="filepath")
|
47 |
+
with gr.Accordion("Gallery", open=False):
|
48 |
+
gen_gallery = gr.Gallery(label="Generated Images Gallery", type="filepath")
|
49 |
+
|
50 |
+
btn.click(generate_image_replicate, inputs=[inp,style_mode,api_path,aspect_ratio,gen_gallery,model_type,style_strength], outputs=[gen_out,gen_gallery])
|