Skip to content

Commit

Permalink
Fix installation for diffuser_instruct_pix2pix (pytorch#2184)
Browse files Browse the repository at this point in the history
Summary:
Currently `diffuser_instruct_pix2pix/install.py` tries to import `diffusers` before installing the requirements throwing an error:

```
from diffusers import StableDiffusionInstructPix2PixPipeline
ModuleNotFoundError: No module named 'diffusers'
```
These changes fix the installation making this file similar to other diffuser installation scripts.

Pull Request resolved: pytorch#2184

Reviewed By: aaronenyeshi

Differential Revision: D54884958

Pulled By: xuzhao9

fbshipit-source-id: 5a80b2d76879ca095b8e12151535983864876805
  • Loading branch information
JasonMts authored and facebook-github-bot committed Mar 14, 2024
1 parent 6ba2382 commit 0ea6f93
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from torchbenchmark.util.framework.diffusers import install_diffusers
from diffusers import StableDiffusionInstructPix2PixPipeline
import torch
import os
import warnings

MODEL_NAME = "timbrooks/instruct-pix2pix"

def load_model_checkpoint():
from diffusers import StableDiffusionInstructPix2PixPipeline

StableDiffusionInstructPix2PixPipeline.from_pretrained(MODEL_NAME, torch_dtype=torch.float16, safety_checker=None)

if __name__ == '__main__':
install_diffusers()
if not "HUGGING_FACE_HUB_TOKEN" in os.environ:
warnings.warn(
"Make sure to set `HUGGINGFACE_HUB_TOKEN` so you can download weights"
)
else:
load_model_checkpoint()

0 comments on commit 0ea6f93

Please sign in to comment.