Skip to content

chenyizi65/FishSpeed

Repository files navigation

FishSpeed Core Source

Directory Structure

  • 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/val
    • labels/train, labels/val
    • shiziyu.yaml (dataset config)
    • Full path: D:\project\shizhiyu\FishSpeed_core_src\merged_dataset

Package Includes / Excludes

Included

  • Core Python source for detection, depth estimation, speed calculation, and visualization.
  • Required configs and helper scripts.
  • The dataset in merged_dataset/ (see path above).

Environment Setup

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.txt

Running

Option A: Use Default YOLO Weight Location

Place YOLO weights at weights/best.pt:

python main_enhanced_complete.py --input /path/to/video.mp4

Option B: Provide Weights Explicitly (Recommended)

python main_enhanced_complete.py --input /path/to/video.mp4 --model /path/to/best.pt

Common arguments (see --help for the full list):

  • --input/-i: input video path
  • --output/-o: output directory (default enhanced_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)

Weight Placement Suggestions

  • 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=0

Important Notes

  • main_enhanced_complete.py defaults to model_path="weights/best.pt"; pass --model if 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.

CBAM / SE Attention Notes

  • Whether CBAM or SE is used depends on the loaded model weights; --attention cbam|se is mainly for logging.
  • If you load CBAM weights, your ultralytics version must include the CBAM module or you may see "CBAM not found" errors.

scripts/ Notes

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages