Skip to content

Commit 3883150

Browse files
author
TRIP(appergb)
committed
fix: resolve pre-commit linting issues
- Fix MyPy unreachable code errors in preload_sharp_model.py - Apply automatic formatting fixes (black, trailing-whitespace, end-of-file-fixer) - Fix markdownlint fenced code block language tags
1 parent f8caa45 commit 3883150

5 files changed

Lines changed: 23 additions & 21 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ jobs:
2828

2929
- name: Verify build
3030
run: ls -la dist/
31-

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ python3 scripts/pointcloud_voxelizer.py input.ply --visualize
8181
## Troubleshooting
8282

8383
1. **Python version error**
84+
8485
```bash
8586
python3 --version # Ensure >= 3.9
8687
```
8788

8889
2. **Dependency installation failure**
90+
8991
```bash
9092
pip install torch --index-url https://download.pytorch.org/whl/cpu
9193
```
@@ -95,6 +97,7 @@ python3 scripts/pointcloud_voxelizer.py input.ply --visualize
9597
- Use `--voxel-size 0.02` for lower precision
9698

9799
4. **GPU unavailable**
100+
98101
```bash
99102
python3 scripts/preload_sharp_model.py --device cpu
100103
```
@@ -119,9 +122,9 @@ A.YLM/
119122

120123
Issues and pull requests are welcome.
121124

122-
**Developer**: TRIP (appergb)
125+
**Developer**: TRIP (appergb)
123126
**Contributors**: closer, true
124127

125128
## License
126129

127-
This project is licensed under the MIT License.
130+
This project is licensed under the MIT License.

scripts/pointcloud_voxelizer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ def detect_and_correct_ground_plane_enhanced(
275275

276276
[a, b, c, d] = best_plane_model
277277
inlier_ratio = (
278-
len(best_inliers) / len(pcd.points)
279-
if best_inliers is not None
280-
else 0.0
278+
len(best_inliers) / len(pcd.points) if best_inliers is not None else 0.0
281279
)
282280

283281
# 2. 地面质量评估
@@ -1689,4 +1687,3 @@ def main():
16891687

16901688
if __name__ == "__main__":
16911689
main()
1692-

scripts/preload_sharp_model.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
from pathlib import Path
3232
from typing import Any, Dict, Optional, cast
3333

34+
try:
35+
from sharp.models import RGBGaussianPredictor
36+
37+
ModelType = Optional[RGBGaussianPredictor]
38+
except ImportError:
39+
ModelType = Any
40+
3441
# 添加项目路径
3542
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
3643
if project_root not in sys.path:
@@ -70,7 +77,7 @@ def __init__(self, checkpoint_path: Optional[str] = None, device: str = "auto"):
7077
"SHARP_MODEL_PATH", "models/sharp_2572gikvuh.pt"
7178
)
7279
self.device = self._get_device(device)
73-
self.model = None
80+
self.model: ModelType = None
7481
self.loaded = False
7582
self.load_time = 0.0
7683
self.metadata_file: Optional[str] = None
@@ -142,17 +149,14 @@ def preload_model(self) -> bool:
142149

143150
# 创建和初始化模型
144151
self.model = create_predictor(PredictorParams())
145-
if self.model is not None:
146-
self.model.load_state_dict(state_dict)
147-
self.model.eval()
148-
self.model.to(self.device)
149-
150-
self.logger.info(f" 模型类型: {type(self.model).__name__}")
151-
self.logger.info(
152-
f" 模型参数量: {sum(p.numel() for p in self.model.parameters()):,}"
153-
)
154-
else:
155-
self.logger.warning("模型创建失败")
152+
self.model.load_state_dict(state_dict)
153+
self.model.eval()
154+
self.model.to(self.device)
155+
156+
self.logger.info(f" 模型类型: {type(self.model).__name__}")
157+
self.logger.info(
158+
f" 模型参数量: {sum(p.numel() for p in self.model.parameters()):,}"
159+
)
156160

157161
self.load_time = time.time() - start_time
158162
self.loaded = True
@@ -327,4 +331,3 @@ def main():
327331

328332
if __name__ == "__main__":
329333
main()
330-

src/aylm/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ def main_cli():
2222
print(" python scripts/preload_sharp_model.py --help")
2323
print(" python scripts/pointcloud_voxelizer.py --help")
2424

25+
2526
if __name__ == "__main__":
2627
main_cli()
27-

0 commit comments

Comments
 (0)