chembfn-webui 0.4.0__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chembfn-webui might be problematic. Click here for more details.
- chembfn_webui/bin/app.py +44 -12
- chembfn_webui/cache/results.csv +0 -1
- chembfn_webui/lib/version.py +1 -1
- {chembfn_webui-0.4.0.dist-info → chembfn_webui-0.6.0.dist-info}/METADATA +9 -2
- {chembfn_webui-0.4.0.dist-info → chembfn_webui-0.6.0.dist-info}/RECORD +9 -9
- {chembfn_webui-0.4.0.dist-info → chembfn_webui-0.6.0.dist-info}/WHEEL +0 -0
- {chembfn_webui-0.4.0.dist-info → chembfn_webui-0.6.0.dist-info}/entry_points.txt +0 -0
- {chembfn_webui-0.4.0.dist-info → chembfn_webui-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {chembfn_webui-0.4.0.dist-info → chembfn_webui-0.6.0.dist-info}/top_level.txt +0 -0
chembfn_webui/bin/app.py
CHANGED
|
@@ -24,7 +24,13 @@ from bayesianflow_for_chem.data import (
|
|
|
24
24
|
aa2vec,
|
|
25
25
|
split_selfies,
|
|
26
26
|
)
|
|
27
|
-
from bayesianflow_for_chem.tool import
|
|
27
|
+
from bayesianflow_for_chem.tool import (
|
|
28
|
+
sample,
|
|
29
|
+
inpaint,
|
|
30
|
+
optimise,
|
|
31
|
+
adjust_lora_,
|
|
32
|
+
quantise_model_,
|
|
33
|
+
)
|
|
28
34
|
from lib.utilities import (
|
|
29
35
|
find_model,
|
|
30
36
|
find_vocab,
|
|
@@ -65,7 +71,7 @@ def selfies2vec(sel: str, vocab_dict: Dict[str, int]) -> List[int]:
|
|
|
65
71
|
if "unknown" in key.lower():
|
|
66
72
|
unknown_id = idx
|
|
67
73
|
break
|
|
68
|
-
return [vocab_dict.get(i,
|
|
74
|
+
return [vocab_dict.get(i, unknown_id) for i in s]
|
|
69
75
|
|
|
70
76
|
|
|
71
77
|
def refresh(
|
|
@@ -176,11 +182,12 @@ def run(
|
|
|
176
182
|
temperature: float,
|
|
177
183
|
prompt: str,
|
|
178
184
|
scaffold: str,
|
|
185
|
+
template: str,
|
|
179
186
|
sar_control: str,
|
|
180
187
|
exclude_token: str,
|
|
181
188
|
quantise: str,
|
|
182
189
|
jited: str,
|
|
183
|
-
) -> Tuple[Union[List, None], List[str], str,
|
|
190
|
+
) -> Tuple[Union[List, None], List[str], str, gr.TextArea, str]:
|
|
184
191
|
"""
|
|
185
192
|
Run generation or inpainting.
|
|
186
193
|
|
|
@@ -195,6 +202,7 @@ def run(
|
|
|
195
202
|
:param temperature: sampling temperature while ODE-solver used
|
|
196
203
|
:param prompt: prompt string
|
|
197
204
|
:param scaffold: molecular scaffold
|
|
205
|
+
:param template: molecular template
|
|
198
206
|
:param sar_control: semi-autoregressive behaviour flags
|
|
199
207
|
:param exclude_token: unwanted tokens
|
|
200
208
|
:param quantise: `"on"` or `"off"`
|
|
@@ -210,6 +218,7 @@ def run(
|
|
|
210
218
|
:type temperature: float
|
|
211
219
|
:type prompt: str
|
|
212
220
|
:type scaffold: str
|
|
221
|
+
:type template: str
|
|
213
222
|
:type sar_control: str
|
|
214
223
|
:type exclude_token: str
|
|
215
224
|
:type quantise: str
|
|
@@ -346,11 +355,14 @@ def run(
|
|
|
346
355
|
if not allowed_tokens:
|
|
347
356
|
allowed_tokens = "all"
|
|
348
357
|
scaffold = scaffold.strip()
|
|
349
|
-
|
|
350
|
-
|
|
358
|
+
template = template.strip()
|
|
359
|
+
if scaffold:
|
|
360
|
+
x = [1] + tokeniser(scaffold)
|
|
361
|
+
x = x + [0 for _ in range(lmax - len(x))]
|
|
362
|
+
x = torch.tensor([x], dtype=torch.long).repeat(batch_size, 1)
|
|
363
|
+
mols = inpaint(
|
|
351
364
|
bfn,
|
|
352
|
-
|
|
353
|
-
lmax,
|
|
365
|
+
x,
|
|
354
366
|
step,
|
|
355
367
|
y,
|
|
356
368
|
guidance_strength,
|
|
@@ -361,11 +373,13 @@ def run(
|
|
|
361
373
|
mols = trans_fn(mols)
|
|
362
374
|
imgs = img_fn(mols)
|
|
363
375
|
chemfigs = chemfig_fn(mols)
|
|
364
|
-
|
|
365
|
-
|
|
376
|
+
if template:
|
|
377
|
+
_message.append(f"Molecular template {template} ignored.")
|
|
378
|
+
elif template:
|
|
379
|
+
x = [1] + tokeniser(scaffold) + [2]
|
|
366
380
|
x = x + [0 for _ in range(lmax - len(x))]
|
|
367
381
|
x = torch.tensor([x], dtype=torch.long).repeat(batch_size, 1)
|
|
368
|
-
mols =
|
|
382
|
+
mols = optimise(
|
|
369
383
|
bfn,
|
|
370
384
|
x,
|
|
371
385
|
step,
|
|
@@ -378,6 +392,21 @@ def run(
|
|
|
378
392
|
mols = trans_fn(mols)
|
|
379
393
|
imgs = img_fn(mols)
|
|
380
394
|
chemfigs = chemfig_fn(mols)
|
|
395
|
+
else:
|
|
396
|
+
mols = sample(
|
|
397
|
+
bfn,
|
|
398
|
+
batch_size,
|
|
399
|
+
lmax,
|
|
400
|
+
step,
|
|
401
|
+
y,
|
|
402
|
+
guidance_strength,
|
|
403
|
+
vocab_keys=vocab_keys,
|
|
404
|
+
method=_method,
|
|
405
|
+
allowed_tokens=allowed_tokens,
|
|
406
|
+
)
|
|
407
|
+
mols = trans_fn(mols)
|
|
408
|
+
imgs = img_fn(mols)
|
|
409
|
+
chemfigs = chemfig_fn(mols)
|
|
381
410
|
n_mol = len(mols)
|
|
382
411
|
with open(cache_dir / "results.csv", "w", encoding="utf-8", newline="") as rf:
|
|
383
412
|
rf.write("\n".join(mols))
|
|
@@ -388,7 +417,8 @@ def run(
|
|
|
388
417
|
imgs,
|
|
389
418
|
mols,
|
|
390
419
|
"\n\n".join(chemfigs),
|
|
391
|
-
"\n".join(_message),
|
|
420
|
+
# "\n".join(_message),
|
|
421
|
+
gr.TextArea("\n".join(_message), label="message", lines=len(_message)),
|
|
392
422
|
str(cache_dir / "results.csv"),
|
|
393
423
|
)
|
|
394
424
|
|
|
@@ -437,8 +467,9 @@ with gr.Blocks(title="ChemBFN WebUI") as app:
|
|
|
437
467
|
label="prompt", lines=12, html_attributes=HTML_STYLE
|
|
438
468
|
)
|
|
439
469
|
scaffold = gr.Textbox(label="scaffold", html_attributes=HTML_STYLE)
|
|
470
|
+
template = gr.Textbox(label="template", html_attributes=HTML_STYLE)
|
|
440
471
|
gr.Markdown("")
|
|
441
|
-
message = gr.TextArea(label="message")
|
|
472
|
+
message = gr.TextArea(label="message", lines=2)
|
|
442
473
|
with gr.Tab(label="result viewer"):
|
|
443
474
|
with gr.Tab(label="result"):
|
|
444
475
|
btn_download = gr.File(label="download", visible=False)
|
|
@@ -527,6 +558,7 @@ with gr.Blocks(title="ChemBFN WebUI") as app:
|
|
|
527
558
|
temperature,
|
|
528
559
|
prompt,
|
|
529
560
|
scaffold,
|
|
561
|
+
template,
|
|
530
562
|
sar_control,
|
|
531
563
|
exclude_token,
|
|
532
564
|
quantise,
|
chembfn_webui/cache/results.csv
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
CCOCC(=O)N1CCC[C@@H](C2CC2)CC1
|
chembfn_webui/lib/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chembfn_webui
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: WebUI for ChemBFN
|
|
5
5
|
Home-page: https://github.com/Augus1999/ChemBFN-WebUI
|
|
6
6
|
Author: Nianze A. Tao
|
|
@@ -20,7 +20,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
20
20
|
Requires-Python: >=3.11
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: bayesianflow_for_chem>=1.
|
|
23
|
+
Requires-Dist: bayesianflow_for_chem>=2.1.0
|
|
24
24
|
Requires-Dist: mol2chemfigPy3>=1.5.11
|
|
25
25
|
Requires-Dist: gradio>=5.32.1
|
|
26
26
|
Requires-Dist: torch>=2.7.0
|
|
@@ -111,6 +111,13 @@ $ set CHEMBFN_WEBUI_MODEL_DIR={YOUR/MODEL/DIR}
|
|
|
111
111
|
$ chembfn
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
V. use an external directory to hold the model files (Notebook, Google Colab)
|
|
115
|
+
```python
|
|
116
|
+
import os
|
|
117
|
+
os.environ["CHEMBFN_WEBUI_MODEL_DIR"] = "{YOUR/MODEL/DIR}"
|
|
118
|
+
!chembfn --public
|
|
119
|
+
```
|
|
120
|
+
|
|
114
121
|
### 4. Write the prompt
|
|
115
122
|
|
|
116
123
|
* Leave prompt blank for unconditional generation.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
chembfn_webui/__init__.py,sha256=AXUdd_PrlfVO56losFUP7A8XrqCDPylwRbTpe_WG3Uc,87
|
|
2
|
-
chembfn_webui/bin/app.py,sha256=
|
|
2
|
+
chembfn_webui/bin/app.py,sha256=_d5J2drmiYJhOKsrGj1hAE1ciBwKTFkB1m_HVIMDm6Q,21284
|
|
3
3
|
chembfn_webui/cache/cache_file_here.txt,sha256=hi60T_q6Cf5WPtXuwe4CqjiWpaUqrczsmGMhKIUL--M,28
|
|
4
|
-
chembfn_webui/cache/results.csv,sha256=
|
|
4
|
+
chembfn_webui/cache/results.csv,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
chembfn_webui/lib/utilities.py,sha256=ALPw-Evjd9DdsU_RQA6Zp2Gc6XnRR7Y_5fZrqG9azWo,7460
|
|
6
|
-
chembfn_webui/lib/version.py,sha256=
|
|
6
|
+
chembfn_webui/lib/version.py,sha256=q5fg1l63m1pIv46TV50BhgAj1ezH83URJCjHcQaF_fQ,138
|
|
7
7
|
chembfn_webui/model/base_model/place_base_model_here.txt,sha256=oa8_ILaAlWpTXICVDi-Y46_OahV7wB6Che6gbiEIh-c,39
|
|
8
8
|
chembfn_webui/model/lora/place_lora_folder_here.txt,sha256=YYOo0Cj278DyRcgVrCLa1f2Q-cqgNeMnelaLiA3Fuic,69
|
|
9
9
|
chembfn_webui/model/standalone_model/place_standalone_model_folder_here.txt,sha256=Dp42UscfI0Zp3SnvRv5vOfWiJZnxdY7rG3jo0kf86VM,80
|
|
10
10
|
chembfn_webui/model/vocab/place_vocabulary_file_here.txt,sha256=fLOINvZP2022oE7RsmfDjgyaw2yMi7glmdu_cTwmo88,28
|
|
11
|
-
chembfn_webui-0.
|
|
12
|
-
chembfn_webui-0.
|
|
13
|
-
chembfn_webui-0.
|
|
14
|
-
chembfn_webui-0.
|
|
15
|
-
chembfn_webui-0.
|
|
16
|
-
chembfn_webui-0.
|
|
11
|
+
chembfn_webui-0.6.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
12
|
+
chembfn_webui-0.6.0.dist-info/METADATA,sha256=euaFBtUCGo5QlWGOfGF9bsj4LiLF2t9lo8ckotlpico,5897
|
|
13
|
+
chembfn_webui-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
chembfn_webui-0.6.0.dist-info/entry_points.txt,sha256=fp8WTPybvwpeYKrUhTi456wwZbmCMJXN1TeFGpR1SlY,55
|
|
15
|
+
chembfn_webui-0.6.0.dist-info/top_level.txt,sha256=VdWt3Z7jhbB0pQO_mkRawnU5s75SBT9BV8fGaAIJTDI,14
|
|
16
|
+
chembfn_webui-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|