Loading repository data…
Loading repository data…
ftm-zarin / repository
Implements Neural Style Transfer with PyTorch and explores CNN fundamentals by building a convolutional layer from scratch.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This repository contains a Jupyter Notebook for a computer vision project, part of the "Introduction to Machine Learning" course. The project explores two key concepts:
Course: Introduction to Machine Learning Instructor: Dr. Fatemeh Mirsalehi TA: Amirhossein Razlighi
This project requires Python and several data science libraries. A virtual environment is recommended.
Clone the repository:
git clone [https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git](https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git)
cd YOUR_REPOSITORY
Create and activate a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install the required packages: The notebook uses the following packages. You can install them via pip:
pip install torch torchvision numpy matplotlib Pillow requests
Note: The notebook also uses torchsummary in one cell for model visualization. You may need to install it separately if you wish to run that specific cell:
pip install torchsummary
The entire project is contained in the mian.ipynb Jupyter Notebook.
jupyter lab
mian.ipynb and run the cells sequentially to see the implementation and results.The notebook is divided into two main sections.
This section focuses on understanding the fundamental mechanics of a convolutional layer.
MyConv Class: A custom class built with NumPy that implements the and propagation for a 2D convolution.forwardbackwardrel_error function).MyConv class is used to apply standard image processing filters (Grayscale, Sobel X/Y edge detection, Gaussian Blur) to sample images, demonstrating the effect of different convolution kernels.This section implements the Neural Style Transfer technique, as described by Gatys et al.
torchvision) to capture image content and style.ContentLoss module is defined, which computes the Mean Squared Error (MSE) between the feature maps of the content image and the generated image.StyleLoss module is defined to compute the MSE between the Gram matrices of the style image's feature maps and the generated image's feature maps. This captures the correlations between features, representing texture and style.LBFGS optimizer is used to iteratively update a target image (initialized as a clone of the content image). The optimizer works to minimize a weighted sum of the total content loss and total style loss, gradually blending the content of one image with the style of another.The primary output of the project is the generated image from the Neural Style Transfer process. The notebook also plots the loss curves over the optimization iterations.
| Content Image | Style Image |
|---|---|
The final image is generated in Cell 73 after the optimization loop.