{"id":26025324,"url":"https://github.com/preethi2805/image_processing_cnn_using_pytorch","last_synced_at":"2026-05-13T20:35:00.733Z","repository":{"id":278491559,"uuid":"935797856","full_name":"Preethi2805/Image_Processing_CNN_using_PyTorch","owner":"Preethi2805","description":"📸 Image Processing \u0026 CNN Classification with PyTorch This project explores feature extraction in image processing, pooling operations, and CNN-based classification using PyTorch and the load_digits dataset.","archived":false,"fork":false,"pushed_at":"2025-02-20T03:51:41.000Z","size":319,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T06:39:49.316Z","etag":null,"topics":["convolutional-neural-networks","kernel","pooling","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Preethi2805.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-20T03:17:02.000Z","updated_at":"2025-02-20T05:37:56.000Z","dependencies_parsed_at":"2025-02-20T04:25:03.137Z","dependency_job_id":"aa2134cb-3bbc-4eb7-92b7-dae53f922cb2","html_url":"https://github.com/Preethi2805/Image_Processing_CNN_using_PyTorch","commit_stats":null,"previous_names":["preethi2805/-image_processing_cnn_using_pytorch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Preethi2805/Image_Processing_CNN_using_PyTorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preethi2805%2FImage_Processing_CNN_using_PyTorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preethi2805%2FImage_Processing_CNN_using_PyTorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preethi2805%2FImage_Processing_CNN_using_PyTorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preethi2805%2FImage_Processing_CNN_using_PyTorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Preethi2805","download_url":"https://codeload.github.com/Preethi2805/Image_Processing_CNN_using_PyTorch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preethi2805%2FImage_Processing_CNN_using_PyTorch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32999515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convolutional-neural-networks","kernel","pooling","pytorch"],"created_at":"2025-03-06T13:35:40.509Z","updated_at":"2026-05-13T20:35:00.716Z","avatar_url":"https://github.com/Preethi2805.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"### **README.md**  \n\n# 🖼️ **Feature Extraction \u0026 CNN Classification with PyTorch**  \n\n## 📌 **Overview**  \nThis repository contains five tasks designed to explore **image feature extraction, pooling, CNN training, and model comparison** using PyTorch and scikit-learn.  \n\n### 🔍 **Tasks Overview:**  \n✅ **Task 1:** Implement convolutional filters for **edge detection, blurring, and identity mapping**.  \n✅ **Task 2:** Apply **max-pooling \u0026 average-pooling** to understand spatial resolution impact.  \n✅ **Task 3:** Build a **CNN from scratch** using PyTorch for digit classification.  \n✅ **Task 4:** Train the CNN with **SGD optimization** and monitor loss trends.  \n✅ **Task 5:** Compare CNN vs **Support Vector Classifier (SVC)** on classification performance.  \n\n---\n\n## 🏗️ **Task 1: Implementing Convolutional Filters**  \n\nThis task explores **image feature extraction** using **custom convolutional filters** implemented in PyTorch.  \n\n### 🔬 **Implemented Filters:**  \n| **Kernel Type**      | **Purpose**                      |\n|----------------------|---------------------------------|\n| **Horizontal Edge**  | Detects horizontal edges        |\n| **Vertical Edge**    | Detects vertical edges          |\n| **Diagonal Edge 1**  | Detects main diagonal edges     |\n| **Diagonal Edge 2**  | Detects anti-diagonal edges     |\n| **Blurring Kernel**  | Smoothens the image            |\n| **Identity Kernel**  | Leaves the image unchanged     |\n\n### 🏗 **Implementation Details:**  \n- Define **custom convolution kernels** in PyTorch.  \n- Implement `corr2d()` function to **perform 2D convolution** manually.  \n- Use **padding (2 pixels)** to handle edge detection at boundaries.  \n- Apply each filter to **5 sample images** and visualize the results.\n\n### 📷 **Example Visualization:**  \n💡 **Before \u0026 After Applying Filters**  \n\n| ![original](task1.png) | \n\n---\n\n## 🔄 **Task 2: Pooling Operations**  \n\nTo understand the impact of pooling on feature maps, we:  \n- Implement `pool2d()` for **Max Pooling** \u0026 **Average Pooling**.  \n- Apply it to **feature maps** from Task 1.  \n- Observe how pooling **reduces resolution but retains key features**.  \n\n### 🏗 **Implementation Details:**  \n✅ Supports **Max-Pooling** \u0026 **Average-Pooling**  \n✅ Customizable **pool size** parameter  \n✅ Visualizes pooled feature maps  \n\n### 📉 **Dimensionality Reduction Example:**  \n```\nBefore Pooling: (8, 8)\nAfter Pooling (2x2): (4, 4)\n```\n\n📷 **Example Pooled Image Output:**  \n| Original Feature Map | Max-Pooled (2x2) | Avg-Pooled (2x2) |\n|----------------------|------------------|------------------|\n| ![original](task2.png) |\n\n---\n\n## 🤖 **Task 3: Building a CNN in PyTorch**  \n\nThis task involves implementing a **Convolutional Neural Network (CNN)** from scratch.  \n\n### **🛠 Network Architecture:**  \n| Layer Type | Filters/Neurons | Kernel Size | Activation |\n|-----------|---------------|-------------|------------|\n| Conv1 | 8 | 3x3 | ReLU |\n| Conv2 | 3 | 3x3 | ReLU |\n| Max Pooling | - | 2x2 | - |\n| Fully Connected (FC1) | 120 | - | ReLU |\n| Fully Connected (FC2) | 84 | - | ReLU |\n| Output Layer | 10 | - | Softmax |\n\n---\n\n## 🎯 **Task 4: Training the CNN on load_digits Dataset**  \n\n- **Preprocess the dataset** by normalizing pixel values **(0 to 1)**.  \n- **Split the dataset** (40% training, 40% validation, 20% test).  \n- **Train the CNN** using **SGD optimizer (lr=0.001, momentum=0.9)**.  \n- **Train for 1000 epochs**, monitoring **training \u0026 validation loss**.  \n- **Checkpointing:** Save the best model when **validation loss improves**.  \n- **Use tqdm progress bar** to track training.\n\n📉 **Loss Trends Over Time:**  \n```\nEpoch 1000: Accuracy = 93.89%\n```\n\n📈 **Loss Graphs:**  \n![loss_graph](task4.png)  \n\n---\n\n## ⚖️ **Task 5: Comparing CNN vs SVC**  \n\n- **Train an SVM model using sklearn's SVC** with `gamma=0.001`.  \n- **Flatten images** (treating pixels as independent features).  \n- **Compare CNN and SVC performance on the test set**.  \n\n### 📊 **Model Comparison Results:**  \n| Model | Test Accuracy |\n|-------|--------------|\n| **CNN** | **93.89%** |\n| **SVC (gamma=0.001)** | **97.04%** |\n\n### 📝 **Observations \u0026 Improvements:**  \n**The SVM model is performing better compared to the CNN model.**\n\n---\n\n## 🤝 **Contributing**  \nFeel free to **open an issue** or **submit a pull request** if you have improvements or suggestions!\n\n---\n\n### ✅ **Let me know if you need any modifications! 🚀**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreethi2805%2Fimage_processing_cnn_using_pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreethi2805%2Fimage_processing_cnn_using_pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreethi2805%2Fimage_processing_cnn_using_pytorch/lists"}