add smpl
Browse files- smpl_generator.py +23 -17
smpl_generator.py
CHANGED
|
@@ -23,15 +23,10 @@ class SMPLGenerator:
|
|
| 23 |
else:
|
| 24 |
model_path_obj.mkdir(parents=True, exist_ok=True)
|
| 25 |
|
| 26 |
-
models_source =
|
| 27 |
if not models_source.exists():
|
| 28 |
models_source = model_path_obj / "models"
|
| 29 |
|
| 30 |
-
if models_source.exists() and (model_path_obj / "smpl").exists():
|
| 31 |
-
expected_models_dir = model_path_obj / "smpl" / "models"
|
| 32 |
-
if not expected_models_dir.exists() and models_source.exists():
|
| 33 |
-
print(f"Models found in {models_source}, smplx may need them in {expected_models_dir}")
|
| 34 |
-
|
| 35 |
self.model_path = model_path_obj
|
| 36 |
model_path_str = str(self.model_path)
|
| 37 |
|
|
@@ -39,21 +34,32 @@ class SMPLGenerator:
|
|
| 39 |
gender = "male"
|
| 40 |
print("Note: Neutral gender not available, using male model")
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if not models_dir.exists():
|
| 44 |
-
models_dir = model_path_obj / "
|
| 45 |
-
|
| 46 |
-
print(f"Looking for SMPL models in: {model_path_str}")
|
| 47 |
-
if models_dir.exists():
|
| 48 |
-
model_files = list(models_dir.glob("*.pkl"))
|
| 49 |
-
print(f"Found {len(model_files)} model files: {[f.name for f in model_files]}")
|
| 50 |
|
| 51 |
model_paths_to_try = [
|
|
|
|
| 52 |
"smpl",
|
| 53 |
-
|
| 54 |
-
str(model_path_obj / "smpl"),
|
| 55 |
-
str(models_dir.parent) if models_dir.exists() else None,
|
| 56 |
-
"smpl/smpl"
|
| 57 |
]
|
| 58 |
model_paths_to_try = [p for p in model_paths_to_try if p is not None and Path(p).exists()]
|
| 59 |
|
|
|
|
| 23 |
else:
|
| 24 |
model_path_obj.mkdir(parents=True, exist_ok=True)
|
| 25 |
|
| 26 |
+
models_source = Path("smpl/smpl/models")
|
| 27 |
if not models_source.exists():
|
| 28 |
models_source = model_path_obj / "models"
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
self.model_path = model_path_obj
|
| 31 |
model_path_str = str(self.model_path)
|
| 32 |
|
|
|
|
| 34 |
gender = "male"
|
| 35 |
print("Note: Neutral gender not available, using male model")
|
| 36 |
|
| 37 |
+
if models_source.exists():
|
| 38 |
+
model_files = list(models_source.glob("*.pkl"))
|
| 39 |
+
print(f"Found {len(model_files)} model files in {models_source}: {[f.name for f in model_files]}")
|
| 40 |
+
|
| 41 |
+
expected_smpl_dir = model_path_obj / "smpl"
|
| 42 |
+
expected_models_dir = expected_smpl_dir / "models"
|
| 43 |
+
|
| 44 |
+
if not expected_models_dir.exists() and models_source.exists():
|
| 45 |
+
print(f"Creating expected directory structure: {expected_models_dir}")
|
| 46 |
+
expected_models_dir.mkdir(parents=True, exist_ok=True)
|
| 47 |
+
|
| 48 |
+
for model_file in model_files:
|
| 49 |
+
target_file = expected_models_dir / model_file.name
|
| 50 |
+
if not target_file.exists():
|
| 51 |
+
import shutil
|
| 52 |
+
shutil.copy2(model_file, target_file)
|
| 53 |
+
print(f"Copied {model_file.name} to {target_file}")
|
| 54 |
+
|
| 55 |
+
models_dir = model_path_obj / "smpl" / "models"
|
| 56 |
if not models_dir.exists():
|
| 57 |
+
models_dir = model_path_obj / "models"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
model_paths_to_try = [
|
| 60 |
+
str(model_path_obj),
|
| 61 |
"smpl",
|
| 62 |
+
str(models_dir.parent) if models_dir.exists() else None
|
|
|
|
|
|
|
|
|
|
| 63 |
]
|
| 64 |
model_paths_to_try = [p for p in model_paths_to_try if p is not None and Path(p).exists()]
|
| 65 |
|