Spaces:
Running
on
A10G
Running
on
A10G
igashov
commited on
Commit
•
eb031b7
1
Parent(s):
7a7c7ad
samples
Browse files
app.py
CHANGED
@@ -93,11 +93,22 @@ def show_input(input_file):
|
|
93 |
return output.IFRAME_TEMPLATE.format(html=html)
|
94 |
|
95 |
|
96 |
-
def draw_sample(idx,
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
|
103 |
def generate(input_file):
|
@@ -162,17 +173,8 @@ def generate(input_file):
|
|
162 |
out_files.append(out_sdf)
|
163 |
print('Converted to SDF')
|
164 |
|
165 |
-
out_sdf = f'results/output_1_{name}_.sdf'
|
166 |
-
input_fragments_content = read_molecule_content(inp_sdf)
|
167 |
-
generated_molecule_content = read_molecule_content(out_sdf)
|
168 |
-
html = output.SAMPLES_RENDERING_TEMPLATE.format(
|
169 |
-
fragments=input_fragments_content,
|
170 |
-
fragments_fmt='sdf',
|
171 |
-
molecule=generated_molecule_content,
|
172 |
-
molecule_fmt='sdf',
|
173 |
-
)
|
174 |
return [
|
175 |
-
|
176 |
[inp_sdf] + out_files,
|
177 |
gr.Radio.update(visible=True)
|
178 |
]
|
@@ -200,8 +202,7 @@ with demo:
|
|
200 |
output_files = gr.File(file_count='multiple', label='Output Files')
|
201 |
with gr.Column():
|
202 |
gr.Markdown('## Visualization')
|
203 |
-
gr.Markdown('Below you will see input and output molecules')
|
204 |
-
visualization = gr.HTML()
|
205 |
samples = gr.Radio(
|
206 |
choices=['Sample 1', 'Sample 2', 'Sample 3', 'Sample 4', 'Sample 5'],
|
207 |
value='Sample 1',
|
@@ -210,6 +211,7 @@ with demo:
|
|
210 |
visible=False,
|
211 |
interactive=True,
|
212 |
)
|
|
|
213 |
|
214 |
input_file.change(
|
215 |
fn=show_input,
|
@@ -229,7 +231,7 @@ with demo:
|
|
229 |
samples.change(
|
230 |
fn=draw_sample,
|
231 |
inputs=[samples, output_files],
|
232 |
-
outputs=[],
|
233 |
)
|
234 |
|
235 |
demo.launch(server_name=args.ip)
|
|
|
93 |
return output.IFRAME_TEMPLATE.format(html=html)
|
94 |
|
95 |
|
96 |
+
def draw_sample(idx, out_files):
|
97 |
+
in_file = out_files[0]
|
98 |
+
in_sdf = in_file if isinstance(in_file, str) else in_file.name
|
99 |
+
|
100 |
+
out_file = out_files[idx + 1]
|
101 |
+
out_sdf = out_file if isinstance(out_file, str) else out_file.name
|
102 |
+
|
103 |
+
input_fragments_content = read_molecule_content(in_sdf)
|
104 |
+
generated_molecule_content = read_molecule_content(out_sdf)
|
105 |
+
html = output.SAMPLES_RENDERING_TEMPLATE.format(
|
106 |
+
fragments=input_fragments_content,
|
107 |
+
fragments_fmt='sdf',
|
108 |
+
molecule=generated_molecule_content,
|
109 |
+
molecule_fmt='sdf',
|
110 |
+
)
|
111 |
+
return output.IFRAME_TEMPLATE.format(html=html)
|
112 |
|
113 |
|
114 |
def generate(input_file):
|
|
|
173 |
out_files.append(out_sdf)
|
174 |
print('Converted to SDF')
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
return [
|
177 |
+
draw_sample(0, out_files),
|
178 |
[inp_sdf] + out_files,
|
179 |
gr.Radio.update(visible=True)
|
180 |
]
|
|
|
202 |
output_files = gr.File(file_count='multiple', label='Output Files')
|
203 |
with gr.Column():
|
204 |
gr.Markdown('## Visualization')
|
205 |
+
# gr.Markdown('Below you will see input and output molecules')
|
|
|
206 |
samples = gr.Radio(
|
207 |
choices=['Sample 1', 'Sample 2', 'Sample 3', 'Sample 4', 'Sample 5'],
|
208 |
value='Sample 1',
|
|
|
211 |
visible=False,
|
212 |
interactive=True,
|
213 |
)
|
214 |
+
visualization = gr.HTML()
|
215 |
|
216 |
input_file.change(
|
217 |
fn=show_input,
|
|
|
231 |
samples.change(
|
232 |
fn=draw_sample,
|
233 |
inputs=[samples, output_files],
|
234 |
+
outputs=[visualization],
|
235 |
)
|
236 |
|
237 |
demo.launch(server_name=args.ip)
|