{"id":23224107,"url":"https://github.com/javipzv/handwritten-digits-classifier","last_synced_at":"2026-04-29T19:31:14.633Z","repository":{"id":233364162,"uuid":"633161317","full_name":"javipzv/handwritten-digits-classifier","owner":"javipzv","description":"It allows the user to draw a digit on a canvas and classify the digit using a pre-trained TensorFlow model.","archived":false,"fork":false,"pushed_at":"2024-04-15T23:32:23.000Z","size":6466,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-29T06:39:51.066Z","etag":null,"topics":["neural-network","python","tensorflow","tkinter"],"latest_commit_sha":null,"homepage":"","language":"PureBasic","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/javipzv.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":"2023-04-26T23:12:02.000Z","updated_at":"2023-04-27T00:38:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"efa12f8d-6bf6-4d5c-b38b-11208edf2cc4","html_url":"https://github.com/javipzv/handwritten-digits-classifier","commit_stats":null,"previous_names":["javipzv/handwritten-digits-classifier"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/javipzv/handwritten-digits-classifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javipzv%2Fhandwritten-digits-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javipzv%2Fhandwritten-digits-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javipzv%2Fhandwritten-digits-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javipzv%2Fhandwritten-digits-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javipzv","download_url":"https://codeload.github.com/javipzv/handwritten-digits-classifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javipzv%2Fhandwritten-digits-classifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32440818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T18:12:22.909Z","status":"ssl_error","status_checked_at":"2026-04-29T18:11:33.322Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["neural-network","python","tensorflow","tkinter"],"created_at":"2024-12-18T23:30:21.646Z","updated_at":"2026-04-29T19:31:14.597Z","avatar_url":"https://github.com/javipzv.png","language":"PureBasic","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Handwritten Digits Classifier\n\n## Description\nThis code defines a GUI (graphical user interface) for a digit classifier. It allows the user to draw a digit on a canvas and classify the digit using a pre-trained TensorFlow model. The model is based on a simple neural net with only 1 hidden layer of 512 neurons.\n\n## How to use\nTo use it, you only have to run the 'digitClassifier.py'. When run, the GUI will display a canvas that allows you to draw a digit with the mouse. You can then save the drawn image by clicking the \"Save\" button, and the image will be preprocessed and fed into the model to classify the digit. The predicted digit will be displayed in a label. The \"Delete\" button can be used to clear the canvas and start over. Additionally, the \"Change Model\" button allows you to switch between the simple neural network model and a convolutional neural network model.\n\n## About the models\nBoth models can be modified with the files neuralNetwork.py and convolutionalNeuralNetwork.py respectively. Don't forget uncomment the line of the model saving.\n\n### Simple Neural Network Model\nThe model in the repository is a simple feedforward neural network with two dense layers. The first layer has 512 units with a ReLU activation function. This layer has an input shape of (28*28,), which suggests that it is designed to process input images that are 28x28 pixels in size, flattened into a 1D array of length 784. The second layer has 10 units with a softmax activation function. This layer is designed to produce a probability distribution over the 10 possible classes (0-9) for the input image. The neural network is compiled with the RMSprop optimizer and categorical cross-entropy loss function. The accuracy metric is also specified for evaluating the performance of the model during training. Finally, the model is trained on a dataset of images and labels using the fit() method for 25 epochs and a batch size of 128.\n\n### Convolutional Neural Network (CNN) Model\nIn addition to the simple neural network model, a convolutional neural network (CNN) model has been implemented. The CNN model comprises three convolutional layers followed by max-pooling and dropout layers to extract and learn features from input images. The model then flattens the output and passes it through two dense layers for classification. It is compiled using the Adam optimizer and categorical cross-entropy loss function and trained on a dataset of images for 10 epochs and a batch size of 128. This CNN model is designed to capture spatial dependencies in the input images more effectively. As expected, the CNN model performs slightly better than the simple neural network model. You can switch between these models using the \"Change Model\" button in the GUI.\n\n## Visual\n  \n\u003cimg width=\"569\" alt=\"Captura del modelo\" src=\"https://github.com/javipzv/handwritten-digits-classifier/assets/90279135/8117ac9d-3ad9-4ac9-81b7-17e5ce052d8b\"\u003e\n\n## Conclusions\nThe performance advantage of the Convolutional Neural Network (CNN) over a traditional neural network in the digits recognition task is relatively marginal. This slight improvement can be attributed to the CNN's ability to effectively capture spatial dependencies in the input images, thanks to its convolutional and pooling layers. However, the task of recognizing handwritten digits, while a vision problem, is relatively straightforward even for a standard neural network architecture due to the simplicity of the dataset and the distinct features present in each digit. Let's visualize the results:\n\n\u003cdiv style=\"display:flex; justify-content: center;\"\u003e\n  \u003cimg width=\"400\" src=\"https://github.com/javipzv/handwritten-digits-classifier/assets/90279135/19c55b8a-168e-455a-b1ee-9c5d35dbea5a\" alt=\"test_loss\"\u003e\n  \u003cimg width=\"400\" src=\"https://github.com/javipzv/handwritten-digits-classifier/assets/90279135/1f4af576-e7bf-4a71-9edf-ad00bb6b6c12\" alt=\"test_acc\"\u003e\n\u003c/div\u003e\n\n## Aditional\nOut of curiosity, I wanted to see how the convolutional neural network works internally. Therefore, I decided to extract the weights of the first layer to visualize the final filters (code in *convolutionalNeuralNetwork.py*) and see how they were applied to a specific number. Here's the result:\n\n\u003cdiv style=\"display:flex; justify-content: center;\"\u003e\n  \u003cimg width=\"400\" src=\"https://github.com/javipzv/handwritten-digits-classifier/assets/90279135/efdf4611-f723-4140-a753-8f127fc8c3e1\" alt=\"filters\"\u003e\n  \u003cimg width=\"400\" src=\"https://github.com/javipzv/handwritten-digits-classifier/assets/90279135/a905afe4-f538-44a6-8b91-6acb3793a905\" alt=\"convolutions\"\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\nWe can observe how the filters of the first layer are gradually selecting shapes, which may seem random at first glance, from the input image. This process of selecting shapes constitutes the convolutional process, where the filters detect local patterns in the image, such as edges, curves, or textures. As these patterns propagate through the subsequent layers of the convolutional neural network, they are combined and refined to form increasingly abstract and complex representations of objects in the image. This hierarchical learning process allows the network to capture discriminative features relevant for distinguishing between different handwritten digits.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavipzv%2Fhandwritten-digits-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavipzv%2Fhandwritten-digits-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavipzv%2Fhandwritten-digits-classifier/lists"}