Update app.py
Browse files
app.py
CHANGED
@@ -18,8 +18,16 @@ else:
|
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 1024
|
20 |
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
if randomize_seed:
|
25 |
seed = random.randint(0, MAX_SEED)
|
@@ -38,12 +46,6 @@ def infer(prompt_part1, prompt_part2, prompt_part3, prompt_part4, prompt_part5,
|
|
38 |
|
39 |
return image
|
40 |
|
41 |
-
examples = [
|
42 |
-
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
43 |
-
"An astronaut riding a green horse",
|
44 |
-
"A delicious ceviche cheesecake slice",
|
45 |
-
]
|
46 |
-
|
47 |
css="""
|
48 |
#col-container {
|
49 |
margin: 0 auto;
|
@@ -73,26 +75,23 @@ with gr.Blocks(css=css) as demo:
|
|
73 |
placeholder="Enter prompt part 1",
|
74 |
container=False,
|
75 |
value="a single",
|
|
|
76 |
)
|
77 |
|
78 |
-
|
79 |
-
label="
|
80 |
-
|
81 |
-
|
82 |
-
placeholder="Enter prompt part 2 (e.g., color category)",
|
83 |
-
container=False,
|
84 |
)
|
85 |
|
86 |
-
|
87 |
-
label="
|
88 |
-
|
89 |
-
|
90 |
-
placeholder="Enter prompt part 3 (e.g., t-shirt, sweatshirt, shirt, hoodie)",
|
91 |
-
container=False,
|
92 |
)
|
93 |
|
94 |
-
|
95 |
-
label="Prompt
|
96 |
show_label=False,
|
97 |
max_lines=1,
|
98 |
placeholder="Enter design prompt",
|
@@ -106,6 +105,7 @@ with gr.Blocks(css=css) as demo:
|
|
106 |
placeholder="Enter prompt part 5",
|
107 |
container=False,
|
108 |
value="hanging on the plain grey wall",
|
|
|
109 |
)
|
110 |
|
111 |
run_button = gr.Button("Run", scale=0)
|
@@ -156,25 +156,20 @@ with gr.Blocks(css=css) as demo:
|
|
156 |
minimum=0.0,
|
157 |
maximum=10.0,
|
158 |
step=0.1,
|
159 |
-
value=
|
160 |
)
|
161 |
|
162 |
num_inference_steps = gr.Slider(
|
163 |
label="Number of inference steps",
|
164 |
minimum=1,
|
165 |
-
maximum=
|
166 |
step=1,
|
167 |
-
value=
|
168 |
)
|
169 |
-
|
170 |
-
gr.Examples(
|
171 |
-
examples = examples,
|
172 |
-
inputs = [prompt_part1]
|
173 |
-
)
|
174 |
|
175 |
run_button.click(
|
176 |
fn = infer,
|
177 |
-
inputs = [prompt_part1,
|
178 |
outputs = [result]
|
179 |
)
|
180 |
|
|
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 1024
|
20 |
|
21 |
+
color_options = [
|
22 |
+
"Red", "Blue", "Green", "Yellow", "Black", "White", "Purple", "Orange", "Pink", "Brown", "Mixed"
|
23 |
+
]
|
24 |
+
|
25 |
+
shirt_type_options = [
|
26 |
+
"T-shirt", "Sweatshirt", "Shirt", "Hoodie"
|
27 |
+
]
|
28 |
+
|
29 |
+
def infer(prompt_part1, color, shirt_type, design_prompt, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
30 |
+
prompt = f"{prompt_part1} {color} {shirt_type} {design_prompt} {prompt_part5}"
|
31 |
|
32 |
if randomize_seed:
|
33 |
seed = random.randint(0, MAX_SEED)
|
|
|
46 |
|
47 |
return image
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
css="""
|
50 |
#col-container {
|
51 |
margin: 0 auto;
|
|
|
75 |
placeholder="Enter prompt part 1",
|
76 |
container=False,
|
77 |
value="a single",
|
78 |
+
visible=False,
|
79 |
)
|
80 |
|
81 |
+
color = gr.Dropdown(
|
82 |
+
label="Color",
|
83 |
+
choices=color_options,
|
84 |
+
value="Red"
|
|
|
|
|
85 |
)
|
86 |
|
87 |
+
shirt_type = gr.Dropdown(
|
88 |
+
label="Shirt Type",
|
89 |
+
choices=shirt_type_options,
|
90 |
+
value="T-shirt"
|
|
|
|
|
91 |
)
|
92 |
|
93 |
+
design_prompt = gr.Text(
|
94 |
+
label="Design Prompt",
|
95 |
show_label=False,
|
96 |
max_lines=1,
|
97 |
placeholder="Enter design prompt",
|
|
|
105 |
placeholder="Enter prompt part 5",
|
106 |
container=False,
|
107 |
value="hanging on the plain grey wall",
|
108 |
+
visible=False,
|
109 |
)
|
110 |
|
111 |
run_button = gr.Button("Run", scale=0)
|
|
|
156 |
minimum=0.0,
|
157 |
maximum=10.0,
|
158 |
step=0.1,
|
159 |
+
value=7.5,
|
160 |
)
|
161 |
|
162 |
num_inference_steps = gr.Slider(
|
163 |
label="Number of inference steps",
|
164 |
minimum=1,
|
165 |
+
maximum=50,
|
166 |
step=1,
|
167 |
+
value=25,
|
168 |
)
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
run_button.click(
|
171 |
fn = infer,
|
172 |
+
inputs = [prompt_part1, color, shirt_type, design_prompt, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
173 |
outputs = [result]
|
174 |
)
|
175 |
|