I'd be happy to help you set up the HierarchicalMask2Former repository to train the model using your custom data. Since you mentioned that the README might be inaccurate, we'll go through the general steps to set up the repository and train the model, and I'll provide guidance on how to adapt it to your custom data.
Step 1: Clone the repository and install dependencies
Clone the repository using the following command:
git clone https://github.com/madeleinedarbyshire/HierarchicalMask2Former.git
Then, navigate into the cloned repository:
cd HierarchicalMask2Former
Install the required dependencies using pip:
pip install -r requirements.txt
Step 2: Prepare your custom data
To train the model using your custom data, you'll need to prepare your dataset in a format compatible with the repository. The repository uses the COCO dataset format, so you'll need to convert your data to this format.
Create a new directory for your custom data, e.g., custom_data. Inside this directory, create the following subdirectories:
custom_data/
train/
images/
annotations.json
val/
images/
annotations.json
Place your training images in the train/images directory and your validation images in the val/images directory. Create annotations.json files in both the train and val directories, containing the annotations for your data in the COCO format.
Step 3: Update the dataset configuration
In the configs directory, you'll find configuration files for different datasets. Create a new configuration file for your custom dataset, e.g., custom_dataset.yaml. Update the dataset section to point to your custom data directory:
dataset:
train:
img_dir: /path/to/custom_data/train/images
ann_file: /path/to/custom_data/train/annotations.json
val:
img_dir: /path/to/custom_data/val/images
ann_file: /path/to/custom_data/val/annotations.json
Step 4: Update the model configuration
In the configs directory, you'll find configuration files for different models. Update the model section in the configuration file you want to use (e.g., mask2former.yaml) to point to your custom dataset configuration file:
model:
...
dataset: custom_dataset
Step 5: Train the model
Run the training script using the following command:
python tools/train.py --config-file configs/mask2former.yaml
This will start training the model using your custom data.
Additional tips
- Make sure to update the
num_classes parameter in the model section of the configuration file to match the number of classes in your custom dataset.
- If you're using a different image size or aspect ratio, you may need to update the
image_size and aspect_ratio parameters in the dataset section of the configuration file.
- You can monitor the training process using tools like TensorBoard or Weights & Biases.
If you encounter any issues or have further questions, feel free to ask, and I'll do my best to help you troubleshoot or provide more guidance.