Spaces:
Running
on
Zero
Running
on
Zero
gokaygokay
commited on
Commit
•
25adc0c
1
Parent(s):
b97d3bc
Update app.py
Browse files
app.py
CHANGED
@@ -21,43 +21,28 @@ import math
|
|
21 |
import gradio as gr
|
22 |
from gradio_imageslider import ImageSlider
|
23 |
|
|
|
|
|
24 |
USE_TORCH_COMPILE = False
|
25 |
ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
|
26 |
|
27 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
28 |
|
29 |
-
def download_file(url, folder_path, filename):
|
30 |
-
if not os.path.exists(folder_path):
|
31 |
-
os.makedirs(folder_path)
|
32 |
-
file_path = os.path.join(folder_path, filename)
|
33 |
-
|
34 |
-
if os.path.isfile(file_path):
|
35 |
-
print(f"File already exists: {file_path}")
|
36 |
-
else:
|
37 |
-
response = requests.get(url, stream=True)
|
38 |
-
if response.status_code == 200:
|
39 |
-
with open(file_path, 'wb') as file:
|
40 |
-
for chunk in response.iter_content(chunk_size=1024):
|
41 |
-
file.write(chunk)
|
42 |
-
print(f"File successfully downloaded and saved: {file_path}")
|
43 |
-
else:
|
44 |
-
print(f"Error downloading the file. Status code: {response.status_code}")
|
45 |
-
|
46 |
def download_models():
|
47 |
models = {
|
48 |
-
"MODEL": ("
|
49 |
-
"UPSCALER_X2": ("
|
50 |
-
"UPSCALER_X4": ("
|
51 |
-
"NEGATIVE_1": ("
|
52 |
-
"NEGATIVE_2": ("
|
53 |
-
"LORA_1": ("
|
54 |
-
"LORA_2": ("
|
55 |
-
"CONTROLNET": ("
|
56 |
-
"VAE": ("
|
57 |
}
|
58 |
|
59 |
-
for model, (
|
60 |
-
|
61 |
|
62 |
download_models()
|
63 |
|
|
|
21 |
import gradio as gr
|
22 |
from gradio_imageslider import ImageSlider
|
23 |
|
24 |
+
from huggingface_hub import hf_hub_download
|
25 |
+
|
26 |
USE_TORCH_COMPILE = False
|
27 |
ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
|
28 |
|
29 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
def download_models():
|
32 |
models = {
|
33 |
+
"MODEL": ("dantea1118/juggernaut_reborn", "juggernaut_reborn.safetensors", "models/models/Stable-diffusion"),
|
34 |
+
"UPSCALER_X2": ("ai-forever/Real-ESRGAN", "RealESRGAN_x2.pth", "models/upscalers/"),
|
35 |
+
"UPSCALER_X4": ("ai-forever/Real-ESRGAN", "RealESRGAN_x4.pth", "models/upscalers/"),
|
36 |
+
"NEGATIVE_1": ("philz1337x/embeddings", "verybadimagenegative_v1.3.pt", "models/embeddings"),
|
37 |
+
"NEGATIVE_2": ("AddictiveFuture/sd-negative-embeddings", "JuggernautNegative-neg.pt", "models/embeddings"),
|
38 |
+
"LORA_1": ("philz1337x/loras", "SDXLrender_v2.0.safetensors", "models/Lora"),
|
39 |
+
"LORA_2": ("philz1337x/loras", "more_details.safetensors", "models/Lora"),
|
40 |
+
"CONTROLNET": ("lllyasviel/ControlNet-v1-1", "control_v11f1e_sd15_tile.pth", "models/ControlNet"),
|
41 |
+
"VAE": ("stabilityai/sd-vae-ft-mse-original", "vae-ft-mse-840000-ema-pruned.safetensors", "models/VAE"),
|
42 |
}
|
43 |
|
44 |
+
for model, (repo_id, filename, local_dir) in models.items():
|
45 |
+
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=local_dir)
|
46 |
|
47 |
download_models()
|
48 |
|