gaur3009 commited on
Commit
a187191
1 Parent(s): d7e9f76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -39
app.py CHANGED
@@ -18,16 +18,8 @@ else:
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,6 +38,12 @@ def infer(prompt_part1, color, shirt_type, design_prompt, prompt_part5, negative
46
 
47
  return image
48
 
 
 
 
 
 
 
49
  css="""
50
  #col-container {
51
  margin: 0 auto;
@@ -68,46 +66,36 @@ with gr.Blocks(css=css) as demo:
68
 
69
  with gr.Row():
70
 
71
- prompt_part1 = gr.Text(
72
- label="Prompt Part 1",
 
 
 
73
  show_label=False,
74
  max_lines=1,
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",
98
  container=False,
99
  )
100
 
101
- prompt_part5 = gr.Text(
102
- label="Prompt Part 5",
103
  show_label=False,
104
  max_lines=1,
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)
112
 
113
  result = gr.Image(label="Result", show_label=False)
@@ -156,20 +144,25 @@ with gr.Blocks(css=css) as demo:
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
 
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
  MAX_IMAGE_SIZE = 1024
20
 
21
+ def infer(prompt_part1, prompt_part2, prompt_part3, prompt_part4, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
22
+ prompt = f"{prompt_part1} {prompt_part2} {prompt_part3} {prompt_part4} {prompt_part5}"
 
 
 
 
 
 
 
 
23
 
24
  if randomize_seed:
25
  seed = random.randint(0, MAX_SEED)
 
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;
 
66
 
67
  with gr.Row():
68
 
69
+ prompt_part1 = "a single"
70
+ gr.Markdown(f"**Prompt Part 1:** {prompt_part1}")
71
+
72
+ prompt_part2 = gr.Text(
73
+ label="Prompt Part 2",
74
  show_label=False,
75
  max_lines=1,
76
+ placeholder="Enter prompt part 2 (e.g., color category)",
77
  container=False,
 
 
78
  )
79
 
80
+ prompt_part3 = gr.Text(
81
+ label="Prompt Part 3",
 
 
 
 
 
 
 
 
 
 
 
 
82
  show_label=False,
83
  max_lines=1,
84
+ placeholder="Enter prompt part 3 (e.g., t-shirt, sweatshirt, shirt, hoodie)",
85
  container=False,
86
  )
87
 
88
+ prompt_part4 = gr.Text(
89
+ label="Prompt Part 4",
90
  show_label=False,
91
  max_lines=1,
92
+ placeholder="Enter design prompt",
93
  container=False,
 
 
94
  )
95
 
96
+ prompt_part5 = "hanging on the plain grey wall"
97
+ gr.Markdown(f"**Prompt Part 5:** {prompt_part5}")
98
+
99
  run_button = gr.Button("Run", scale=0)
100
 
101
  result = gr.Image(label="Result", show_label=False)
 
144
  minimum=0.0,
145
  maximum=10.0,
146
  step=0.1,
147
+ value=0.0,
148
  )
149
 
150
  num_inference_steps = gr.Slider(
151
  label="Number of inference steps",
152
  minimum=1,
153
+ maximum=12,
154
  step=1,
155
+ value=2,
156
  )
157
+
158
+ gr.Examples(
159
+ examples = examples,
160
+ inputs = [prompt_part2]
161
+ )
162
 
163
  run_button.click(
164
  fn = infer,
165
+ inputs = [prompt_part1, prompt_part2, prompt_part3, prompt_part4, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
166
  outputs = [result]
167
  )
168