Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -5,9 +5,16 @@ from diffusers import DiffusionPipeline
5
  import torch
6
  from huggingface_hub import login
7
  import os
 
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
 
 
 
 
 
 
 
11
  # Set your Hugging Face token
12
  HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
13
  login(token=HUGGINGFACE_TOKEN)
 
5
  import torch
6
  from huggingface_hub import login
7
  import os
8
+ import subprocess
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
11
 
12
+ # Install xformers if not already installed
13
+ try:
14
+ import xformers
15
+ except ImportError:
16
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "xformers"])
17
+
18
  # Set your Hugging Face token
19
  HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
20
  login(token=HUGGINGFACE_TOKEN)