This project simplifies the process of data labeling by automating the creation of color masks using Sam2 prompts. Users can manually correct errors in the generated masks, and Sam2 further automates the masking process to produce ground truth values for ResNet training.
-
cd Sam2Masks -
Sam2 Installation: git clone https://github.com/facebookresearch/sam2.git && cd sam2
-
Install Sam2: pip install -e . Note: If you encounter errors, check your network speed or try downloading the package independently.
-
Download Checkpoint:
cd checkpoints/wget https://dl.fbaipublicfiles.com/segment_anything_2/092824/sam2.1_hiera_large.pt -
Set config file
configs/sam2.1/sam2.1_hiera_l.yaml -
Create JPG Folder:
python generate_frames_and_prompts.py -
Run Video Masking:
python generate_sam2_masks.py -
Train ResNet:
cd resnet/python train.py -
Run Inference:
cd resnet/python inference.py
Summary of Outputs:
data/frames_and_prompts: Contains extracted JPG images from the video and prompts for each frame.data/sam2_masked_frames: Contains masked images with pixel values of 0 and 1.checkpoints/mask_rcnn_model.onnx: Contains the trained Mask R-CNN model.