{"id":22188821,"url":"https://github.com/aliiiw/ai-project","last_synced_at":"2026-05-17T11:33:02.363Z","repository":{"id":220565705,"uuid":"751978082","full_name":"Aliiiw/Ai-Project","owner":"Aliiiw","description":"Persian hand writing digit detection using tensorflow","archived":false,"fork":false,"pushed_at":"2024-02-02T18:49:36.000Z","size":2004,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-07T00:42:49.534Z","etag":null,"topics":["cnn","handwritten-digit-recognition","persian-language","random-forest-classifier","tensorflow"],"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/Aliiiw.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}},"created_at":"2024-02-02T18:40:17.000Z","updated_at":"2024-02-03T07:31:54.000Z","dependencies_parsed_at":"2024-02-02T19:55:36.109Z","dependency_job_id":null,"html_url":"https://github.com/Aliiiw/Ai-Project","commit_stats":null,"previous_names":["aliiiw/ai-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Aliiiw/Ai-Project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aliiiw%2FAi-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aliiiw%2FAi-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aliiiw%2FAi-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aliiiw%2FAi-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aliiiw","download_url":"https://codeload.github.com/Aliiiw/Ai-Project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aliiiw%2FAi-Project/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33136741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["cnn","handwritten-digit-recognition","persian-language","random-forest-classifier","tensorflow"],"created_at":"2024-12-02T11:12:46.697Z","updated_at":"2026-05-17T11:33:02.357Z","avatar_url":"https://github.com/Aliiiw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ai-Project\n\nAi-Project is a Persian handwritten digit recognition project. It loads digit images from a folder-based dataset, preprocesses them into 8x8 grayscale feature vectors, trains a Random Forest classifier, and also includes a simple PyTorch neural network as a bonus model.\n\n## Output Samples\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/p1.png\" width=\"850\" alt=\"Random Forest and neural network prediction sample\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/p2.png\" width=\"850\" alt=\"Digit recognition output sample\" /\u003e\n\u003c/p\u003e\n\n## Features\n\n- Loads custom image datasets from class folders.\n- Converts each image to grayscale.\n- Resizes images to 8x8 pixels and flattens them into 64-value feature vectors.\n- Normalizes pixel values and applies `StandardScaler`.\n- Splits the dataset into train/test sets.\n- Trains a `RandomForestClassifier` from scikit-learn.\n- Evaluates Random Forest accuracy on the test split.\n- Defines and trains a simple PyTorch neural network.\n- Evaluates neural-network accuracy.\n- Visualizes the original image, Random Forest prediction, and neural-network prediction side by side.\n\n## Tech Stack\n\n- Python\n- NumPy\n- OpenCV\n- scikit-learn\n- PyTorch\n- Matplotlib\n\n## Project Structure\n\n```text\n.\n├── AliRahimi.py              # Main training, evaluation, and visualization script\n├── AI-Project-Fall-1402.pdf  # Assignment/project document\n├── images/                   # Output screenshots\n└── README.md\n```\n\n## Dataset Format\n\nThe script expects a local dataset folder named `Train` in the project root. Each subfolder should represent one digit/class label:\n\n```text\nTrain/\n├── 0/\n│   ├── image_1.png\n│   └── ...\n├── 1/\n│   └── ...\n└── 9/\n    └── ...\n```\n\nFolder names are converted to integer labels, so they should be numeric digit labels.\n\n## How It Works\n\n1. `loadImages()` walks through every class folder and reads the images.\n2. `convertTo8Gray()` converts each image to grayscale, resizes it to 8x8, and flattens it.\n3. `LoadCustomDataSet()` normalizes, splits, and scales the dataset.\n4. A Random Forest model is trained and evaluated.\n5. A small PyTorch neural network with one hidden layer is trained for 10 epochs.\n6. A test image is visualized with both model predictions.\n\n## Running the Project\n\nInstall the required packages:\n\n```bash\npip install numpy opencv-python scikit-learn matplotlib torch\n```\n\nThen place the dataset in `./Train` and run:\n\n```bash\npython AliRahimi.py\n```\n\n## Notes\n\nThe dataset itself is not included in this repository. The script depends on the local `Train` folder being present before execution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliiiw%2Fai-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliiiw%2Fai-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliiiw%2Fai-project/lists"}