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