{"id":18768106,"url":"https://github.com/tyler-hilbert/cat_vs_dog_image_classification","last_synced_at":"2025-07-06T23:34:22.677Z","repository":{"id":88114145,"uuid":"320240777","full_name":"Tyler-Hilbert/Cat_vs_Dog_Image_Classification","owner":"Tyler-Hilbert","description":"Compares KNN, HOG/SVM and CNN for classifying images as cat or dog","archived":false,"fork":false,"pushed_at":"2021-10-19T03:00:20.000Z","size":1047,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-29T07:13:36.168Z","etag":null,"topics":["computer-vision"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Tyler-Hilbert.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":"2020-12-10T10:45:29.000Z","updated_at":"2024-07-09T04:00:08.000Z","dependencies_parsed_at":"2023-05-18T08:31:08.870Z","dependency_job_id":null,"html_url":"https://github.com/Tyler-Hilbert/Cat_vs_Dog_Image_Classification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyler-Hilbert%2FCat_vs_Dog_Image_Classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyler-Hilbert%2FCat_vs_Dog_Image_Classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyler-Hilbert%2FCat_vs_Dog_Image_Classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyler-Hilbert%2FCat_vs_Dog_Image_Classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tyler-Hilbert","download_url":"https://codeload.github.com/Tyler-Hilbert/Cat_vs_Dog_Image_Classification/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239671417,"owners_count":19677873,"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","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":["computer-vision"],"created_at":"2024-11-07T19:10:53.945Z","updated_at":"2025-02-19T14:13:06.360Z","avatar_url":"https://github.com/Tyler-Hilbert.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cat vs Dog Image Classifier\nCompares the accuracy of KNN, HOG/SVM and CNN for classifying an image as cat or dog.  \n\n# Conclusion  \nA CNN is the best approach to this dataset with a 91% accuracy.  \nNeither the KNN or HOG/SVM performed well enough to be considered useable for this dataset as they barely did better than a random guess.  \n\n# Analysis of Each Algorithm (best to worst)\n## CNN (Convolutional Neural Network)\nCNN written using Pytorch.   \n### CNN Results\nAlexNet: 91%  \n11 Convolutional Layers + ReLU + Batch Normalization: 89.5%  \n6 Convolutional Layers + ReLU + Batch Normalization: 83%  \n3 Convolutional Layers + ReLU + Batch Normalization: 81%  \n\n![CNN Training Graph](https://raw.githubusercontent.com/Tyler-Hilbert/Cat_vs_Dog_Image_Classification/main/CNN_Training_Accuracy_Plot.png)\n\n### CNN Setup Instructions\n[put the train data set from this link - https://www.kaggle.com/c/dogs-vs-cats/data - ](https://www.kaggle.com/c/dogs-vs-cats/data) into the following directories:  \ndataYouTubeFormat/train/cat  \ndataYouTubeFormat/train/dog  \ndataYouTubeFormat/test/cat  \ndataYouTubeFormat/test/dog  \nSome hyperparameters can be set under `Constants` in CNN_CatVsDog.py, while others will need to be set in the `ConvNN` class or in the following lines of code:  \n```\ntransformer = transforms.Compose([\n    transforms.Resize( (150,150) ), # Is this the correct size?\n    transforms.RandomHorizontalFlip(),\n    transforms.ToTensor(),\n    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))\n])\n```\n\n## HOG / SVM (Histogram of Oriented Gradients / Linear SVM)  \nHOG / SVM written using scikit-learn.  \n### HOG / SVM Results\nThe accuracy of the HOG / SVM algorithm consistently got around a 60% accuracy even with many different hyperparameters and training set sizes.  \n### KNN Setup Instructions\n[put the train data set from this link - https://www.kaggle.com/c/dogs-vs-cats/data - into the directory data/](https://www.kaggle.com/c/dogs-vs-cats/data)  \nHyperparameters for the SVM can be set under `Constants` in HOG-CatDog.py and the following 2 lines for the bin size:  \n```\nfd = fd.round(1)\n...\nfor i in np.arange(0, 1.1, 0.1).round(1).tolist():\n```\n\nHyperparameters for the HOG need to be set in the following line of code within HOG-CatDog.py:  \n`fd, hogImage = hog(image, orientations=64, pixels_per_cell=(32, 32), cells_per_block=(1, 1), visualize=True, multichannel=True)`\n\n## KNN (k-nearest neighbors)\nKNN written from scratch using Python3.  \n### KNN Results\nThe accuracy was around 50%-60%.  \nKNN was tested for k = 3, 7, 11, 23, 45, 101, 201 and 301.  \n### KNN Setup Instructions\n[put the train data set from this link - https://www.kaggle.com/c/dogs-vs-cats/data - into the directory data/](https://www.kaggle.com/c/dogs-vs-cats/data)  \nHyperparameters can be set under `Constants` in knn_catVsDog.py  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler-hilbert%2Fcat_vs_dog_image_classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyler-hilbert%2Fcat_vs_dog_image_classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler-hilbert%2Fcat_vs_dog_image_classification/lists"}