Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,13 @@ import torch
|
|
3 |
import os
|
4 |
import gc
|
5 |
import random
|
6 |
-
from huggingface_hub import snapshot_download
|
7 |
from diffusers import StableDiffusionXLPipeline, LCMScheduler
|
8 |
from PIL import Image
|
9 |
|
|
|
|
|
|
|
10 |
os.environ["XDG_CACHE_HOME"] = "/home/user/.cache"
|
11 |
os.environ["TRANSFORMERS_CACHE"] = "/home/user/.cache/huggingface/transformers"
|
12 |
os.environ["HF_HOME"] = "/home/user/.cache/huggingface"
|
@@ -27,7 +30,7 @@ cached_loras = {}
|
|
27 |
def get_lora(lora_id):
|
28 |
if lora_id in cached_loras:
|
29 |
return cached_loras[lora_id]
|
30 |
-
lora_dir = snapshot_download(repo_id=lora_id, allow_patterns=["*.safetensors", "*.bin"])
|
31 |
lora_files = [f for f in os.listdir(lora_dir) if f.endswith((".safetensors", ".bin"))]
|
32 |
lora_path = os.path.join(lora_dir, lora_files[0])
|
33 |
cached_loras[lora_id] = lora_path
|
|
|
3 |
import os
|
4 |
import gc
|
5 |
import random
|
6 |
+
from huggingface_hub import snapshot_download, HfApi
|
7 |
from diffusers import StableDiffusionXLPipeline, LCMScheduler
|
8 |
from PIL import Image
|
9 |
|
10 |
+
newcv = os.getenv("newcv")
|
11 |
+
newhf = os.getenv("newhf")
|
12 |
+
api = HfApi(token=HF_TOKEN)
|
13 |
os.environ["XDG_CACHE_HOME"] = "/home/user/.cache"
|
14 |
os.environ["TRANSFORMERS_CACHE"] = "/home/user/.cache/huggingface/transformers"
|
15 |
os.environ["HF_HOME"] = "/home/user/.cache/huggingface"
|
|
|
30 |
def get_lora(lora_id):
|
31 |
if lora_id in cached_loras:
|
32 |
return cached_loras[lora_id]
|
33 |
+
lora_dir = snapshot_download(repo_id=lora_id, use_auth_token=newhf, local_files_only=False ,allow_patterns=["*.safetensors", "*.bin"])
|
34 |
lora_files = [f for f in os.listdir(lora_dir) if f.endswith((".safetensors", ".bin"))]
|
35 |
lora_path = os.path.join(lora_dir, lora_files[0])
|
36 |
cached_loras[lora_id] = lora_path
|