Spaces:
Sleeping
Sleeping
igashov
commited on
Commit
•
059a987
1
Parent(s):
3c26059
radio
Browse files
app.py
CHANGED
@@ -91,7 +91,7 @@ def show_input(input_file):
|
|
91 |
return output.IFRAME_TEMPLATE.format(html=html)
|
92 |
|
93 |
|
94 |
-
def generate(input_file):
|
95 |
if input_file is None:
|
96 |
return ''
|
97 |
|
@@ -165,6 +165,7 @@ def generate(input_file):
|
|
165 |
molecule=generated_molecule_content,
|
166 |
molecule_fmt='sdf',
|
167 |
)
|
|
|
168 |
return [
|
169 |
output.IFRAME_TEMPLATE.format(html=html),
|
170 |
[inp_sdf, inp_xyz] + out_files,
|
@@ -193,6 +194,13 @@ with demo:
|
|
193 |
output_files = gr.File(file_count='multiple', label='Output Files')
|
194 |
with gr.Column():
|
195 |
visualization = gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
input_file.change(
|
198 |
fn=show_input,
|
@@ -201,39 +209,13 @@ with demo:
|
|
201 |
)
|
202 |
button.click(
|
203 |
fn=generate,
|
204 |
-
inputs=[input_file],
|
205 |
outputs=[visualization, output_files],
|
206 |
)
|
207 |
-
|
208 |
-
# def foo(idx):
|
209 |
-
# print('INPUT:', idx)
|
210 |
-
# input_path = f'examples/example_{idx+1}.sdf'
|
211 |
-
# return [input_path, show_input(input_path)]
|
212 |
-
|
213 |
examples.click(
|
214 |
fn=lambda idx: [f'examples/example_{idx+1}.sdf', show_input(f'examples/example_{idx+1}.sdf')],
|
215 |
inputs=[examples],
|
216 |
outputs=[input_file, visualization]
|
217 |
)
|
218 |
|
219 |
-
# example1.click(
|
220 |
-
# fn=lambda: ['examples/example_1.sdf', show_input('examples/example_1.sdf')],
|
221 |
-
# inputs=[],
|
222 |
-
# outputs=[input_file, visualization],
|
223 |
-
# )
|
224 |
-
# example2.click(
|
225 |
-
# fn=lambda: ['examples/example_2.sdf', show_input('examples/example_2.sdf')],
|
226 |
-
# inputs=[],
|
227 |
-
# outputs=[input_file, visualization],
|
228 |
-
# )
|
229 |
-
|
230 |
-
# examples = gr.Examples(
|
231 |
-
# examples=[['examples/example_1.sdf'], ['examples/example_2.sdf']],
|
232 |
-
# inputs=[input_file],
|
233 |
-
# outputs=[visualization],
|
234 |
-
# fn=show_input,
|
235 |
-
# run_on_click=True,
|
236 |
-
# cache_examples=False,
|
237 |
-
# )
|
238 |
-
|
239 |
demo.launch(server_name=args.ip)
|
|
|
91 |
return output.IFRAME_TEMPLATE.format(html=html)
|
92 |
|
93 |
|
94 |
+
def generate(input_file, samples):
|
95 |
if input_file is None:
|
96 |
return ''
|
97 |
|
|
|
165 |
molecule=generated_molecule_content,
|
166 |
molecule_fmt='sdf',
|
167 |
)
|
168 |
+
samples.update(visible=True)
|
169 |
return [
|
170 |
output.IFRAME_TEMPLATE.format(html=html),
|
171 |
[inp_sdf, inp_xyz] + out_files,
|
|
|
194 |
output_files = gr.File(file_count='multiple', label='Output Files')
|
195 |
with gr.Column():
|
196 |
visualization = gr.HTML()
|
197 |
+
samples = gr.Radio(
|
198 |
+
choices=['Sample 1', 'Sample 2', 'Sample 3', 'Sample 4', 'Sample 5'],
|
199 |
+
value='Sample 1',
|
200 |
+
type='index',
|
201 |
+
show_label=False,
|
202 |
+
visible=False,
|
203 |
+
)
|
204 |
|
205 |
input_file.change(
|
206 |
fn=show_input,
|
|
|
209 |
)
|
210 |
button.click(
|
211 |
fn=generate,
|
212 |
+
inputs=[input_file, samples],
|
213 |
outputs=[visualization, output_files],
|
214 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
examples.click(
|
216 |
fn=lambda idx: [f'examples/example_{idx+1}.sdf', show_input(f'examples/example_{idx+1}.sdf')],
|
217 |
inputs=[examples],
|
218 |
outputs=[input_file, visualization]
|
219 |
)
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
demo.launch(server_name=args.ip)
|