update
Browse files- README.md +1 -1
- app.py +25 -31
- model_cards/article.md +27 -20
- model_cards/description.md +1 -1
- model_cards/examples.csv +2 -1
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: GT4SD -
|
| 3 |
emoji: 💡
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
|
|
|
| 1 |
---
|
| 2 |
+
title: GT4SD - Diffusers (image)
|
| 3 |
emoji: 💡
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
app.py
CHANGED
|
@@ -2,30 +2,32 @@ import logging
|
|
| 2 |
import pathlib
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
-
from gt4sd.algorithms.generation.
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
)
|
| 9 |
-
|
| 10 |
from gt4sd.algorithms.registry import ApplicationsRegistry
|
| 11 |
|
| 12 |
-
from utils import draw_grid_generate
|
| 13 |
-
|
| 14 |
logger = logging.getLogger(__name__)
|
| 15 |
logger.addHandler(logging.NullHandler())
|
| 16 |
|
| 17 |
|
| 18 |
-
def run_inference(
|
| 19 |
|
| 20 |
-
config =
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
model =
|
| 26 |
-
|
| 27 |
|
| 28 |
-
return
|
| 29 |
|
| 30 |
|
| 31 |
if __name__ == "__main__":
|
|
@@ -33,11 +35,10 @@ if __name__ == "__main__":
|
|
| 33 |
# Preparation (retrieve all available algorithms)
|
| 34 |
all_algos = ApplicationsRegistry.list_available()
|
| 35 |
algos = [
|
| 36 |
-
x["
|
| 37 |
-
for x in list(
|
| 38 |
-
filter(lambda x: "PolymerBlocks" in x["algorithm_name"], all_algos)
|
| 39 |
-
)
|
| 40 |
]
|
|
|
|
| 41 |
|
| 42 |
# Load metadata
|
| 43 |
metadata_root = pathlib.Path(__file__).parent.joinpath("model_cards")
|
|
@@ -53,21 +54,14 @@ if __name__ == "__main__":
|
|
| 53 |
|
| 54 |
demo = gr.Interface(
|
| 55 |
fn=run_inference,
|
| 56 |
-
title="
|
| 57 |
inputs=[
|
| 58 |
-
gr.Dropdown(
|
| 59 |
-
|
| 60 |
-
minimum=5,
|
| 61 |
-
maximum=400,
|
| 62 |
-
value=100,
|
| 63 |
-
label="Maximal sequence length",
|
| 64 |
-
step=1,
|
| 65 |
-
),
|
| 66 |
-
gr.Slider(
|
| 67 |
-
minimum=1, maximum=50, value=10, label="Number of samples", step=1
|
| 68 |
),
|
|
|
|
| 69 |
],
|
| 70 |
-
outputs=gr.
|
| 71 |
article=article,
|
| 72 |
description=description,
|
| 73 |
examples=examples.values.tolist(),
|
|
|
|
| 2 |
import pathlib
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
+
from gt4sd.algorithms.generation.diffusion import (
|
| 6 |
+
DiffusersGenerationAlgorithm,
|
| 7 |
+
DDPMGenerator,
|
| 8 |
+
DDIMGenerator,
|
| 9 |
+
ScoreSdeGenerator,
|
| 10 |
+
LDMTextToImageGenerator,
|
| 11 |
+
LDMGenerator,
|
| 12 |
+
StableDiffusionGenerator,
|
| 13 |
)
|
|
|
|
| 14 |
from gt4sd.algorithms.registry import ApplicationsRegistry
|
| 15 |
|
|
|
|
|
|
|
| 16 |
logger = logging.getLogger(__name__)
|
| 17 |
logger.addHandler(logging.NullHandler())
|
| 18 |
|
| 19 |
|
| 20 |
+
def run_inference(model_type: str, prompt: str):
|
| 21 |
|
| 22 |
+
config = eval(f"{model_type}(prompt={prompt})")
|
| 23 |
+
if config.modality != "token2image" and prompt != "":
|
| 24 |
+
raise ValueError(
|
| 25 |
+
f"{model_type} is an unconditional generative model, please remove prompt (not={prompt})"
|
| 26 |
+
)
|
| 27 |
+
model = DiffusersGenerationAlgorithm(config)
|
| 28 |
+
image = list(model.sample(1))[0]
|
| 29 |
|
| 30 |
+
return image
|
| 31 |
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
|
|
|
| 35 |
# Preparation (retrieve all available algorithms)
|
| 36 |
all_algos = ApplicationsRegistry.list_available()
|
| 37 |
algos = [
|
| 38 |
+
x["algorithm_application"]
|
| 39 |
+
for x in list(filter(lambda x: "Diff" in x["algorithm_name"], all_algos))
|
|
|
|
|
|
|
| 40 |
]
|
| 41 |
+
algos = [a for a in algos if not "GeoDiff" in a]
|
| 42 |
|
| 43 |
# Load metadata
|
| 44 |
metadata_root = pathlib.Path(__file__).parent.joinpath("model_cards")
|
|
|
|
| 54 |
|
| 55 |
demo = gr.Interface(
|
| 56 |
fn=run_inference,
|
| 57 |
+
title="Diffusion-based image generators",
|
| 58 |
inputs=[
|
| 59 |
+
gr.Dropdown(
|
| 60 |
+
algos, label="Diffusion model", value="StableDiffusionGenerator"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
),
|
| 62 |
+
gr.Textbox(label="Text prompt", placeholder="A blue tree", lines=1),
|
| 63 |
],
|
| 64 |
+
outputs=gr.outputs.Image(type="pil"),
|
| 65 |
article=article,
|
| 66 |
description=description,
|
| 67 |
examples=examples.values.tolist(),
|
model_cards/article.md
CHANGED
|
@@ -1,40 +1,45 @@
|
|
| 1 |
# Model documentation & parameters
|
| 2 |
|
| 3 |
-
**
|
| 4 |
|
| 5 |
-
**
|
| 6 |
|
| 7 |
-
**Number of samples**: How many samples should be generated (between 1 and 50).
|
| 8 |
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
**
|
| 14 |
|
| 15 |
-
**
|
| 16 |
|
| 17 |
-
**
|
| 18 |
|
| 19 |
-
**Model
|
| 20 |
|
| 21 |
-
**Model
|
| 22 |
-
|
| 23 |
-
**Model type**: A sequence-based molecular generator tuned to generate blocks of polymers (e.g., catalysts and monomers).
|
| 24 |
|
| 25 |
**Information about training algorithms, parameters, fairness constraints or other applied approaches, and features**:
|
| 26 |
N.A.
|
| 27 |
|
| 28 |
**Paper or other resource for more information**:
|
| 29 |
-
|
| 30 |
|
| 31 |
**License**: MIT
|
| 32 |
|
| 33 |
-
**Where to send questions or comments about the model**: Open an issue on [
|
| 34 |
|
| 35 |
-
**Intended Use. Use cases that were envisioned during development**:
|
| 36 |
|
| 37 |
-
**Primary intended uses/users**:
|
| 38 |
|
| 39 |
**Out-of-scope use cases**: Production-level inference, producing molecules with harmful properties.
|
| 40 |
|
|
@@ -51,10 +56,12 @@ Model card prototype inspired by [Mitchell et al. (2019)](https://dl.acm.org/doi
|
|
| 51 |
## Citation
|
| 52 |
TBD, temporarily please cite:
|
| 53 |
```bib
|
| 54 |
-
@
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
```
|
|
|
|
| 1 |
# Model documentation & parameters
|
| 2 |
|
| 3 |
+
**Diffusion model**: Which model version to use.
|
| 4 |
|
| 5 |
+
**Prompt**: The text prompt used, only applies to *conditional* diffusion image generators. These are `LDMTextToImageGenerator` and `StableDiffusionGenerator`. The other four models (`DDPMGenerator`, `DDPMGenerator`, `LDMGenerator` and `ScoreSdeGenerator`) are *unconditional*.
|
| 6 |
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
+
# Model card -- Image diffusion models
|
| 10 |
|
| 11 |
+
**Model Details**: Six diffusion models for image generation:
|
| 12 |
+
- `LDMTextToImageGenerator`
|
| 13 |
+
- `StableDiffusionGenerator`
|
| 14 |
+
- `DDPMGenerator`
|
| 15 |
+
- `DDPMGenerator`
|
| 16 |
+
- `LDMGenerator`
|
| 17 |
+
- `ScoreSdeGenerator`
|
| 18 |
+
For details, see the [Diffusers docs](https://huggingface.co/docs/diffusers/index)
|
| 19 |
|
| 20 |
+
**Developers**: Various developers of above models, wrapped by Diffusers developers into [`diffusers`](https://github.com/huggingface/diffusers)
|
| 21 |
|
| 22 |
+
**Distributors**: Diffusers code integrated into GT4SD.
|
| 23 |
|
| 24 |
+
**Model date**: 2022.
|
| 25 |
|
| 26 |
+
**Model version**: Diffusion models, checkpoints provided and distributed by [`diffusers`](https://github.com/huggingface/diffusers).
|
| 27 |
|
| 28 |
+
**Model type**: Various, see [`diffusers`](https://github.com/huggingface/diffusers) docs.
|
|
|
|
|
|
|
| 29 |
|
| 30 |
**Information about training algorithms, parameters, fairness constraints or other applied approaches, and features**:
|
| 31 |
N.A.
|
| 32 |
|
| 33 |
**Paper or other resource for more information**:
|
| 34 |
+
N.A.
|
| 35 |
|
| 36 |
**License**: MIT
|
| 37 |
|
| 38 |
+
**Where to send questions or comments about the model**: Open an issue on [`diffusers`](https://github.com/huggingface/diffusers) repo.
|
| 39 |
|
| 40 |
+
**Intended Use. Use cases that were envisioned during development**: Computer vision researchers experimenting with image generative models.
|
| 41 |
|
| 42 |
+
**Primary intended uses/users**: Computer vision researchers
|
| 43 |
|
| 44 |
**Out-of-scope use cases**: Production-level inference, producing molecules with harmful properties.
|
| 45 |
|
|
|
|
| 56 |
## Citation
|
| 57 |
TBD, temporarily please cite:
|
| 58 |
```bib
|
| 59 |
+
@misc{von-platen-etal-2022-diffusers,
|
| 60 |
+
author = {Patrick von Platen and Suraj Patil and Anton Lozhkov and Pedro Cuenca and Nathan Lambert and Kashif Rasul and Mishig Davaadorj and Thomas Wolf},
|
| 61 |
+
title = {Diffusers: State-of-the-art diffusion models},
|
| 62 |
+
year = {2022},
|
| 63 |
+
publisher = {GitHub},
|
| 64 |
+
journal = {GitHub repository},
|
| 65 |
+
howpublished = {\url{https://github.com/huggingface/diffusers}}
|
| 66 |
}
|
| 67 |
```
|
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 |
+
This UI provides access to various diffusion-based image generators implemented in the [`diffusers`](https://github.com/huggingface/diffusers) library, wrapped and re-distributed 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
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
|
|
|
|
|
|
| 1 |
+
LDMGenerator,
|
| 2 |
+
LDMTextToImageGenerator,Generative models on the moon
|