mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-29 07:22:12 +03:00
glide is alive!
This commit is contained in:
@@ -124,6 +124,7 @@ class GLIDE(DiffusionPipeline):
|
||||
- _extract_into_tensor(self.noise_scheduler.sqrt_recipm1_alphas_cumprod, t, x_t.shape) * eps
|
||||
)
|
||||
|
||||
@torch.no_grad()
|
||||
def __call__(self, prompt, generator=None, torch_device=None):
|
||||
torch_device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
|
||||
@@ -164,4 +165,6 @@ class GLIDE(DiffusionPipeline):
|
||||
nonzero_mask = (t != 0).float().view(-1, *([1] * (len(image.shape) - 1))) # no noise when t == 0
|
||||
image = mean + nonzero_mask * torch.exp(0.5 * log_variance) * noise
|
||||
|
||||
image = image[0].permute(1, 2, 0)
|
||||
|
||||
return image
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import torch
|
||||
|
||||
from modeling_glide import GLIDE
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
matplotlib.rcParams['interactive'] = True
|
||||
|
||||
|
||||
generator = torch.Generator()
|
||||
@@ -10,5 +13,8 @@ generator = generator.manual_seed(0)
|
||||
pipeline = GLIDE.from_pretrained("fusing/glide-base")
|
||||
|
||||
img = pipeline("an oil painting of a corgi", generator)
|
||||
img = ((img + 1)*127.5).round().clamp(0, 255).to(torch.uint8).cpu().numpy()
|
||||
|
||||
print(img)
|
||||
plt.figure(figsize=(8, 8))
|
||||
plt.imshow(img)
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user