AI-RABBIT commited on
Commit
38bfd01
·
verified ·
1 Parent(s): ab0a17e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1,23 +1,27 @@
1
  import os
2
  import git
 
 
3
  import gradio as gr
4
  import torch
5
  from huggingface_hub import hf_hub_download
6
  from diffusers import DiffusionPipeline
7
- from cog_sdxl.dataset_and_utils import TokenEmbeddingsHandler
8
- import subprocess
9
 
10
- # Clone the cog-sdxl repository if it doesn't exist
11
  repo_url = "https://github.com/replicate/cog-sdxl.git"
12
  repo_dir = "./cog-sdxl"
 
13
  if not os.path.exists(repo_dir):
14
  print("Cloning cog-sdxl repository...")
15
  git.Repo.clone_from(repo_url, repo_dir)
16
 
17
- # Install cog-sdxl as a local package
18
  print("Installing cog-sdxl package...")
19
  subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", repo_dir])
20
 
 
 
 
21
  # Load the model pipeline
22
  pipe = DiffusionPipeline.from_pretrained(
23
  "stabilityai/stable-diffusion-xl-base-1.0",
 
1
  import os
2
  import git
3
+ import subprocess
4
+ import sys
5
  import gradio as gr
6
  import torch
7
  from huggingface_hub import hf_hub_download
8
  from diffusers import DiffusionPipeline
 
 
9
 
10
+ # Check if the cog-sdxl repository exists, otherwise clone it
11
  repo_url = "https://github.com/replicate/cog-sdxl.git"
12
  repo_dir = "./cog-sdxl"
13
+
14
  if not os.path.exists(repo_dir):
15
  print("Cloning cog-sdxl repository...")
16
  git.Repo.clone_from(repo_url, repo_dir)
17
 
18
+ # Install the cog-sdxl repository locally
19
  print("Installing cog-sdxl package...")
20
  subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", repo_dir])
21
 
22
+ # Now import the required module after it has been installed
23
+ from cog_sdxl.dataset_and_utils import TokenEmbeddingsHandler
24
+
25
  # Load the model pipeline
26
  pipe = DiffusionPipeline.from_pretrained(
27
  "stabilityai/stable-diffusion-xl-base-1.0",