Spaces:
Running
Running
Commit
·
4754e4d
1
Parent(s):
63ae026
feat: move doc up
Browse files
app.py
CHANGED
@@ -88,7 +88,7 @@ with gr.Blocks(
|
|
88 |
.button-container {
|
89 |
display: flex !important;
|
90 |
justify-content: center !important;
|
91 |
-
width: 600px !important;
|
92 |
}
|
93 |
.optimal-button {
|
94 |
margin-top: 1rem !important;
|
@@ -100,15 +100,39 @@ with gr.Blocks(
|
|
100 |
gr.Markdown(
|
101 |
"""
|
102 |
# Interactive Image Generation
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
"""
|
105 |
)
|
106 |
|
107 |
with gr.Row():
|
108 |
# Left column
|
109 |
-
with gr.Column(scale=
|
110 |
selected_idx = gr.State(value=0)
|
111 |
-
coords = gr.State()
|
112 |
|
113 |
with gr.Column(elem_classes="radio-container"):
|
114 |
task_select = gr.Radio(
|
@@ -140,7 +164,7 @@ with gr.Blocks(
|
|
140 |
)
|
141 |
|
142 |
# Right column
|
143 |
-
with gr.Column(scale=
|
144 |
gr.Markdown("### Coordinate Selector")
|
145 |
gr.Markdown("Click anywhere in the image below to select (x, y) coordinates in the latent space")
|
146 |
with gr.Column(elem_classes="coordinate-container"):
|
@@ -157,37 +181,13 @@ with gr.Blocks(
|
|
157 |
with gr.Column(elem_classes="button-container"):
|
158 |
optimal_button = gr.Button("Find Optimal Latent", elem_classes="optimal-button")
|
159 |
|
160 |
-
#
|
161 |
with gr.Column(elem_classes="documentation"):
|
162 |
-
gr.Markdown(
|
163 |
-
"""
|
164 |
-
## Method Documentation
|
165 |
-
|
166 |
-
### How It Works
|
167 |
-
This interactive demo showcases our novel image generation method that uses coordinate-based control. The process works as follows:
|
168 |
-
|
169 |
-
1. **Task Selection**: Choose one of four different pattern generation tasks
|
170 |
-
2. **Reference Pattern**: View the target pattern for the selected task
|
171 |
-
3. **Coordinate Selection**: Click anywhere in the heatmap to specify where in the latent space you want to generate from
|
172 |
-
4. **Generation**: The model generates a new image based on your selected coordinates
|
173 |
-
|
174 |
-
The "Find Optimal Latent" button automatically selects pre-determined optimal coordinates for the current task.
|
175 |
-
"""
|
176 |
-
)
|
177 |
-
|
178 |
-
# Add the diagram as a separate Image component instead of Markdown
|
179 |
-
gr.Image(
|
180 |
-
value="imgs/lpn_diagram.png",
|
181 |
-
show_label=False,
|
182 |
-
interactive=False,
|
183 |
-
show_download_button=False,
|
184 |
-
show_fullscreen_button=False,
|
185 |
-
)
|
186 |
-
|
187 |
gr.Markdown(
|
188 |
"""
|
189 |
### Technical Details
|
190 |
-
Our approach uses a novel coordinate-conditioning mechanism that allows precise control over the generated patterns.
|
|
|
191 |
|
192 |
For more information, please refer to our [paper](https://arxiv.org/pdf/2411.08706) or GitHub [repository](https://github.com/clement-bonnet/lpn).
|
193 |
"""
|
@@ -200,7 +200,6 @@ with gr.Blocks(
|
|
200 |
outputs=[reference_image, selected_idx, coord_selector],
|
201 |
)
|
202 |
|
203 |
-
# Split the coordinate selection into two events with state passing
|
204 |
coord_selector.select(
|
205 |
fn=update_marker,
|
206 |
inputs=[selected_idx],
|
@@ -212,7 +211,6 @@ with gr.Blocks(
|
|
212 |
outputs=output_image,
|
213 |
)
|
214 |
|
215 |
-
# Add event handler for the optimal latent button
|
216 |
optimal_button.click(
|
217 |
fn=find_optimal_latent,
|
218 |
inputs=[selected_idx],
|
|
|
88 |
.button-container {
|
89 |
display: flex !important;
|
90 |
justify-content: center !important;
|
91 |
+
width: 600px !important;
|
92 |
}
|
93 |
.optimal-button {
|
94 |
margin-top: 1rem !important;
|
|
|
100 |
gr.Markdown(
|
101 |
"""
|
102 |
# Interactive Image Generation
|
103 |
+
|
104 |
+
## Method Overview
|
105 |
+
This interactive demo showcases our novel image generation method that uses coordinate-based control.
|
106 |
+
The process allows precise control over generated patterns through a coordinate-conditioning mechanism.
|
107 |
+
"""
|
108 |
+
)
|
109 |
+
|
110 |
+
# Add the diagram at the top
|
111 |
+
gr.Image(
|
112 |
+
value="imgs/lpn_diagram.png",
|
113 |
+
show_label=False,
|
114 |
+
interactive=False,
|
115 |
+
show_download_button=False,
|
116 |
+
show_fullscreen_button=False,
|
117 |
+
)
|
118 |
+
|
119 |
+
gr.Markdown(
|
120 |
+
"""
|
121 |
+
### How to Use
|
122 |
+
1. Choose a pattern generation task using the radio buttons
|
123 |
+
2. View the target pattern for your selected task
|
124 |
+
3. Click anywhere in the heatmap to specify coordinates in the latent space
|
125 |
+
4. See the generated image based on your selection
|
126 |
+
|
127 |
+
Use the "Find Optimal Latent" button to automatically select pre-determined optimal coordinates.
|
128 |
"""
|
129 |
)
|
130 |
|
131 |
with gr.Row():
|
132 |
# Left column
|
133 |
+
with gr.Column(scale=3):
|
134 |
selected_idx = gr.State(value=0)
|
135 |
+
coords = gr.State()
|
136 |
|
137 |
with gr.Column(elem_classes="radio-container"):
|
138 |
task_select = gr.Radio(
|
|
|
164 |
)
|
165 |
|
166 |
# Right column
|
167 |
+
with gr.Column(scale=4):
|
168 |
gr.Markdown("### Coordinate Selector")
|
169 |
gr.Markdown("Click anywhere in the image below to select (x, y) coordinates in the latent space")
|
170 |
with gr.Column(elem_classes="coordinate-container"):
|
|
|
181 |
with gr.Column(elem_classes="button-container"):
|
182 |
optimal_button = gr.Button("Find Optimal Latent", elem_classes="optimal-button")
|
183 |
|
184 |
+
# Footer with additional information
|
185 |
with gr.Column(elem_classes="documentation"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
gr.Markdown(
|
187 |
"""
|
188 |
### Technical Details
|
189 |
+
Our approach uses a novel coordinate-conditioning mechanism that allows precise control over the generated patterns.
|
190 |
+
The heatmap visualization shows the distribution of pattern characteristics across the latent space.
|
191 |
|
192 |
For more information, please refer to our [paper](https://arxiv.org/pdf/2411.08706) or GitHub [repository](https://github.com/clement-bonnet/lpn).
|
193 |
"""
|
|
|
200 |
outputs=[reference_image, selected_idx, coord_selector],
|
201 |
)
|
202 |
|
|
|
203 |
coord_selector.select(
|
204 |
fn=update_marker,
|
205 |
inputs=[selected_idx],
|
|
|
211 |
outputs=output_image,
|
212 |
)
|
213 |
|
|
|
214 |
optimal_button.click(
|
215 |
fn=find_optimal_latent,
|
216 |
inputs=[selected_idx],
|