Spaces:
Sleeping
Sleeping
InstantID For retaining facial identity
Browse files
app.py
CHANGED
|
@@ -13,22 +13,32 @@ from rembg import remove
|
|
| 13 |
from diffusers import StableDiffusionImg2ImgPipeline
|
| 14 |
from diffusers import StableDiffusionXLPipeline
|
| 15 |
import io
|
| 16 |
-
import os, sys, subprocess, warnings
|
| 17 |
|
| 18 |
warnings.filterwarnings("ignore", category=UserWarning)
|
|
|
|
| 19 |
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
| 20 |
|
| 21 |
# --- Ensure InstantID is available ---
|
| 22 |
if not os.path.exists("instantid"):
|
| 23 |
print("🔄 Cloning InstantID repository...")
|
| 24 |
subprocess.run(["git", "clone", "https://github.com/InstantID/InstantID.git"], check=True)
|
| 25 |
-
if os.path.exists("InstantID") and not os.path.exists("instantid"):
|
| 26 |
-
os.rename("InstantID", "instantid")
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
import torchvision
|
| 34 |
print("Printing Torch and TorchVision versions:")
|
|
|
|
| 13 |
from diffusers import StableDiffusionImg2ImgPipeline
|
| 14 |
from diffusers import StableDiffusionXLPipeline
|
| 15 |
import io
|
| 16 |
+
import os, sys, subprocess, warnings, logging
|
| 17 |
|
| 18 |
warnings.filterwarnings("ignore", category=UserWarning)
|
| 19 |
+
logging.getLogger("onnxruntime").setLevel(logging.ERROR)
|
| 20 |
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
| 21 |
|
| 22 |
# --- Ensure InstantID is available ---
|
| 23 |
if not os.path.exists("instantid"):
|
| 24 |
print("🔄 Cloning InstantID repository...")
|
| 25 |
subprocess.run(["git", "clone", "https://github.com/InstantID/InstantID.git"], check=True)
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
if os.path.exists("InstantID") and not os.path.exists("instantid"):
|
| 28 |
+
os.rename("InstantID", "instantid")
|
| 29 |
+
|
| 30 |
+
instantid_path = os.path.abspath("instantid")
|
| 31 |
+
sys.path.append(instantid_path)
|
| 32 |
+
sys.path.append(os.path.join(instantid_path, "pipelines"))
|
| 33 |
|
| 34 |
+
#sys.path.append(os.path.abspath("instantid"))
|
| 35 |
+
#sys.path.insert(0, os.path.join(os.getcwd(), 'InstantID'))
|
| 36 |
+
try
|
| 37 |
+
from pipelines.pipeline_instantid import InstantIDPipeline
|
| 38 |
+
print("✅ InstantIDPipeline imported successfully.")
|
| 39 |
+
except Exception as e:
|
| 40 |
+
print("⚠️ Failed to import InstantIDPipeline:", e)
|
| 41 |
+
InstantIDPipeline = None # graceful fallback
|
| 42 |
|
| 43 |
import torchvision
|
| 44 |
print("Printing Torch and TorchVision versions:")
|