linoyts HF Staff commited on
Commit
1b77cc9
·
verified ·
1 Parent(s): 997104a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -56
app.py CHANGED
@@ -89,68 +89,79 @@ css = """
89
  """
90
 
91
  with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
92
- with gr.Column(elem_id="col-container"):
93
- gr.Markdown("## FIBO")
94
 
95
- with gr.Row():
96
- with gr.Tab("generate") as tab_generate:
97
- with gr.Row():
98
- prompt_generate = gr.Textbox(label="Prompt", placeholder="a man holding a goose screaming")
 
 
 
 
 
 
99
 
100
- with gr.Tab("refine") as tab_refine:
101
- with gr.Row():
102
- prompt_refine = gr.Textbox(label="Prompt", info="describe the change you want to make", placeholder="make the cat white")
 
 
 
103
 
104
- with gr.Tab("inspire") as tab_inspire:
105
- with gr.Row():
106
  prompt_inspire_image = gr.Image(
107
  label="Inspiration Image",
108
  type="pil",
109
  )
110
-
111
- submit_btn = gr.Button("Generate", variant="primary")
112
- result = gr.Image(label="output")
113
- with gr.Accordion("Structured Prompt", open=False) as structured_accordion:
114
- prompt_in_json = gr.JSON(label="json structured prompt")
115
- with gr.Accordion("Advanced Settings", open=False):
116
- with gr.Row():
117
- seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
118
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
119
- with gr.Row():
120
- guidance_scale = gr.Slider(label="guidance scale", minimum=1.0, maximum=10.0, step=0.1, value=5.0)
121
- num_inference_steps = gr.Slider(
122
- label="number of inference steps", minimum=1, maximum=60, step=1, value=50
123
- )
124
- height = gr.Slider(label="Height", minimum=768, maximum=1248, step=32, value=1024)
125
- width = gr.Slider(label="Width", minimum=832, maximum=1344, step=64, value=1024)
126
- with gr.Row():
127
- negative_prompt = gr.Textbox(label="negative prompt")
128
- negative_prompt_json = gr.JSON(label="json negative prompt")
129
-
130
- # Track active tab
131
- current_mode = gr.State("generate")
132
-
133
- tab_generate.select(lambda: "generate", outputs=current_mode)
134
- tab_refine.select(lambda: "refine", outputs=current_mode)
135
- tab_inspire.select(lambda: "inspire", outputs=current_mode)
136
-
137
- submit_btn.click(
138
- fn=infer,
139
- inputs=[
140
- prompt_generate,
141
- prompt_refine,
142
- prompt_inspire_image,
143
- prompt_in_json,
144
- negative_prompt,
145
- seed,
146
- randomize_seed,
147
- width,
148
- height,
149
- guidance_scale,
150
- num_inference_steps,
151
- current_mode,
152
- ],
153
- outputs=[result, seed, prompt_in_json, negative_prompt_json, structured_accordion],
154
- )
 
 
 
155
 
156
  demo.queue().launch()
 
 
89
  """
90
 
91
  with gr.Blocks(css=css, theme=gr.themes.Soft(primary_hue="violet")) as demo:
92
+ gr.Markdown("## FIBO")
 
93
 
94
+ # Two-column layout
95
+ with gr.Row(elem_id="col-container"):
96
+ # ==== LEFT COLUMN ====
97
+ with gr.Column():
98
+ with gr.Row():
99
+ with gr.Tab("generate") as tab_generate:
100
+ prompt_generate = gr.Textbox(
101
+ label="Prompt",
102
+ placeholder="a man holding a goose screaming"
103
+ )
104
 
105
+ with gr.Tab("refine") as tab_refine:
106
+ prompt_refine = gr.Textbox(
107
+ label="Prompt",
108
+ info="describe the change you want to make",
109
+ placeholder="make the cat white"
110
+ )
111
 
112
+ with gr.Tab("inspire") as tab_inspire:
 
113
  prompt_inspire_image = gr.Image(
114
  label="Inspiration Image",
115
  type="pil",
116
  )
117
+
118
+ submit_btn = gr.Button("Generate", variant="primary")
119
+
120
+ with gr.Accordion("Advanced Settings", open=False):
121
+ with gr.Row():
122
+ seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
123
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
124
+ with gr.Row():
125
+ guidance_scale = gr.Slider(label="guidance scale", minimum=1.0, maximum=10.0, step=0.1, value=5.0)
126
+ num_inference_steps = gr.Slider(
127
+ label="number of inference steps", minimum=1, maximum=60, step=1, value=50
128
+ )
129
+ height = gr.Slider(label="Height", minimum=768, maximum=1248, step=32, value=1024)
130
+ width = gr.Slider(label="Width", minimum=832, maximum=1344, step=64, value=1024)
131
+ with gr.Row():
132
+ negative_prompt = gr.Textbox(label="negative prompt")
133
+ negative_prompt_json = gr.JSON(label="json negative prompt")
134
+
135
+ # ==== RIGHT COLUMN ====
136
+ with gr.Column():
137
+ result = gr.Image(label="output")
138
+ with gr.Accordion("Structured Prompt", open=False) as structured_accordion:
139
+ prompt_in_json = gr.JSON(label="json structured prompt")
140
+
141
+ # Track active tab
142
+ current_mode = gr.State("generate")
143
+ tab_generate.select(lambda: "generate", outputs=current_mode)
144
+ tab_refine.select(lambda: "refine", outputs=current_mode)
145
+ tab_inspire.select(lambda: "inspire", outputs=current_mode)
146
+
147
+ submit_btn.click(
148
+ fn=infer,
149
+ inputs=[
150
+ prompt_generate,
151
+ prompt_refine,
152
+ prompt_inspire_image,
153
+ prompt_in_json,
154
+ negative_prompt,
155
+ seed,
156
+ randomize_seed,
157
+ width,
158
+ height,
159
+ guidance_scale,
160
+ num_inference_steps,
161
+ current_mode,
162
+ ],
163
+ outputs=[result, seed, prompt_in_json, negative_prompt_json, structured_accordion],
164
+ )
165
 
166
  demo.queue().launch()
167
+