Files
FishServer/README.md
2026-04-10 10:30:01 +08:00

69 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FishServer 核心仓库(已瘦身)
本目录面向 **FishMeasureSVO2 称重/点云)**、**FishActionMP4 行为 X3D** 与 **fish_apiFastAPI 网关)** 的部署与运行,已去掉训练数据、历史推理产物、旧版 Django 前端和 SlowFast 训练栈等大体积非运行时内容。
## 目录结构
| 路径 | 说明 |
|------|------|
| `fish_api/` | FastAPI`uv sync``uv run uvicorn app.main:app`,见其中 `README.md` |
| `FishMeasure/` | 双目链路:`predict_weigth_from_svo2.py``fish_video_weight_evaluation.py``weight_estimator/``pointcloud_classifier/` 等 |
| `FishAction/` | 行为推断:`predict_video_x3d_3class.py``train_pytorchvideo_x3d.py``checkpoints/`X3D |
| `packaging/` | **单一 Conda 环境**:网关 + 两条算法依赖定义,见 [`packaging/README.md`](packaging/README.md) |
| `scripts/start_fresh.sh` | 在已激活的 `fishserver` 环境中清空缓存后启动 uvicorn |
| `scripts/start_no_fresh.sh` | 保留 SQLite 与推理缓存启动 uvicorn |
### 一键打包成「单环境」运行(推荐服务器)
```bash
bash packaging/bootstrap_fishserver.sh
conda activate fishserver
bash packaging/patch_cuda_torch.sh # Linux + NVIDIA 时建议
# 再按 packaging/README.md 安装 ZED SDK 与 pyzed
PORT=8001 bash scripts/start_fresh.sh
```
多 Conda 环境、分别设置 `PYTHON_FISH_MEASURE` / `PYTHON_FISH_ACTION` 的方式仍支持,见 `fish_api/README.md`
## 已删除内容(需训练/旧功能时可从备份找回)
- `FishMeasure/output_weight_estimator/``output-yolo-sam/`:推理输出
- `FishMeasure/datasets/`:训练集
- `FishMeasure/project_jiuzhou01/`:九州 Django + 前端工程
- `FishMeasure/measure/``detect_refbox/dataset``detect_refbox/runs`:独立实验数据与跑次
- `FishMeasure/runs/predict``runs/segment`:旧预测/分割输出
- `FishMeasure/utils/data/`:工具附带大数据
- `FishMeasure/weight_estimator/runs/` 中除 `dgcnn_20260312_171043/` 外的历史训练目录
- `FishAction/slowfast/`SlowFast 训练代码(当前网关仅走 PyTorchVideo X3D
- 根目录重复 `yolo*.pt``fish_video_weight_evaluation__v1.py`
## 仍占空间的大文件(运行时一般需要)
- **`FishMeasure/sam_vit_h_4b8939.pth`**(约 2.4GBSAM `vit_h`。若未放置,可从 [Segment Anything 官方权重](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth) 下载到 `FishMeasure/` 下同名文件。
- **`FishMeasure/runs/train/fish_detection_20251127_104658/weights/best.pt`**YOLO 检测,与 `fish_api` 默认环境变量一致。
- **`FishMeasure/weight_estimator/runs/dgcnn_20260312_171043/best.pt`**DGCNN 体重估计。
- **`FishAction/checkpoints/ptv_x3d_m/checkpoint_best.pt`**:行为分类(已删除其它实验版 checkpoint 目录以省空间;若需恢复请从备份拿回)。
## Git 与体积
`FishMeasure/``FishAction/` 内嵌各自 `.git`,其中 FishMeasure 历史对象可能很大(含 LFS。**仅部署运行时**可用 rsync 排除版本库:
```bash
rsync -avz --exclude '.git' --exclude 'fish_api/.venv' ...
```
## 接口说明
- 业务 API 契约可参考仓库根目录 `接口文档.docx`(若仍保留)。
- HTTP 网关路径以 `fish_api/app/routers/` 为准。
## 同步到服务器示例
```bash
rsync -avz --delete \
--exclude '.venv' --exclude 'fish_api/.venv' --exclude '__pycache__' \
./ ubuntu@192.168.10.93:/home/ubuntu/projects/FishServer/
```
(按实际 IP、用户与路径修改`--delete` 慎用,会删远端多余文件。)