How ioannispol/underwatergan works
Main Components
• Data Preparation and Preprocessing
– Components: The data is expected to be organized in directories (e.g., "trainA", "trainB", "testA", "testB").
– Relevant directories: UnderWaterGAN_pytorch/preprocess, UnderWaterGAN_pytorch/data, and UnderWaterGAN_pytorch/datasets.
– Functionality: Creating directories, splitting and renaming datasets, and preparing image data for input to the network.
• Model Architecture and Training
– Components: This contains various models (CycleGAN, Pix2Pix, etc.) along with a number of training options and scripts.
– Relevant directories: UnderWaterGAN_pytorch/models (cycle_gan_model.py, pix2pix_model.py, etc.), UnderWaterGAN_pytorch/train.py, UnderWaterGAN_pytorch/options (train_options.py, test_options.py), and scripts (train_cyclegan.sh, train_pix2pix.sh).
– Flow: The training phase starts with loading the prepared dataset, then the model is initialized, trained using the specified options, and the network states are saved in the results directory.
• Testing / Inference Pipeline
– Components: Testing means running a forward pass through the model to generate image translations.
– Relevant files: UnderWaterGAN_pytorch/test.py and corresponding scripts (test_cyclegan.sh, etc.).
– Flow: Loading test data → applying the appropriate model (cycle_gan or test variant) → generating and storing output (e.g., HTML reports under results).
• Evaluations
– Components: The project evaluates model performance using metrics like SSIM and FID.
– Relevant directories: UnderWaterGAN_pytorch/evaluations (SSIM-py, pytorch-fid).
– Functionality: Contains separate evaluation scripts, test images, and configurations to assess the quality of image translations.
• Utility and Visualization
– Components: Helper functions and utilities for image processing, visual logging, and HTML visualization.
– Relevant directories: UnderWaterGAN_pytorch/util (html.py, image_pool.py, visualizer.py) and the integration of visdom for plotting training progress.
• Deployment / CI/CD and Containerization
– Components: Dockerfile, docker-compose files, as well as GitHub workflows are present.
– Functionality: These support containerized deployment, continuous integration (via GitHub workflows with docker-image.yml, docker-publish.yml, pylint.yml), and environment setup.
Relationships & Data Flow
• The Data Loader (via UnderWaterGAN_pytorch/data and datasets) feeds images into the Model.
• The Model (implemented in UnderWaterGAN_pytorch/models) connects with both Training (train.py) and Testing (test.py) modules.
• Both train and test modules use configuration options (from UnderWaterGAN_pytorch/options).
• Utilities (UnderWaterGAN_pytorch/util) are employed across data, training, and visualization.
• The Evaluation modules run once the model is trained to compute scores (SSIM, FID) with their own internal pipelines.
• Scripts in the “scripts” folder encapsulate the command-line logic to kick off training, testing, and pre-run validations.
• CI/CD workflows and container orchestration with Docker/Docker Compose facilitate deployment / experimentation cycles.
Architectural Patterns and Design Principles
• Separation of Concerns – Each major function (preprocessing, training, testing, evaluation) is isolated in its own directory.
• Modularity – Different models (CycleGAN, Pix2Pix, etc.) and datasets are implemented as separate modules to allow extensibility.
• Configuration Management – Training and testing options are externalized in “options”, supporting flexible experiments.
• Reusability – Utility functions and scripts encapsulate common tasks like image management and logging.