DarkVision is a deep learning project focused on image classification using PyTorch and ResNet18 architecture. The project implements various loss functions and provides tools for training and testing image classification models.
DarkVision/
├── dataset/ # Directory containing training and validation datasets
├── model/ # Directory for model-related files
├── final_results_NV/ # Directory for storing final results
├── checkpoint.pth # Saved model checkpoint
├── training_output.txt # Training process output
├── utils.py # Utility functions and data loading
├── test.py # Testing script
├── test_base.py # Base testing functionality
├── train.py # Training script
├── loss.py # Custom loss function implementations
├── model.py # Model architecture definition
├── data.ipynb # Jupyter notebook for data analysis
└── LICENSE # Project license file
- ResNet18-based image classification
- Multiple loss function options:
- Focal Loss
- Mean Squared Error (MSE)
- Cross Entropy Loss
- Custom dataset handling
- Training and validation pipeline
- Model checkpointing
- GPU support (if available)
- Python 3.x
- PyTorch
- torchvision
- pandas
- numpy
- PIL (Python Imaging Library)
- Clone the repository:
git clone https://github.com/michaelborek/DarkVision.git
cd DarkVision- Install the required dependencies:
pip install torch torchvision pandas numpy pillowThe project expects datasets in CSV format with the following structure:
filepath: Path to the image filelabel: Class label for the image
Place your training and validation datasets in the dataset/ directory:
train_dataset.csvval_dataset.csv
To train the model, use the following command:
python train.py --loss [loss_type]Available loss types:
focal: Focal Lossmse: Mean Squared Errorcross_entropyorce: Cross Entropy Loss
Example:
python train.py --loss focalTo test the model, use:
python test.pyThe project uses a ResNet18 architecture with the following modifications:
- Pretrained weights from ImageNet
- Customizable number of output classes
- Modified final fully connected layer
- Number of epochs: 8
- Batch size: 128
- Learning rate: 0.001
- Optimizer: Adam
Training progress and results are saved in:
training_output.txt: Training metrics and progresscheckpoint.pth: Model weights and training statefinal_results_NV/: Directory containing final evaluation results
This project is licensed under the terms specified in the LICENSE file.
Contributions are welcome! Please feel free to submit a Pull Request.
For any questions or suggestions, please open an issue in the repository.