Skip to main content

WebUI for ChemBFN

Project description

Web-based UI visualisation tool for ChemBFN method

PyPI black Stand With Ukraine CI

Important:

For the security concerning, it is not recommended to use this application as a public service. When deploying on a local host as a shared application, it is better to install this application in a container or VM, to prevent this application from accessing the Internet, and to limit the premissions of read, create, and delete loacal files and directories.

1. Install

$ pip install -U chembfn_webui

2. Place model files

For example,

├───chembfn_webui
    ├───bin
    ├───cache
    ├───lib
    └───model
        ├───base_model
        |   └───zinc15_190m.pt
        ├───lora
        │   └───csd_ees
        │       ├───lora.pt
        |       ├───mlp.pt
        |       └───config.json
        ├───standalone_model
        │   ├───guacamol
        │   |   ├───model.pt
        │   |   └───config.json
        │   └───qm9
        |        ├───model.pt
        |        ├───mlp.pt
        |        └───config.json
        └───vocab
            └───moses_selfies_vocab.txt

Note:

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:

{
   "padding_index": 0,
   "start_index": 1,
   "end_index": 2,
   "padding_strategy": "static",
   "padding_length": PADDING_LENGTH,
   "label": [LABEL_NAME_I, LABEL_NAME_II, ...],
   "name": JOB_NAME
}

The configureation file for base models can be downloaded here.

If placed correctly, all these files can be seen in the "model explorer" tab.

You can use an external folder to host the models if it follows the same structure as chembfn_webui/model. See the next section for the method.

3. Launch the program

I. launch the web-UI

$ chembfn

II. launch the web in a public link

$ chembfn --public

III. use an external directory to hold the model files (Linux and MacOS)

$ CHEMBFN_WEBUI_MODEL_DIR={YOUR/MODEL/DIR} chembfn

IV. use an external directory to hold the model files (Windows)

# if you use CMD
> set CHEMBFN_WEBUI_MODEL_DIR={YOUR/MODEL/DIR} & chembfn

# if you use PowerShell
> $env:CHEMBFN_WEBUI_MODEL_DIR="{YOUR/MODEL/DIR}" & chembfn

V. use an external directory to hold the model files (Notebook, Google Colab)

import os
os.environ["CHEMBFN_WEBUI_MODEL_DIR"] = "{YOUR/MODEL/DIR}"
!chembfn --public

VI. create an empty folder to hold the model files

$ chembfn --create_model_dir {YOUR/MODEL/DIR}

A structured folder YOUR/MODEL/DIR/model will be created.

4. Write the prompt

  • Leave prompt blank for unconditional generation.
  • For standalone models, key in objective values in the format of [a,b,c,...] to pass the values to the model.
  • Key in <name:A> or <name:A>:[a,b,c,...] to select LoRA parameter and pass the objective values if necessary, where name is the LoRA model name and A is the LoRA scaling. You can easily select a LoRA model by clicking the model name in "LoRA models" tab as well.
  • You can stack several LoRA models together to form an ensemble model by prompt like <name1:A1>:[a1,b1,c1,...];<name2:A2>:[a2,b2,...];.... Note that here A1, A2, etc are contributions of each model to the ensemble.

5. Advanced control

Under "advanced control" tab

  • You can control semi-autoregressive behaviours by key in F for switching off SAR, T for switching on SAR, and prompt like F,F,T,... to individually control the SAR in an ensemble model.
  • You can add unwanted tokens, e.g., [Cu],p,[Si].
  • You can customise the result preprocessing function, e.g., the model output a reaction SMILES "CCI.C[O-]>>COCC" which couldn't be recognised by RDKit; you can pass lambda x: x.split(">>")[-1] to force the program only looking at the products.

6. Generate molecules

Click "RUN" then here you go! If error occured, please check your prompts and settings.

Where to obtain the models?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chembfn_webui-2.2.1.tar.gz (76.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chembfn_webui-2.2.1-py3-none-any.whl (71.1 kB view details)

Uploaded Python 3

File details

Details for the file chembfn_webui-2.2.1.tar.gz.

File metadata

  • Download URL: chembfn_webui-2.2.1.tar.gz
  • Upload date:
  • Size: 76.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for chembfn_webui-2.2.1.tar.gz
Algorithm Hash digest
SHA256 eb51b73d6fe90d3ce76176bd270fbab808b6e64e39bcbc41708c50bf5427341b
MD5 5bf2af9072838ddcd97214a595b3c280
BLAKE2b-256 10fc53c41bb46c4585bcd2c71bd77e20887a436a76dcc4c082fd26f8a0201514

See more details on using hashes here.

File details

Details for the file chembfn_webui-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: chembfn_webui-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 71.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for chembfn_webui-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 762d99e135faa8283312580b242afec7d579b96dba19b8b9e908da3bf0e1c8f9
MD5 89ef329e176d3de84db8406767c5b828
BLAKE2b-256 055ac54be518d3ce9c9338730e98e49c8720be9ce36ab16a4ecf5e9aa61d4646

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page