chembfn-webui 0.6.0__py3-none-any.whl → 1.1.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 +25 -14
- chembfn_webui/lib/version.py +1 -1
- {chembfn_webui-0.6.0.dist-info → chembfn_webui-1.1.0.dist-info}/METADATA +17 -2
- {chembfn_webui-0.6.0.dist-info → chembfn_webui-1.1.0.dist-info}/RECORD +8 -8
- {chembfn_webui-0.6.0.dist-info → chembfn_webui-1.1.0.dist-info}/WHEEL +0 -0
- {chembfn_webui-0.6.0.dist-info → chembfn_webui-1.1.0.dist-info}/entry_points.txt +0 -0
- {chembfn_webui-0.6.0.dist-info → chembfn_webui-1.1.0.dist-info}/licenses/LICENSE +0 -0
- {chembfn_webui-0.6.0.dist-info → chembfn_webui-1.1.0.dist-info}/top_level.txt +0 -0
chembfn_webui/bin/app.py
CHANGED
|
@@ -10,7 +10,7 @@ from functools import partial
|
|
|
10
10
|
from typing import Tuple, List, Dict, Union
|
|
11
11
|
|
|
12
12
|
sys.path.append(str(Path(__file__).parent.parent))
|
|
13
|
-
from rdkit.Chem import Draw, MolFromSmiles
|
|
13
|
+
from rdkit.Chem import Draw, MolFromSmiles # type: ignore
|
|
14
14
|
from mol2chemfigPy3 import mol2chemfig
|
|
15
15
|
import gradio as gr
|
|
16
16
|
import torch
|
|
@@ -18,10 +18,10 @@ from selfies import decoder
|
|
|
18
18
|
from bayesianflow_for_chem import ChemBFN, MLP, EnsembleChemBFN
|
|
19
19
|
from bayesianflow_for_chem.data import (
|
|
20
20
|
VOCAB_KEYS,
|
|
21
|
-
|
|
21
|
+
FASTA_VOCAB_KEYS,
|
|
22
22
|
load_vocab,
|
|
23
23
|
smiles2vec,
|
|
24
|
-
|
|
24
|
+
fasta2vec,
|
|
25
25
|
split_selfies,
|
|
26
26
|
)
|
|
27
27
|
from bayesianflow_for_chem.tool import (
|
|
@@ -42,7 +42,8 @@ from lib.version import __version__
|
|
|
42
42
|
|
|
43
43
|
vocabs = find_vocab()
|
|
44
44
|
models = find_model()
|
|
45
|
-
|
|
45
|
+
_lora_selected = False # lora select flag
|
|
46
|
+
_run_in_public = False # public flag
|
|
46
47
|
cache_dir = Path(__file__).parent.parent / "cache"
|
|
47
48
|
|
|
48
49
|
HTML_STYLE = gr.InputHTMLAttributes(
|
|
@@ -130,12 +131,12 @@ def select_lora(evt: gr.SelectData, prompt: str) -> str:
|
|
|
130
131
|
:return: new prompt string
|
|
131
132
|
:rtype: str
|
|
132
133
|
"""
|
|
133
|
-
global
|
|
134
|
-
if
|
|
135
|
-
|
|
134
|
+
global _lora_selected
|
|
135
|
+
if _lora_selected and not _run_in_public: # avoid double select
|
|
136
|
+
_lora_selected = False
|
|
136
137
|
return prompt
|
|
137
138
|
selected_lora = evt.value
|
|
138
|
-
|
|
139
|
+
_lora_selected = True
|
|
139
140
|
if evt.index[1] != 0:
|
|
140
141
|
return prompt
|
|
141
142
|
if not prompt:
|
|
@@ -246,8 +247,8 @@ def run(
|
|
|
246
247
|
img_fn = lambda x: [Draw.MolToImage(MolFromSmiles(i), (500, 500)) for i in x]
|
|
247
248
|
chemfig_fn = lambda x: [mol2chemfig(i, "-r", inline=True) for i in x]
|
|
248
249
|
if token_name == "FASTA":
|
|
249
|
-
vocab_keys =
|
|
250
|
-
tokeniser =
|
|
250
|
+
vocab_keys = FASTA_VOCAB_KEYS
|
|
251
|
+
tokeniser = fasta2vec
|
|
251
252
|
trans_fn = lambda x: x
|
|
252
253
|
img_fn = lambda _: None # senseless to provide dumb 2D images
|
|
253
254
|
chemfig_fn = lambda _: [""] # senseless to provide very long Chemfig code
|
|
@@ -344,7 +345,11 @@ def run(
|
|
|
344
345
|
if len(sar_flag) == 1:
|
|
345
346
|
sar_flag = [sar_flag[0] for _ in range(len(weights))]
|
|
346
347
|
bfn = EnsembleChemBFN(base_model_dir, lora_dir, mlps, weights)
|
|
347
|
-
y =
|
|
348
|
+
y = (
|
|
349
|
+
[torch.tensor([i], dtype=torch.float32) for i in prompt_info["objective"]]
|
|
350
|
+
if prompt_info["objective"]
|
|
351
|
+
else None
|
|
352
|
+
)
|
|
348
353
|
if quantise == "on":
|
|
349
354
|
bfn.quantise()
|
|
350
355
|
if jited == "on":
|
|
@@ -417,7 +422,6 @@ def run(
|
|
|
417
422
|
imgs,
|
|
418
423
|
mols,
|
|
419
424
|
"\n\n".join(chemfigs),
|
|
420
|
-
# "\n".join(_message),
|
|
421
425
|
gr.TextArea("\n".join(_message), label="message", lines=len(_message)),
|
|
422
426
|
str(cache_dir / "results.csv"),
|
|
423
427
|
)
|
|
@@ -610,12 +614,19 @@ def main() -> None:
|
|
|
610
614
|
:return:
|
|
611
615
|
:rtype: None
|
|
612
616
|
"""
|
|
613
|
-
parser = argparse.ArgumentParser(
|
|
617
|
+
parser = argparse.ArgumentParser(
|
|
618
|
+
description="A web-based visualisation tool for ChemBFN method.",
|
|
619
|
+
epilog=f"ChemBFN WebUI {__version__}, developed in Hiroshima University by chemists for chemists. "
|
|
620
|
+
"Visit https://augus1999.github.io/bayesian-flow-network-for-chemistry/ for more details.",
|
|
621
|
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
622
|
+
)
|
|
614
623
|
parser.add_argument(
|
|
615
|
-
"--public", default=False, help="open to public", action="store_true"
|
|
624
|
+
"-P", "--public", default=False, help="open to public", action="store_true"
|
|
616
625
|
)
|
|
617
626
|
parser.add_argument("-V", "--version", action="version", version=__version__)
|
|
618
627
|
args = parser.parse_args()
|
|
628
|
+
global _run_in_public
|
|
629
|
+
_run_in_public = args.public
|
|
619
630
|
app.launch(share=args.public, allowed_paths=[cache_dir.absolute().__str__()])
|
|
620
631
|
|
|
621
632
|
|
chembfn_webui/lib/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chembfn_webui
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.1.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>=2.
|
|
23
|
+
Requires-Dist: bayesianflow_for_chem>=2.2.2
|
|
24
24
|
Requires-Dist: mol2chemfigPy3>=1.5.11
|
|
25
25
|
Requires-Dist: gradio>=5.32.1
|
|
26
26
|
Requires-Dist: torch>=2.7.0
|
|
@@ -83,6 +83,21 @@ For example,
|
|
|
83
83
|
└───moses_selfies_vocab.txt
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
> Note:
|
|
87
|
+
>
|
|
88
|
+
> >The file `config.json` is automatically saved by CLI tool `Madmol` provided in `bayesianflow-for-chem` package. If you train models via Python API, you need to manually create that file for your models by filling in the tempate:
|
|
89
|
+
> >```json
|
|
90
|
+
> >{
|
|
91
|
+
> > "padding_index": 0,
|
|
92
|
+
> > "start_index": 1,
|
|
93
|
+
> > "end_index": 2,
|
|
94
|
+
> > "padding_strategy": "static",
|
|
95
|
+
> > "padding_length": PADDING_LENGTH,
|
|
96
|
+
> > "label": [LABEL_NAME_I, LABEL_NAME_II, ...],
|
|
97
|
+
> > "name": JOB_NAME
|
|
98
|
+
> >}
|
|
99
|
+
> >```
|
|
100
|
+
|
|
86
101
|
If placed correctly, all these files can be seen in the "model explorer" tab.
|
|
87
102
|
|
|
88
103
|
> You can use an external folder to host the models if it follows the same structure as [`chembfn_webui/model`](https://github.com/Augus1999/ChemBFN-WebUI/tree/main/chembfn_webui/model). See the next section for the method.
|
|
@@ -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=Oguy3G8jaIuNT7RZWgtGweMKzCLipagMGH7E7y7C27A,21849
|
|
3
3
|
chembfn_webui/cache/cache_file_here.txt,sha256=hi60T_q6Cf5WPtXuwe4CqjiWpaUqrczsmGMhKIUL--M,28
|
|
4
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=9gQIR8VWU0vhANDgg8w-friQemzdDuGMpih04LtIwCY,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-
|
|
12
|
-
chembfn_webui-
|
|
13
|
-
chembfn_webui-
|
|
14
|
-
chembfn_webui-
|
|
15
|
-
chembfn_webui-
|
|
16
|
-
chembfn_webui-
|
|
11
|
+
chembfn_webui-1.1.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
12
|
+
chembfn_webui-1.1.0.dist-info/METADATA,sha256=zLnFwjbkQsvqAm2fg5f17A7N-4X2sIFvJ4n4tcr2Sa0,6412
|
|
13
|
+
chembfn_webui-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
chembfn_webui-1.1.0.dist-info/entry_points.txt,sha256=fp8WTPybvwpeYKrUhTi456wwZbmCMJXN1TeFGpR1SlY,55
|
|
15
|
+
chembfn_webui-1.1.0.dist-info/top_level.txt,sha256=VdWt3Z7jhbB0pQO_mkRawnU5s75SBT9BV8fGaAIJTDI,14
|
|
16
|
+
chembfn_webui-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|