@ -29,53 +29,46 @@ Load the model parameters once and reuse the model to generate multiple images.
```python
from min_dalle import MinDalle
model = MinDalle(is_mega=True, models_root='./pretrained')
model = MinDalle(
is_mega=True,
is_reusable=True,
models_root='./pretrained'
)
```
The required models will be downloaded to `models_root` if they are not already there. Once everything has finished initializing, call `generate_image` with some text as many times as you want.
Use a positive `seed` for reproducible results. Higher values for `log2_supercondition_factor` result in better agreement with the text but a narrower variety of generated images.
If the model is being used interactively (e.g. in a notebook) `generate_image_stream` can be used to generate a stream of images as it the model is decoding. The detokenizer adds a slight delay for each intermediate image.
```python
text = 'a funeral at Whole Foods'
image = model.generate_image(text, grid_size=3)
display(image)
image_stream = model.generate_image_stream(
text='Dali painting of WALL·E',
seed=-1,
grid_size=3,
log2_mid_count=3,
log2_supercondition_factor=3
)
is_first = True
for image in image_stream:
display_image = display if is_first else update_display