Ali Mohsin commited on
Commit
77b97f3
Β·
1 Parent(s): 63e7e53

more fixes

Browse files
Files changed (1) hide show
  1. app.py +68 -57
app.py CHANGED
@@ -30,67 +30,77 @@ except:
30
  # Check if complex dependencies are installed
31
  def check_complex_dependencies():
32
  """Check if complex dependencies are available"""
 
 
 
33
  try:
34
  import nvdiffrast
 
 
 
 
 
 
 
35
  import pytorch3d
36
-
37
- # Check if torch-sparse is available or disabled
38
- try:
39
- import torch_sparse
40
- except ImportError:
41
- # Check if torch-sparse was disabled
42
- try:
43
- with open("NeuralJacobianFields/PoissonSystem.py", 'r') as f:
44
- content = f.read()
45
- if "USE_TORCH_SPARSE = False" in content:
46
- print("torch-sparse is disabled, using built-in PyTorch sparse operations")
47
- else:
48
- return False
49
- except:
50
- return False
51
-
52
- # Check if torch-scatter is available (not critical)
53
- try:
54
- import torch_scatter
55
- except ImportError:
56
- print("torch-scatter not available, but this may not be critical")
57
-
58
- # Try to safely import torchvision
59
  try:
60
- import torchvision
61
- print(f"torchvision {torchvision.__version__} loaded successfully")
62
- except RuntimeError as e:
63
- if "operator torchvision::nms does not exist" in str(e):
64
- print("WARNING: Compatibility issue with torchvision. Will attempt to continue anyway.")
65
  else:
66
- print(f"WARNING: torchvision error: {e}")
67
- except ImportError:
68
- print("WARNING: torchvision not available")
69
-
70
- return True
71
- except ImportError as e:
72
- print(f"Dependency error: {e}")
73
- return False
74
-
75
- # Run post-install if needed
76
- if not check_complex_dependencies():
77
- print("Complex dependencies not found, running post-install...")
78
  try:
79
- import subprocess
80
- subprocess.run([sys.executable, "post_install.py"], check=True)
81
- print("Post-install completed successfully!")
82
-
83
- # Run test to verify installation
84
- print("Running installation test...")
85
- subprocess.run([sys.executable, "test_installation.py"], check=True)
86
- print("Installation test passed!")
87
-
88
- print("Restarting to pick up new dependencies...")
89
- # Restart the process to pick up new dependencies
90
- os.execv(sys.executable, ['python'] + sys.argv)
91
- except Exception as e:
92
- print(f"Post-install failed: {e}")
93
- sys.exit(1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  # Enhanced torchvision compatibility handling
96
  def apply_torchvision_fix():
@@ -192,6 +202,7 @@ if import_success:
192
  else:
193
  print(f"οΏ½οΏ½ Processing engine failed to load: {loop_import_error}")
194
  print("The interface will still start, but processing functionality will be limited.")
 
195
 
196
  # Ensure NeuralJacobianFields is properly configured
197
  try:
@@ -602,8 +613,8 @@ def create_interface():
602
  engine_status = "βœ… Processing engine loaded successfully"
603
  status_msg = "Ready to generate garments. Select an input method and click 'Generate 3D Garment'."
604
  else:
605
- engine_status = f"❌ Processing engine unavailable: {loop_import_error or 'Unknown error'}"
606
- status_msg = "Processing engine is currently unavailable. Please check the system status."
607
 
608
  engine_status_output = gr.Markdown(f"**System Status:** {engine_status}")
609
  status_output = gr.Markdown(status_msg)
 
30
  # Check if complex dependencies are installed
31
  def check_complex_dependencies():
32
  """Check if complex dependencies are available"""
33
+ dependencies_ok = True
34
+ missing_deps = []
35
+
36
  try:
37
  import nvdiffrast
38
+ print("βœ“ nvdiffrast available")
39
+ except ImportError:
40
+ print("βœ— nvdiffrast not available")
41
+ dependencies_ok = False
42
+ missing_deps.append("nvdiffrast")
43
+
44
+ try:
45
  import pytorch3d
46
+ print("βœ“ pytorch3d available")
47
+ except ImportError:
48
+ print("βœ— pytorch3d not available")
49
+ dependencies_ok = False
50
+ missing_deps.append("pytorch3d")
51
+
52
+ # Check if torch-sparse is available or disabled
53
+ try:
54
+ import torch_sparse
55
+ print("βœ“ torch-sparse available")
56
+ except ImportError:
57
+ # Check if torch-sparse was disabled
 
 
 
 
 
 
 
 
 
 
 
58
  try:
59
+ with open("NeuralJacobianFields/PoissonSystem.py", 'r') as f:
60
+ content = f.read()
61
+ if "USE_TORCH_SPARSE = False" in content:
62
+ print("βœ“ torch-sparse is disabled, using built-in PyTorch sparse operations")
 
63
  else:
64
+ print("βœ— torch-sparse not available")
65
+ missing_deps.append("torch-sparse")
66
+ except:
67
+ print("βœ— torch-sparse not available")
68
+ missing_deps.append("torch-sparse")
69
+
70
+ # Check if torch-scatter is available (not critical)
 
 
 
 
 
71
  try:
72
+ import torch_scatter
73
+ print("βœ“ torch-scatter available")
74
+ except ImportError:
75
+ print("⚠ torch-scatter not available, but this may not be critical")
76
+
77
+ # Try to safely import torchvision
78
+ try:
79
+ import torchvision
80
+ print(f"βœ“ torchvision {torchvision.__version__} loaded successfully")
81
+ except RuntimeError as e:
82
+ if "operator torchvision::nms does not exist" in str(e):
83
+ print("⚠ Compatibility issue with torchvision. Will attempt to continue anyway.")
84
+ else:
85
+ print(f"⚠ torchvision error: {e}")
86
+ except ImportError:
87
+ print("⚠ torchvision not available")
88
+
89
+ if missing_deps:
90
+ print(f"Missing dependencies: {', '.join(missing_deps)}")
91
+
92
+ return dependencies_ok
93
+
94
+ # Check dependencies but don't fail if some are missing
95
+ print("Checking dependencies...")
96
+ deps_ok = check_complex_dependencies()
97
+
98
+ if not deps_ok:
99
+ print("Some dependencies are missing, but continuing anyway...")
100
+ print("The app will start with limited functionality.")
101
+ print("You can install missing dependencies manually if needed.")
102
+ else:
103
+ print("All dependencies are available!")
104
 
105
  # Enhanced torchvision compatibility handling
106
  def apply_torchvision_fix():
 
202
  else:
203
  print(f"οΏ½οΏ½ Processing engine failed to load: {loop_import_error}")
204
  print("The interface will still start, but processing functionality will be limited.")
205
+ print("This is normal in Dev Mode if dependencies are still being installed.")
206
 
207
  # Ensure NeuralJacobianFields is properly configured
208
  try:
 
613
  engine_status = "βœ… Processing engine loaded successfully"
614
  status_msg = "Ready to generate garments. Select an input method and click 'Generate 3D Garment'."
615
  else:
616
+ engine_status = f"⚠️ Processing engine unavailable: {loop_import_error or 'Unknown error'}"
617
+ status_msg = "Processing engine is currently unavailable. This is normal in Dev Mode if dependencies are still being installed. The interface will work once dependencies are ready."
618
 
619
  engine_status_output = gr.Markdown(f"**System Status:** {engine_status}")
620
  status_output = gr.Markdown(status_msg)