update
Browse files- app.py +7 -24
- model_cards/article.md +17 -25
- model_cards/description.md +1 -1
- model_cards/examples.csv +0 -2
app.py
CHANGED
|
@@ -16,26 +16,18 @@ logger = logging.getLogger(__name__)
|
|
| 16 |
logger.addHandler(logging.NullHandler())
|
| 17 |
|
| 18 |
|
| 19 |
-
def run_inference(
|
| 20 |
-
algorithm_version: str,
|
| 21 |
-
prompt_file: str,
|
| 22 |
-
prompt_id: int,
|
| 23 |
-
number_of_samples: int,
|
| 24 |
-
):
|
| 25 |
|
| 26 |
# Read file:
|
| 27 |
with open(prompt_file.name, "rb") as f:
|
| 28 |
prompts = pickle.load(f)
|
| 29 |
|
| 30 |
-
if all(isinstance(x,
|
| 31 |
prompt = prompts[prompt_id]
|
| 32 |
else:
|
| 33 |
prompt = prompts
|
| 34 |
|
| 35 |
-
config = GeoDiffGenerator(
|
| 36 |
-
algorithm_version=algorithm_version,
|
| 37 |
-
prompt=prompt,
|
| 38 |
-
)
|
| 39 |
model = DiffusersGenerationAlgorithm(config)
|
| 40 |
results = list(model.sample(number_of_samples))
|
| 41 |
smiles = [Chem.MolToSmiles(m) for m in results]
|
|
@@ -45,19 +37,13 @@ def run_inference(
|
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
| 47 |
|
| 48 |
-
# Preparation (retrieve all available algorithms)
|
| 49 |
-
all_algos = ApplicationsRegistry.list_available()
|
| 50 |
-
algos = [
|
| 51 |
-
x["algorithm_version"]
|
| 52 |
-
for x in list(
|
| 53 |
-
filter(lambda x: "GeoDiff" in x["algorithm_application"], all_algos)
|
| 54 |
-
)
|
| 55 |
-
]
|
| 56 |
-
|
| 57 |
# Load metadata
|
| 58 |
metadata_root = pathlib.Path(__file__).parent.joinpath("model_cards")
|
| 59 |
|
| 60 |
-
examples = [
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
with open(metadata_root.joinpath("article.md"), "r") as f:
|
| 63 |
article = f.read()
|
|
@@ -68,9 +54,6 @@ if __name__ == "__main__":
|
|
| 68 |
fn=run_inference,
|
| 69 |
title="GeoDiff",
|
| 70 |
inputs=[
|
| 71 |
-
gr.Dropdown(
|
| 72 |
-
algos, label="GeoDiff version", value="fusing/gfn-molecule-gen-drugs"
|
| 73 |
-
),
|
| 74 |
gr.File(file_types=[".pkl"], label="GeoDiff prompt"),
|
| 75 |
gr.Number(value=0, label="Prompt ID", precision=0),
|
| 76 |
gr.Slider(minimum=1, maximum=5, value=2, label="Number of samples", step=1),
|
|
|
|
| 16 |
logger.addHandler(logging.NullHandler())
|
| 17 |
|
| 18 |
|
| 19 |
+
def run_inference(prompt_file: str, prompt_id: int, number_of_samples: int):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Read file:
|
| 22 |
with open(prompt_file.name, "rb") as f:
|
| 23 |
prompts = pickle.load(f)
|
| 24 |
|
| 25 |
+
if all(isinstance(x, int) for x in prompts.keys()):
|
| 26 |
prompt = prompts[prompt_id]
|
| 27 |
else:
|
| 28 |
prompt = prompts
|
| 29 |
|
| 30 |
+
config = GeoDiffGenerator(prompt=prompt)
|
|
|
|
|
|
|
|
|
|
| 31 |
model = DiffusersGenerationAlgorithm(config)
|
| 32 |
results = list(model.sample(number_of_samples))
|
| 33 |
smiles = [Chem.MolToSmiles(m) for m in results]
|
|
|
|
| 37 |
|
| 38 |
if __name__ == "__main__":
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Load metadata
|
| 41 |
metadata_root = pathlib.Path(__file__).parent.joinpath("model_cards")
|
| 42 |
|
| 43 |
+
examples = [
|
| 44 |
+
[metadata_root.joinpath("mol_dct.pkl"), 0, 2],
|
| 45 |
+
[metadata_root.joinpath("mol_dct.pkl"), 1, 2],
|
| 46 |
+
]
|
| 47 |
|
| 48 |
with open(metadata_root.joinpath("article.md"), "r") as f:
|
| 49 |
article = f.read()
|
|
|
|
| 54 |
fn=run_inference,
|
| 55 |
title="GeoDiff",
|
| 56 |
inputs=[
|
|
|
|
|
|
|
|
|
|
| 57 |
gr.File(file_types=[".pkl"], label="GeoDiff prompt"),
|
| 58 |
gr.Number(value=0, label="Prompt ID", precision=0),
|
| 59 |
gr.Slider(minimum=1, maximum=5, value=2, label="Number of samples", step=1),
|
model_cards/article.md
CHANGED
|
@@ -1,32 +1,26 @@
|
|
| 1 |
# Model documentation & parameters
|
| 2 |
|
| 3 |
-
**
|
| 4 |
|
| 5 |
-
**Prompt**:
|
| 6 |
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
-
# Model card -- Image diffusion models
|
| 10 |
|
| 11 |
-
|
| 12 |
-
- `LDMTextToImageGenerator`
|
| 13 |
-
- `StableDiffusionGenerator`
|
| 14 |
-
- `DDPMGenerator`
|
| 15 |
-
- `DDPMGenerator`
|
| 16 |
-
- `LDMGenerator`
|
| 17 |
-
- `ScoreSdeGenerator`
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
**Developers**:
|
| 22 |
|
| 23 |
-
**Distributors**:
|
| 24 |
|
| 25 |
**Model date**: 2022.
|
| 26 |
|
| 27 |
-
**Model version**:
|
| 28 |
|
| 29 |
-
**Model type**:
|
| 30 |
|
| 31 |
**Information about training algorithms, parameters, fairness constraints or other applied approaches, and features**:
|
| 32 |
N.A.
|
|
@@ -36,11 +30,11 @@ N.A.
|
|
| 36 |
|
| 37 |
**License**: MIT
|
| 38 |
|
| 39 |
-
**Where to send questions or comments about the model**: Open an issue on [`
|
| 40 |
|
| 41 |
-
**Intended Use. Use cases that were envisioned during development**:
|
| 42 |
|
| 43 |
-
**Primary intended uses/users**:
|
| 44 |
|
| 45 |
**Out-of-scope use cases**: Production-level inference, producing molecules with harmful properties.
|
| 46 |
|
|
@@ -56,12 +50,10 @@ Model card prototype inspired by [Mitchell et al. (2019)](https://dl.acm.org/doi
|
|
| 56 |
|
| 57 |
## Citation
|
| 58 |
```bib
|
| 59 |
-
@
|
| 60 |
-
author
|
| 61 |
-
title
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
journal = {GitHub repository},
|
| 65 |
-
howpublished = {\url{https://github.com/huggingface/diffusers}}
|
| 66 |
}
|
| 67 |
```
|
|
|
|
| 1 |
# Model documentation & parameters
|
| 2 |
|
| 3 |
+
**GeoDiff prompt**: Here you can upload a `.pkl` file with the necessary variables to initialize a `GeoDiff` generation. Our example file contains five example configurations. NOTE: For details on how to create such files for your custom data, see [original paper](https://openreview.net/forum?id=PzcvxEMzvQC) and this [Colab](https://colab.research.google.com/drive/1pLYYWQhdLuv1q-JtEHGZybxp2RBF8gPs#scrollTo=-3-P4w5sXkRU)
|
| 4 |
|
| 5 |
+
**Prompt ID**: Which of the five example configurations to be used. If you use your own file and have the files in a flat dictionary, leave this blank. If your own file should contain multiple examples, create a top-level dictionary with keys as ascending integers and values as example dictionaries.
|
| 6 |
|
| 7 |
+
**Number of samples**: How many samples should be generated (between 1 and 50).
|
| 8 |
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
+
# Model card -- GeoDiff
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
**Model Details**: [GeoDiff](https://openreview.net/forum?id=PzcvxEMzvQC): A Geometric Diffusion Model for Molecular Conformation Generation
|
| 14 |
|
| 15 |
+
**Developers**: Minkai Xu and colleagues from MILA and Stanford University.
|
| 16 |
|
| 17 |
+
**Distributors**: GT4SD Developers.
|
| 18 |
|
| 19 |
**Model date**: 2022.
|
| 20 |
|
| 21 |
+
**Model version**: Checkpoints provided by original authors ([see their GitHub repo](https://github.com/MinkaiXu/GeoDiff)).
|
| 22 |
|
| 23 |
+
**Model type**: A Geometric Diffusion Model for Molecular Conformation Generation
|
| 24 |
|
| 25 |
**Information about training algorithms, parameters, fairness constraints or other applied approaches, and features**:
|
| 26 |
N.A.
|
|
|
|
| 30 |
|
| 31 |
**License**: MIT
|
| 32 |
|
| 33 |
+
**Where to send questions or comments about the model**: Open an issue on [`GeoDiff`](https://github.com/MinkaiXu/GeoDiff) repo.
|
| 34 |
|
| 35 |
+
**Intended Use. Use cases that were envisioned during development**: Chemical research, in particular drug discovery.
|
| 36 |
|
| 37 |
+
**Primary intended uses/users**: Researchers and computational chemists using the model for model comparison or research exploration purposes.
|
| 38 |
|
| 39 |
**Out-of-scope use cases**: Production-level inference, producing molecules with harmful properties.
|
| 40 |
|
|
|
|
| 50 |
|
| 51 |
## Citation
|
| 52 |
```bib
|
| 53 |
+
@inproceedings{xu2022geodiff,
|
| 54 |
+
author = {Minkai Xu and Lantao Yu and Yang Song and Chence Shi and Stefano Ermon and Jian Tang},
|
| 55 |
+
title = {GeoDiff: {A} Geometric Diffusion Model for Molecular Conformation Generation},
|
| 56 |
+
booktitle = {The Tenth International Conference on Learning Representations, {ICLR}},
|
| 57 |
+
year = {2022},
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
```
|
model_cards/description.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<img align="right" src="https://raw.githubusercontent.com/GT4SD/gt4sd-core/main/docs/_static/gt4sd_logo.png" alt="logo" width="120" >
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
For **examples** and **documentation** of the model parameters, please see below.
|
| 6 |
Moreover, we provide a **model card** ([Mitchell et al. (2019)](https://dl.acm.org/doi/abs/10.1145/3287560.3287596?casa_token=XD4eHiE2cRUAAAAA:NL11gMa1hGPOUKTAbtXnbVQBDBbjxwcjGECF_i-WC_3g1aBgU1Hbz_f2b4kI_m1in-w__1ztGeHnwHs)) at the bottom of this page.
|
|
|
|
| 1 |
<img align="right" src="https://raw.githubusercontent.com/GT4SD/gt4sd-core/main/docs/_static/gt4sd_logo.png" alt="logo" width="120" >
|
| 2 |
|
| 3 |
+
[**GeoDiff** (*ICLR* 2022)](https://openreview.net/forum?id=PzcvxEMzvQC) is a diffusion-based molecular generative model implemented in and distributed natively by GT4SD.
|
| 4 |
|
| 5 |
For **examples** and **documentation** of the model parameters, please see below.
|
| 6 |
Moreover, we provide a **model card** ([Mitchell et al. (2019)](https://dl.acm.org/doi/abs/10.1145/3287560.3287596?casa_token=XD4eHiE2cRUAAAAA:NL11gMa1hGPOUKTAbtXnbVQBDBbjxwcjGECF_i-WC_3g1aBgU1Hbz_f2b4kI_m1in-w__1ztGeHnwHs)) at the bottom of this page.
|
model_cards/examples.csv
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
LDMGenerator,
|
| 2 |
-
LDMTextToImageGenerator,Generative models on the moon
|
|
|
|
|
|
|
|
|