Spaces:
Paused
Paused
#!/usr/bin/env python3 | |
""" | |
Test script to verify all dependencies are working correctly | |
""" | |
import sys | |
import traceback | |
def test_imports(): | |
"""Test importing all required dependencies""" | |
print("Testing imports...") | |
try: | |
import torch | |
print(f"β PyTorch {torch.__version__}") | |
print(f" CUDA available: {torch.cuda.is_available()}") | |
if torch.cuda.is_available(): | |
print(f" CUDA version: {torch.version.cuda}") | |
print(f" GPU count: {torch.cuda.device_count()}") | |
except Exception as e: | |
print(f"β PyTorch import failed: {e}") | |
return False | |
# Check if torch-sparse is available or disabled | |
try: | |
import torch_sparse | |
print("β torch-sparse") | |
except ImportError: | |
# Check if torch-sparse was disabled | |
try: | |
with open("NeuralJacobianFields/PoissonSystem.py", 'r') as f: | |
content = f.read() | |
if "USE_TORCH_SPARSE = False" in content: | |
print("β torch-sparse (disabled, using built-in PyTorch sparse)") | |
else: | |
print("β torch-sparse (not available)") | |
return False | |
except: | |
print("β torch-sparse (not available)") | |
return False | |
except Exception as e: | |
print(f"β torch-sparse import failed: {e}") | |
return False | |
# Check if torch-scatter is available (not critical) | |
try: | |
import torch_scatter | |
print("β torch-scatter") | |
except ImportError: | |
print("β torch-scatter (not available, may not be critical)") | |
except Exception as e: | |
print(f"β torch-scatter import failed: {e} (may not be critical)") | |
try: | |
import nvdiffrast | |
print("β nvdiffrast") | |
except Exception as e: | |
print(f"β nvdiffrast import failed: {e}") | |
return False | |
try: | |
import pytorch3d | |
print("β PyTorch3D") | |
except Exception as e: | |
print(f"β PyTorch3D import failed: {e}") | |
return False | |
try: | |
import clip | |
print("β CLIP") | |
except Exception as e: | |
print(f"β CLIP import failed: {e}") | |
return False | |
return True | |
def test_basic_functionality(): | |
"""Test basic functionality of key components""" | |
print("\nTesting basic functionality...") | |
try: | |
import torch | |
# Test basic tensor operations | |
x = torch.randn(10, 10) | |
y = torch.randn(10, 10) | |
z = x + y | |
print("β Basic tensor operations") | |
# Test sparse operations (using built-in PyTorch sparse) | |
indices = torch.randint(0, 10, (2, 20)) | |
values = torch.randn(20) | |
sparse_tensor = torch.sparse_coo_tensor(indices, values, (10, 10)) | |
print("β Sparse tensor creation") | |
# Test if torch-sparse is available (optional) | |
try: | |
import torch_sparse | |
print("β torch-sparse operations available") | |
except ImportError: | |
print("β Using built-in PyTorch sparse operations") | |
# Test if torch-scatter is available (optional) | |
try: | |
import torch_scatter | |
print("β torch-scatter operations available") | |
except ImportError: | |
print("β torch-scatter not available (not critical)") | |
except Exception as e: | |
print(f"β Basic functionality test failed: {e}") | |
traceback.print_exc() | |
return False | |
return True | |
def main(): | |
"""Main test function""" | |
print("=== Garment3DGen Dependency Test ===\n") | |
# Test imports | |
if not test_imports(): | |
print("\nβ Import tests failed!") | |
sys.exit(1) | |
# Test basic functionality | |
if not test_basic_functionality(): | |
print("\nβ Functionality tests failed!") | |
sys.exit(1) | |
print("\nβ All tests passed! Dependencies are working correctly.") | |
print("The Garment3DGen application should be ready to run.") | |
if __name__ == "__main__": | |
main() |