Spaces:
Paused
Paused
Delete test_full_installation.py
Browse files- test_full_installation.py +0 -212
test_full_installation.py
DELETED
|
@@ -1,212 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
Comprehensive test script to verify that all dependencies are installed correctly
|
| 4 |
-
and the Garment3DGen system is ready to run
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
import sys
|
| 8 |
-
import os
|
| 9 |
-
import torch
|
| 10 |
-
import numpy as np
|
| 11 |
-
|
| 12 |
-
def test_import(module_name, package_name=None):
|
| 13 |
-
"""Test if a module can be imported"""
|
| 14 |
-
try:
|
| 15 |
-
if package_name:
|
| 16 |
-
__import__(package_name)
|
| 17 |
-
else:
|
| 18 |
-
__import__(module_name)
|
| 19 |
-
print(f"β {module_name} imported successfully")
|
| 20 |
-
return True
|
| 21 |
-
except ImportError as e:
|
| 22 |
-
print(f"β Failed to import {module_name}: {e}")
|
| 23 |
-
return False
|
| 24 |
-
|
| 25 |
-
def test_cuda():
|
| 26 |
-
"""Test CUDA availability and functionality"""
|
| 27 |
-
try:
|
| 28 |
-
if torch.cuda.is_available():
|
| 29 |
-
print(f"β CUDA is available. GPU count: {torch.cuda.device_count()}")
|
| 30 |
-
print(f" Current device: {torch.cuda.current_device()}")
|
| 31 |
-
print(f" Device name: {torch.cuda.get_device_name()}")
|
| 32 |
-
|
| 33 |
-
# Test basic CUDA operations
|
| 34 |
-
device = torch.device('cuda:0')
|
| 35 |
-
x = torch.randn(10, 10).to(device)
|
| 36 |
-
y = torch.randn(10, 10).to(device)
|
| 37 |
-
z = torch.mm(x, y)
|
| 38 |
-
print(f"β CUDA operations working correctly")
|
| 39 |
-
return True
|
| 40 |
-
else:
|
| 41 |
-
print("β CUDA is not available")
|
| 42 |
-
return False
|
| 43 |
-
except Exception as e:
|
| 44 |
-
print(f"β Error testing CUDA: {e}")
|
| 45 |
-
return False
|
| 46 |
-
|
| 47 |
-
def test_torch_sparse():
|
| 48 |
-
"""Test torch-sparse functionality"""
|
| 49 |
-
try:
|
| 50 |
-
import torch_sparse
|
| 51 |
-
print("β torch_sparse imported successfully")
|
| 52 |
-
|
| 53 |
-
# Test basic sparse operations
|
| 54 |
-
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
| 55 |
-
indices = torch.tensor([[0, 1, 1], [2, 0, 2]], device=device)
|
| 56 |
-
values = torch.tensor([3, 4, 5], device=device)
|
| 57 |
-
size = (2, 3)
|
| 58 |
-
|
| 59 |
-
sparse_tensor = torch.sparse_coo_tensor(indices, values, size, device=device)
|
| 60 |
-
dense_tensor = torch.randn(3, 4, device=device)
|
| 61 |
-
|
| 62 |
-
# Test sparse matrix multiplication
|
| 63 |
-
result = torch.sparse.mm(sparse_tensor, dense_tensor)
|
| 64 |
-
print(f"β torch_sparse operations working correctly")
|
| 65 |
-
return True
|
| 66 |
-
except Exception as e:
|
| 67 |
-
print(f"β Error testing torch_sparse: {e}")
|
| 68 |
-
return False
|
| 69 |
-
|
| 70 |
-
def test_pytorch3d():
|
| 71 |
-
"""Test PyTorch3D functionality"""
|
| 72 |
-
try:
|
| 73 |
-
import pytorch3d
|
| 74 |
-
from pytorch3d.structures import Meshes
|
| 75 |
-
from pytorch3d.ops import sample_points_from_meshes
|
| 76 |
-
print("β PyTorch3D imported successfully")
|
| 77 |
-
|
| 78 |
-
# Test basic PyTorch3D operations
|
| 79 |
-
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
| 80 |
-
|
| 81 |
-
# Create a simple mesh
|
| 82 |
-
verts = torch.tensor([[0, 0, 0], [1, 0, 0], [0, 1, 0]], device=device)
|
| 83 |
-
faces = torch.tensor([[0, 1, 2]], device=device)
|
| 84 |
-
|
| 85 |
-
mesh = Meshes(verts=[verts], faces=[faces])
|
| 86 |
-
points = sample_points_from_meshes(mesh, num_samples=100)
|
| 87 |
-
|
| 88 |
-
print(f"β PyTorch3D operations working correctly")
|
| 89 |
-
return True
|
| 90 |
-
except Exception as e:
|
| 91 |
-
print(f"β Error testing PyTorch3D: {e}")
|
| 92 |
-
return False
|
| 93 |
-
|
| 94 |
-
def test_nvdiffrast():
|
| 95 |
-
"""Test nvdiffrast functionality"""
|
| 96 |
-
try:
|
| 97 |
-
import nvdiffrast.torch as dr
|
| 98 |
-
print("β nvdiffrast imported successfully")
|
| 99 |
-
|
| 100 |
-
# Test basic nvdiffrast operations
|
| 101 |
-
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
| 102 |
-
glctx = dr.RasterizeGLContext(device=device)
|
| 103 |
-
print(f"β nvdiffrast operations working correctly")
|
| 104 |
-
return True
|
| 105 |
-
except Exception as e:
|
| 106 |
-
print(f"β Error testing nvdiffrast: {e}")
|
| 107 |
-
return False
|
| 108 |
-
|
| 109 |
-
def test_project_modules():
|
| 110 |
-
"""Test project-specific modules"""
|
| 111 |
-
try:
|
| 112 |
-
# Test core project modules
|
| 113 |
-
from loop import loop
|
| 114 |
-
from utils import *
|
| 115 |
-
from NeuralJacobianFields import SourceMesh
|
| 116 |
-
from nvdiffmodeling.src import render
|
| 117 |
-
from utilities.camera import CameraBatch
|
| 118 |
-
from utilities.helpers import cosine_avg, create_scene, l1_avg
|
| 119 |
-
from utilities.clip_spatial import CLIPVisualEncoder
|
| 120 |
-
from utilities.resize_right import resize, cubic, linear, lanczos2, lanczos3
|
| 121 |
-
from packages.fashion_clip.fashion_clip.fashion_clip import FashionCLIP
|
| 122 |
-
from get_embeddings import *
|
| 123 |
-
|
| 124 |
-
print("β All project modules imported successfully")
|
| 125 |
-
return True
|
| 126 |
-
except Exception as e:
|
| 127 |
-
print(f"β Error testing project modules: {e}")
|
| 128 |
-
return False
|
| 129 |
-
|
| 130 |
-
def test_config_loading():
|
| 131 |
-
"""Test configuration loading"""
|
| 132 |
-
try:
|
| 133 |
-
import yaml
|
| 134 |
-
with open('example_config.yml', 'r') as f:
|
| 135 |
-
config = yaml.safe_load(f)
|
| 136 |
-
print("β Configuration loading working correctly")
|
| 137 |
-
return True
|
| 138 |
-
except Exception as e:
|
| 139 |
-
print(f"β Error testing configuration loading: {e}")
|
| 140 |
-
return False
|
| 141 |
-
|
| 142 |
-
def main():
|
| 143 |
-
"""Main test function"""
|
| 144 |
-
print("Testing Garment3DGen Full Installation...")
|
| 145 |
-
print("=" * 60)
|
| 146 |
-
|
| 147 |
-
# Test basic dependencies
|
| 148 |
-
print("\nTesting basic dependencies:")
|
| 149 |
-
basic_deps = [
|
| 150 |
-
("torch", "torch"),
|
| 151 |
-
("torchvision", "torchvision"),
|
| 152 |
-
("numpy", "numpy"),
|
| 153 |
-
("PIL", "Pillow"),
|
| 154 |
-
("yaml", "yaml"),
|
| 155 |
-
("gradio", "gradio"),
|
| 156 |
-
("clip", "clip"),
|
| 157 |
-
("kornia", "kornia"),
|
| 158 |
-
("scipy", "scipy"),
|
| 159 |
-
("trimesh", "trimesh"),
|
| 160 |
-
("easydict", "easydict"),
|
| 161 |
-
]
|
| 162 |
-
|
| 163 |
-
basic_success = True
|
| 164 |
-
for module, package in basic_deps:
|
| 165 |
-
if not test_import(module, package):
|
| 166 |
-
basic_success = False
|
| 167 |
-
|
| 168 |
-
# Test CUDA
|
| 169 |
-
print("\nTesting CUDA:")
|
| 170 |
-
cuda_success = test_cuda()
|
| 171 |
-
|
| 172 |
-
# Test complex dependencies
|
| 173 |
-
print("\nTesting complex dependencies:")
|
| 174 |
-
complex_success = True
|
| 175 |
-
|
| 176 |
-
if not test_torch_sparse():
|
| 177 |
-
complex_success = False
|
| 178 |
-
|
| 179 |
-
if not test_pytorch3d():
|
| 180 |
-
complex_success = False
|
| 181 |
-
|
| 182 |
-
if not test_nvdiffrast():
|
| 183 |
-
complex_success = False
|
| 184 |
-
|
| 185 |
-
# Test project modules
|
| 186 |
-
print("\nTesting project modules:")
|
| 187 |
-
project_success = test_project_modules()
|
| 188 |
-
|
| 189 |
-
# Test configuration
|
| 190 |
-
print("\nTesting configuration:")
|
| 191 |
-
config_success = test_config_loading()
|
| 192 |
-
|
| 193 |
-
# Summary
|
| 194 |
-
print("\n" + "=" * 60)
|
| 195 |
-
print("Full Installation Test Summary:")
|
| 196 |
-
print(f"Basic dependencies: {'β PASS' if basic_success else 'β FAIL'}")
|
| 197 |
-
print(f"CUDA: {'β PASS' if cuda_success else 'β FAIL'}")
|
| 198 |
-
print(f"Complex dependencies: {'β PASS' if complex_success else 'β FAIL'}")
|
| 199 |
-
print(f"Project modules: {'β PASS' if project_success else 'β FAIL'}")
|
| 200 |
-
print(f"Configuration: {'β PASS' if config_success else 'β FAIL'}")
|
| 201 |
-
|
| 202 |
-
if basic_success and cuda_success and complex_success and project_success and config_success:
|
| 203 |
-
print("\nπ All tests passed! The system is ready to run.")
|
| 204 |
-
print("You can now start the Gradio interface with: python app.py")
|
| 205 |
-
return True
|
| 206 |
-
else:
|
| 207 |
-
print("\nβ Some tests failed. Please check the installation.")
|
| 208 |
-
return False
|
| 209 |
-
|
| 210 |
-
if __name__ == "__main__":
|
| 211 |
-
success = main()
|
| 212 |
-
sys.exit(0 if success else 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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