|
```python |
|
import os |
|
os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8" |
|
|
|
from diffusers import UnCLIPPipeline |
|
import torch |
|
import random |
|
import numpy as np |
|
|
|
def set_seed(seed: int): |
|
random.seed(seed) |
|
np.random.seed(seed) |
|
torch.manual_seed(seed) |
|
torch.cuda.manual_seed_all(seed) |
|
|
|
set_seed(0) |
|
|
|
torch.backends.cuda.matmul.allow_tf32 = False |
|
torch.use_deterministic_algorithms(True) |
|
|
|
pipe = UnCLIPPipeline.from_pretrained("fusing/karlo_unclip", torch_dtype=torch.float16) |
|
pipe = pipe.to('cuda') |
|
|
|
prompt = "a high-resolution photograph of a big red frog on a green leaf." |
|
|
|
image = pipe([prompt]).images[0] |
|
|
|
image.save("frog.png") |
|
``` |
|
|
|
![img](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/frog.png) |