main_enhanced_complete.py: main entrypoint (detection/segmentation + speed estimation + anomaly logging + video output).src/: core pipeline modules.detector.py: YOLOv8-seg inference wrapper.speed_calculator.py: 3D speed estimation with smoothing.depth_estimator.py: Depth-Anything depth estimation (with simplified fallback).visualizer.py: annotated video output and charts.
depth_anything/: local Depth-Anything implementation (source only; weights separate).models/custom_modules.py: custom attention modules (for example, SE).configs/: model and camera YAML configs.scripts/: helper scripts for depth setup and weight handling.weights/: model weight files (for example,weights/best.pt).merged_dataset/: dataset included in this repository.images/train,images/vallabels/train,labels/valshiziyu.yaml(dataset config)- Full path:
D:\project\shizhiyu\FishSpeed_core_src\merged_dataset
- Core Python source for detection, depth estimation, speed calculation, and visualization.
- Required configs and helper scripts.
- The dataset in
merged_dataset/(see path above).
Use Python 3.8+.
python -m venv venv
# Windows
.\venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
pip install -U pip
pip install -r requirements.txtPlace YOLO weights at weights/best.pt:
python main_enhanced_complete.py --input /path/to/video.mp4python main_enhanced_complete.py --input /path/to/video.mp4 --model /path/to/best.ptCommon arguments (see --help for the full list):
--input/-i: input video path--output/-o: output directory (defaultenhanced_outputs)--model/-m: YOLO weight path--enable-depth-anything/--disable-depth-anything: enable/disable Depth-Anything--enable-depth/--disable-depth: legacy depth toggle--depth-encoder:vits|vitb|vitl--depth-weights: Depth-Anything weight path--allow-remote: allow remote downloads (avoid in restricted networks)--show-depth/--no-show-depth: show depth panel in output video--frame-skip: frame skip interval (default 1)
- YOLO weights:
weights/.../best.pt - Depth-Anything weights:
weights/depth_anything_vitb14.pth
You can also use environment variables:
export FISHSPEED_DEPTH_WEIGHTS=/path/to/depth_anything_*.pth
export FISHSPEED_ALLOW_REMOTE=0main_enhanced_complete.pydefaults tomodel_path="weights/best.pt"; pass--modelif the file is not available.- If Depth-Anything or its weights are unavailable, the pipeline falls back to a simplified depth mode; outputs are still produced, but 3D accuracy is reduced.
- Whether CBAM or SE is used depends on the loaded model weights;
--attention cbam|seis mainly for logging. - If you load CBAM weights, your
ultralyticsversion must include the CBAM module or you may see "CBAM not found" errors.
Helper scripts for Depth-Anything setup:
scripts/download_depth_weights.py: download depth weights (requires network access).scripts/setup_depth_anything.py: prepare environment dependencies.scripts/fix_depth_model.py: compatibility fix helper.