FYP-Net is my university graduation project. It is based on the current hybrid attention mechanism, where I designed the PHAM module by combining channel attention and spatial attention in a parallel manner to enhance the model's segmentation performance.
Below is the architecture of the model I designed, which consists of several modules:
PHAM module architecture The ECAB and ESAB architecture diagrams are shown below For more details, you can refer to the code in the following files:Below are the results of my model evaluation. It turns out that our model has achieved relatively good results
Below is the table of contents of my project, along with the associated comments.
FYP/
├── Block # Contains utility functions and core components of the project.
├── configs # Configuration files for model and experiment settings.
└── config.yaml # ** KEY config**
├── Evaluate # Scripts for model evaluation and performance assessment.
├── model # Contains model definitions and architecture setups.
├── model_loader.py # Control all model loading.
├── FYPNet # Our model path
└── <Other models..>
├── LoadData # Scripts for loading and preprocessing data.
├── data.py # The data loading controller, which controls whether all datasets are loaded or not
└── <Other code..> # Other code, containing different dataset loading classes
├── scripts # Small project maintenance scripts.
├── tests # Synthetic tests, no real dataset required.
├── params # The training weights save the path.
├── main.py # Unified command-line entrance.
├── test_model.py # Script for testing the model.
├── todoList.py # All of my tasks during the development of the project.
├── train_model.py # Script for training the model.
├── requirements.txt # File listing the required Python packages for the project.
└── README.md # Documentation file with setup instructions and project details.
#!/bin/bash
git clone git@github.com:scybl/FYP.git
cd FYP
# Define the directory names
DIRS=("saved_images" "params")
# Loop through the directory names
for DIR_NAME in "${DIRS[@]}"; do
# Check if the directory exists
if [ ! -d "$DIR_NAME" ]; then
# Create the directory
mkdir "$DIR_NAME"
echo "Directory '$DIR_NAME' has been created."
else
echo "Directory '$DIR_NAME' already exists."
fi
done
# Create the Conda environment
echo "Creating a Conda environment named 'FYPNet' with Python 3.10..."
conda create -n FYPNet python=3.10 -y
# Activate the newly created environment
echo "Activating the Conda environment 'FYPNet'..."
conda activate FYPNet
# Install required packages from requirements.txt
if [ -f "requirements.txt" ]; then
echo "Installing dependencies from requirements.txt..."
pip install -r requirements.txt
else
echo "requirements.txt file not found!"
fiIn our training framework, we have prepared three datasets: ISIC2018, CVC-ClinicDB and Kvasir-SEG. You can click the links to visit the official websites and download the datasets.
If you wish to download the dataset we have prepared, you can click the link below to configure it directly:Google Drive
If you need to change the path in the project after configuring the path, you need to modify it change the config.yaml file to control the dataset path
After downloading the dataset, we need to split it into three parts: train, val, and test. Then change the dataset setting in config.yaml.
The real datasets and saved weights are intentionally not stored in this repository. This keeps the code clean and avoids pushing large files. The paths are ignored by .gitignore, and the code tests use synthetic samples instead.
You can also use config.example.yaml as a clean starting point for another machine.
Because of the complete setup, you can use the unified entrance:
python main.py list
python main.py train --model bnet --dataset isic2018
python main.py test --model bnet34 --dataset isic2018The original experiment scripts are still available:
python train_model.py
python test_model.pyIf you want to use the pre-trained model we have prepared, you can obtain it through the link below: Google Drive
If you want the ResNet encoder in bnet34 to download ImageNet-pretrained weights, set this option in config.yaml:
model:
pretrained_encoder: trueBy default it is set to false, so the project can be checked offline without downloading weights.
The repository includes synthetic tests for the data loaders, segmentation metrics, learning-rate scheduler, and core model loading. They do not require ISIC2018, CVC-ClinicDB, Kvasir-SEG, Synapse, or saved .pth weights.
python -m unittest discover -s testsOr run the full lightweight project check:
python scripts/check_project.py


