Update src/load_models.py
Browse files- src/load_models.py +3 -10
src/load_models.py
CHANGED
|
@@ -1,19 +1,14 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
-
import subprocess
|
| 4 |
import torch
|
| 5 |
import numpy as np
|
| 6 |
from PIL import Image
|
| 7 |
from huggingface_hub import hf_hub_download
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
subprocess.run(["git", "clone", "https://github.com/NVlabs/stylegan2-ada-pytorch.git", "stylegan2-ada"])
|
| 12 |
-
sys.path.append("stylegan2-ada")
|
| 13 |
|
| 14 |
-
|
| 15 |
-
import dnnlib
|
| 16 |
-
import legacy
|
| 17 |
|
| 18 |
# Globals
|
| 19 |
stylegan_generator = None
|
|
@@ -37,13 +32,11 @@ def load_stylegan_model(device="cuda" if torch.cuda.is_available() else "cpu"):
|
|
| 37 |
stylegan_generator = G
|
| 38 |
print("✅ StyleGAN2 model loaded and ready.")
|
| 39 |
|
| 40 |
-
|
| 41 |
def warm_up_models():
|
| 42 |
"""
|
| 43 |
Loads and warms up all global models used in the pipeline.
|
| 44 |
"""
|
| 45 |
global stylegan_generator
|
| 46 |
|
| 47 |
-
|
| 48 |
if stylegan_generator is None:
|
| 49 |
load_stylegan_model()
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
|
|
|
| 3 |
import torch
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
| 6 |
from huggingface_hub import hf_hub_download
|
| 7 |
|
| 8 |
+
# Point to your local stylegan2 utilities
|
| 9 |
+
#sys.path.append("src/stylegan2") # Adjust if the path differs
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
from stylegan2 import legacy
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Globals
|
| 14 |
stylegan_generator = None
|
|
|
|
| 32 |
stylegan_generator = G
|
| 33 |
print("✅ StyleGAN2 model loaded and ready.")
|
| 34 |
|
|
|
|
| 35 |
def warm_up_models():
|
| 36 |
"""
|
| 37 |
Loads and warms up all global models used in the pipeline.
|
| 38 |
"""
|
| 39 |
global stylegan_generator
|
| 40 |
|
|
|
|
| 41 |
if stylegan_generator is None:
|
| 42 |
load_stylegan_model()
|