Automated segmentation and bounding box labeling pipeline using SAM3. This automatically generates normalized YOLO-pose keypoint data for underwater gate detection.
-
Compute Environment: This pipeline supports CUDA, MPS, and CPU, but running it on a GPU cluster is highly recommended for optimal inferencing speeds
-
Hugging Face Authentication: You will need a valid Hugging Face access token to download the model weights. Run the following command in your terminal and follow the prompts to paste your token:
huggingface-cli login1.
Install uv once per machine:
curl -LsSf https://astral.sh/uv/install.sh | sh(or brew install uv on macOS).
2. Clone this auto-labeling repository and navigate into it:
git clone https://github.com/berkeleyauv/auto_data_labeling.git
cd auto_data_labeling3.
Create the virtual environment pinning Python 3.11, which creates a .venv/ directory:
uv venv --python 3.11
source .venv/bin/activate4. Install the necessary libraries from the requirements file:
# Install pytorch with CUDA support
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
# Install the other packages
uv pip install -r requirements.txt1.
Inside your cloned auto_data_labeling repository, create a directory to hold your raw images:
mkdir -p data/raw_images2. Place all the raw dataset images you want to annotate (must be .png, .jpg, or .jpeg) into this folder.
Submit the inference script to the Slurm scheduler:
sbatch submit_inference.sh--input_diris where to pull the images from--output_diris where to save the raw_predictions.json file to
To see live outputs and track inference progress:
# Check your job ID
squeue -u $USER
# Replace 123456 with your actual job ID
tail -f slurm-123456.out1. Launch the Gradio UI
bash launch_QA.sh
--json_pathis where the generated predictions are--image_diris where the raw images are for rendering
2. Review the annotations:
- Click the public gradio.live link generated in your terminal to open the UI in your web browser.
- Review the predicted corners (cyan dots) on the underwater gate frame.
- If a corner is incorrect, select the corresponding radio button (e.g., TL for Top-Left) and click on the image to manually move the point.
- Click Accept & Export to save the frame and move to the next image.
- When finished, a completion screen will appear.
- A ./data/labels directory will have been created
- Each image has a corresponding .txt file containing the normalized keypoints and bounding boxes of the gate