Spaces:
Paused
Paused
Ali Mohsin
commited on
Commit
Β·
e2b6169
1
Parent(s):
fd9f634
changes c1233;g
Browse files
app.py
CHANGED
|
@@ -254,7 +254,23 @@ print("Attempting to import processing engine...")
|
|
| 254 |
|
| 255 |
# First, try to run post-install if needed
|
| 256 |
print("π Checking for Hugging Face Spaces environment...")
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
if is_hf_spaces:
|
| 260 |
print("π Hugging Face Spaces detected - ensuring all dependencies are installed...")
|
|
@@ -306,20 +322,38 @@ if is_hf_spaces:
|
|
| 306 |
# Manual installation of critical dependencies
|
| 307 |
try:
|
| 308 |
print("π¦ Installing nvdiffrast...")
|
|
|
|
| 309 |
result = subprocess.run([sys.executable, "-m", "pip", "install", "nvdiffrast"],
|
| 310 |
capture_output=True, text=True, timeout=300)
|
| 311 |
if result.returncode == 0:
|
| 312 |
print("β
nvdiffrast installed successfully")
|
| 313 |
else:
|
| 314 |
print(f"β οΈ nvdiffrast installation failed: {result.stderr}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
print("π¦ Installing pytorch3d...")
|
|
|
|
| 317 |
result = subprocess.run([sys.executable, "-m", "pip", "install", "pytorch3d", "--no-deps"],
|
| 318 |
capture_output=True, text=True, timeout=300)
|
| 319 |
if result.returncode == 0:
|
| 320 |
print("β
pytorch3d installed successfully")
|
| 321 |
else:
|
| 322 |
print(f"β οΈ pytorch3d installation failed: {result.stderr}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
print("π¦ Installing FashionCLIP...")
|
| 325 |
if os.path.exists("packages/fashion_clip"):
|
|
@@ -367,6 +401,8 @@ if is_hf_spaces:
|
|
| 367 |
else:
|
| 368 |
print("π Local development environment detected")
|
| 369 |
|
|
|
|
|
|
|
| 370 |
# Try to import the loop module after dependency installation attempts
|
| 371 |
print("π Attempting to import processing engine after dependency checks...")
|
| 372 |
import_success = try_import_loop()
|
|
|
|
| 254 |
|
| 255 |
# First, try to run post-install if needed
|
| 256 |
print("π Checking for Hugging Face Spaces environment...")
|
| 257 |
+
|
| 258 |
+
# More robust environment detection for Hugging Face Spaces
|
| 259 |
+
is_hf_spaces = (
|
| 260 |
+
os.environ.get('HUGGING_FACE_SPACES', '0') == '1' or
|
| 261 |
+
os.environ.get('SPACE_ID') is not None or
|
| 262 |
+
os.environ.get('HF_SPACE_ID') is not None or
|
| 263 |
+
os.environ.get('SPACES_SDK_VERSION') is not None or
|
| 264 |
+
'huggingface' in os.environ.get('HOSTNAME', '').lower() or
|
| 265 |
+
os.path.exists('/home/user/app') # Common HF Spaces path
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
print(f"Environment variables: HUGGING_FACE_SPACES={os.environ.get('HUGGING_FACE_SPACES', 'not set')}")
|
| 269 |
+
print(f"Environment variables: SPACE_ID={os.environ.get('SPACE_ID', 'not set')}")
|
| 270 |
+
print(f"Environment variables: HF_SPACE_ID={os.environ.get('HF_SPACE_ID', 'not set')}")
|
| 271 |
+
print(f"Environment variables: SPACES_SDK_VERSION={os.environ.get('SPACES_SDK_VERSION', 'not set')}")
|
| 272 |
+
print(f"Hostname: {os.environ.get('HOSTNAME', 'not set')}")
|
| 273 |
+
print(f"Current working directory: {os.getcwd()}")
|
| 274 |
|
| 275 |
if is_hf_spaces:
|
| 276 |
print("π Hugging Face Spaces detected - ensuring all dependencies are installed...")
|
|
|
|
| 322 |
# Manual installation of critical dependencies
|
| 323 |
try:
|
| 324 |
print("π¦ Installing nvdiffrast...")
|
| 325 |
+
# Try different installation methods for nvdiffrast
|
| 326 |
result = subprocess.run([sys.executable, "-m", "pip", "install", "nvdiffrast"],
|
| 327 |
capture_output=True, text=True, timeout=300)
|
| 328 |
if result.returncode == 0:
|
| 329 |
print("β
nvdiffrast installed successfully")
|
| 330 |
else:
|
| 331 |
print(f"β οΈ nvdiffrast installation failed: {result.stderr}")
|
| 332 |
+
# Try alternative installation
|
| 333 |
+
print("π Trying alternative nvdiffrast installation...")
|
| 334 |
+
result = subprocess.run([sys.executable, "-m", "pip", "install", "nvdiffrast", "--no-cache-dir"],
|
| 335 |
+
capture_output=True, text=True, timeout=300)
|
| 336 |
+
if result.returncode == 0:
|
| 337 |
+
print("β
nvdiffrast installed successfully (alternative method)")
|
| 338 |
+
else:
|
| 339 |
+
print(f"β οΈ Alternative nvdiffrast installation also failed: {result.stderr}")
|
| 340 |
|
| 341 |
print("π¦ Installing pytorch3d...")
|
| 342 |
+
# Try different installation methods for pytorch3d
|
| 343 |
result = subprocess.run([sys.executable, "-m", "pip", "install", "pytorch3d", "--no-deps"],
|
| 344 |
capture_output=True, text=True, timeout=300)
|
| 345 |
if result.returncode == 0:
|
| 346 |
print("β
pytorch3d installed successfully")
|
| 347 |
else:
|
| 348 |
print(f"β οΈ pytorch3d installation failed: {result.stderr}")
|
| 349 |
+
# Try alternative installation
|
| 350 |
+
print("π Trying alternative pytorch3d installation...")
|
| 351 |
+
result = subprocess.run([sys.executable, "-m", "pip", "install", "pytorch3d", "--no-deps", "--no-cache-dir"],
|
| 352 |
+
capture_output=True, text=True, timeout=300)
|
| 353 |
+
if result.returncode == 0:
|
| 354 |
+
print("β
pytorch3d installed successfully (alternative method)")
|
| 355 |
+
else:
|
| 356 |
+
print(f"β οΈ Alternative pytorch3d installation also failed: {result.stderr}")
|
| 357 |
|
| 358 |
print("π¦ Installing FashionCLIP...")
|
| 359 |
if os.path.exists("packages/fashion_clip"):
|
|
|
|
| 401 |
else:
|
| 402 |
print("π Local development environment detected")
|
| 403 |
|
| 404 |
+
|
| 405 |
+
|
| 406 |
# Try to import the loop module after dependency installation attempts
|
| 407 |
print("π Attempting to import processing engine after dependency checks...")
|
| 408 |
import_success = try_import_loop()
|