From c6a33e3d24d0258c3a5578388827257c7813c54a Mon Sep 17 00:00:00 2001 From: anton-l Date: Thu, 9 Jun 2022 11:43:51 +0200 Subject: [PATCH] fix tokenizers pipeline --- models/vision/glide/run_glide.py | 24 +++++++++++++----------- src/diffusers/pipeline_utils.py | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/models/vision/glide/run_glide.py b/models/vision/glide/run_glide.py index 7648b39f..c4351291 100644 --- a/models/vision/glide/run_glide.py +++ b/models/vision/glide/run_glide.py @@ -1,19 +1,21 @@ import torch - -from modeling_glide import GLIDE -import matplotlib -import matplotlib.pyplot as plt -matplotlib.rcParams['interactive'] = True - +from diffusers import DiffusionPipeline +import PIL.Image generator = torch.Generator() generator = generator.manual_seed(0) -pipeline = GLIDE.from_pretrained("fusing/glide-base") +model_id = "fusing/glide-base" -img = pipeline("a pencil sketch of a corgi", generator) +# load model and scheduler +pipeline = DiffusionPipeline.from_pretrained(model_id) + +# run inference (text-conditioned denoising + upscaling) +img = pipeline("a clip art of a hugging face", generator) + +# process image to PIL img = ((img + 1)*127.5).round().clamp(0, 255).to(torch.uint8).cpu().numpy() +image_pil = PIL.Image.fromarray(img) -plt.figure(figsize=(8, 8)) -plt.imshow(img) -plt.show() +# save image +image_pil.save("test.png") \ No newline at end of file diff --git a/src/diffusers/pipeline_utils.py b/src/diffusers/pipeline_utils.py index db802180..07fa2fbc 100644 --- a/src/diffusers/pipeline_utils.py +++ b/src/diffusers/pipeline_utils.py @@ -42,7 +42,7 @@ LOADABLE_CLASSES = { "GlideDDIMScheduler": ["save_config", "from_config"], }, "transformers": { - "GPT2Tokenizer": ["save_pretrained", "from_pretrained"], + "PreTrainedTokenizer": ["save_pretrained", "from_pretrained"], }, }