{"id":25486621,"url":"https://github.com/sszukala/trianglepixels","last_synced_at":"2026-05-18T15:35:30.201Z","repository":{"id":277245879,"uuid":"931808719","full_name":"sszukala/TrianglePixels","owner":"sszukala","description":"The results obtained from the experiments are compared and analyzed to determine the effectiveness of using triangle pixels in image classification tasks. ","archived":false,"fork":false,"pushed_at":"2025-02-14T23:59:53.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T12:05:19.241Z","etag":null,"topics":["cnn-for-visual-recognition","cnn-model","deep-neural-networks","deeplearning","image","image-classification","image-processing","image-recognition","imageenhancement","machine-learning","pixels","python-script","rnn-model","tensorflow","triangles"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sszukala.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-02-12T22:19:16.000Z","updated_at":"2025-02-14T23:59:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"ad10e89f-4dca-4ae2-88e0-1646d4fe242c","html_url":"https://github.com/sszukala/TrianglePixels","commit_stats":null,"previous_names":["sszukala/trianglepixels"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sszukala/TrianglePixels","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sszukala%2FTrianglePixels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sszukala%2FTrianglePixels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sszukala%2FTrianglePixels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sszukala%2FTrianglePixels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sszukala","download_url":"https://codeload.github.com/sszukala/TrianglePixels/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sszukala%2FTrianglePixels/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266586905,"owners_count":23952205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cnn-for-visual-recognition","cnn-model","deep-neural-networks","deeplearning","image","image-classification","image-processing","image-recognition","imageenhancement","machine-learning","pixels","python-script","rnn-model","tensorflow","triangles"],"created_at":"2025-02-18T19:21:26.943Z","updated_at":"2026-05-18T15:35:30.172Z","avatar_url":"https://github.com/sszukala.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrianglePixels\nThe results obtained from the experiments are compared and analyzed to determine the effectiveness of using triangle pixels in image classification tasks. \n\n# Triangle Pixel Model for Image Classification\n\n## Overview\n\nThis repository explores the concept of utilizing triangle pixels instead of traditional square pixels for image classification tasks. The primary goal is to investigate the potential benefits of this alternative pixel structure in terms of memory efficiency and visual perception capabilities. The project uses PyTorch to implement and train convolutional neural networks (CNNs) with both square and triangle pixel representations.\n\n## Key Features\n\n* **Triangle Pixel Representation:** Introduces a custom layer (`TrianglePixelSplitter`) to split square pixels into two triangular pixels, effectively doubling the number of channels in the input data.\n* **Teacher-Student Architecture:** Employs a knowledge distillation technique, where a larger, more complex teacher model (square pixel-based) guides the learning of a smaller, more efficient student model (triangle pixel-based).\n* **Memory Efficiency:** Analyzes the memory usage of both models to compare the storage requirements of triangle and square pixel representations.\n* **Visual Perception:** Evaluates the performance of both models on FashionMNIST and CIFAR-10 datasets to assess the impact of pixel structure on visual perception tasks.\n\n## Methodology\n\n### Data Preprocessing:\n\n* **FashionMNIST:** Images are transformed to tensors, followed by Gaussian blur, median blur, and histogram equalization to enhance image features and robustness.\n* **CIFAR-10:** Images are transformed to tensors and normalized to a specific range for consistency and better training performance.\n\n### Model Training:\n\n* **Teacher Model (Square Pixel):** A CNN with two convolutional layers, batch normalization, max pooling, and two fully connected layers is used as the teacher model.\n* **Student Model (Triangle Pixel):** A smaller CNN architecture with one convolutional layer, batch normalization, max pooling, and two fully connected layers is used as the student model.\n* **Knowledge Distillation:** The student model is trained using knowledge distillation, where it learns from the teacher model's predictions (logits) rather than just ground truth labels.\n* **Early Stopping:** Implemented to prevent overfitting and to achieve optimal model performance.\n\n### Evaluation Metrics:\n\n* **Accuracy:** Measures the percentage of correctly classified images.\n* **Precision:** Indicates the proportion of correctly predicted positive instances.\n* **Recall:** Represents the proportion of actual positive instances correctly identified.\n* **F1 Score:** Provides a harmonic mean of precision and recall, offering a balanced performance evaluation.\n\n## Results and Analysis\n\nThe results obtained from the experiments are compared and analyzed to determine the effectiveness of using triangle pixels in image classification tasks. The key findings are summarized as follows:\n\n* **Memory Efficiency:** The student model (triangle pixel) demonstrates significantly reduced memory footprint compared to the teacher model (square pixel) due to its smaller architecture.\n* **Visual Perception:** The student model's performance on the FashionMNIST and CIFAR-10 datasets, though slightly lower in terms of accuracy, indicates the potential of triangle pixels in learning discriminative features.\n* **Batch Processing:** Triangle Pixel Model shows faster batch processing time in comparison to Square Pixel Model.\n* The TPM uses triangle pixels instead of traditional square pixels to achieve better efficiency and performance compared to conventional CNNs.\n\nHere are some key points about the TPM:\n\nTriangle Pixel Structure: The TPM splits each square pixel into two triangles using a custom layer called TrianglePixelSplitter. This creates a more detailed representation of the image.\n\nEfficient Architecture: The TPM is designed to be more efficient than conventional CNNs by reducing the number of parameters and computations. A smaller student model (StudentNet) is trained with knowledge distillation from a larger teacher model (Net).\n\nImproved Visual Perception: The triangle pixel structure enhances the model's ability to perceive edges and contours, leading to better performance on image classification tasks.\n\nMemory Efficiency: The TPM uses fewer parameters, resulting in lower memory usage compared to conventional CNNs.\n\nThe code includes experiments on two datasets: FashionMNIST and CIFAR-10. The results demonstrate that the TPM achieves comparable or better accuracy with significantly lower memory usage and faster inference time.\n\nThe Triangle Pixel Model (TPM) and its benefits in terms of memory efficiency, visual perception, and computational performance can be applied to various real-life systems where image classification is a crucial task. Some potential applications include:\n\nEmbedded Systems: The TPM's ability to reduce memory usage makes it an attractive solution for embedded systems, such as:\nSmart home devices (e.g., security cameras, doorbells)\nWearable devices (e.g., fitness trackers, smartwatches)\nAutonomous vehicles (e.g., navigation systems, object detection)\n\nEdge Computing: The TPM's efficiency in terms of computational performance and memory usage makes it suitable for edge computing applications:\n\nIoT devices (e.g., sensors, actuators) that require real-time processing\n\nSmart cities infrastructure (e.g., traffic management, public safety)\n\nReal-Time Systems: The TPM's ability to process images in real-time can be applied to various systems:\nSurveillance systems (e.g., monitoring, object detection)\n\nMedical imaging systems (e.g., image processing, disease diagnosis)\n\nRobotics and Autonomous Systems: The TPM's visual perception capabilities make it suitable for robotics and autonomous systems:\nRobotics (e.g., object recognition, navigation)\n\nDrones and unmanned aerial vehicles (UAVs) (e.g., object detection, tracking)\n\nMobile Devices: The TPM's efficiency in terms of memory usage and computational performance can be applied to mobile devices:\nSmartphones (e.g., image processing, object recognition)\nTablets and laptops (e.g., image editing, object detection)\n\nThese are just a few examples of the many potential applications of the Triangle Pixel Model. The TPM's benefits in terms of memory efficiency, visual perception, and computational performance make it an attractive solution for various real-life systems where image classification is a crucial task.\n\n## Conclusion and Future Work\n\nThe results highlight the trade-offs between memory efficiency, visual perception, and computational performance when using triangle pixels instead of traditional square pixels in CNNs. Future work might involve exploring more complex image datasets, optimizing the triangle pixel model architecture, and investigating potential benefits for real-world applications such as edge devices or embedded systems where memory constraints are a significant consideration.\n\n## Getting Started\n\n1. Clone the repository: `git clone (https://github.com/sszukala/TrianglePixels)`\n2. Install necessary packages: `pip install torchvision tqdm scipy scikit-learn psutil`\n3. Run the notebook: `jupyter notebook`\n\n## Contribution Guidelines\n\nIf you'd like to contribute to this project, please feel free to fork the repository and submit pull requests. Any improvements or new ideas are welcome!\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Contact\nIts my Birthday! Yeah me. I am tired, you are getting this as is. \nFor any inquiries, please contact [sszukala at gmail.com].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsszukala%2Ftrianglepixels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsszukala%2Ftrianglepixels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsszukala%2Ftrianglepixels/lists"}