{"id":43278732,"url":"https://github.com/rodolfoferro/cv-demo","last_synced_at":"2026-02-01T17:02:28.356Z","repository":{"id":314112588,"uuid":"1053933861","full_name":"RodolfoFerro/cv-demo","owner":"RodolfoFerro","description":"This repository contains a technical demo for an image classification system using a one-shot learning model. ","archived":false,"fork":false,"pushed_at":"2025-09-10T14:32:20.000Z","size":3592,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-10T18:37:38.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/RodolfoFerro.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-10T06:19:56.000Z","updated_at":"2025-09-10T14:32:23.000Z","dependencies_parsed_at":"2025-09-10T18:37:40.139Z","dependency_job_id":"bb7cb5e1-0905-479d-878b-524402b31d22","html_url":"https://github.com/RodolfoFerro/cv-demo","commit_stats":null,"previous_names":["rodolfoferro/cv-demo"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/RodolfoFerro/cv-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodolfoFerro%2Fcv-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodolfoFerro%2Fcv-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodolfoFerro%2Fcv-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodolfoFerro%2Fcv-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RodolfoFerro","download_url":"https://codeload.github.com/RodolfoFerro/cv-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodolfoFerro%2Fcv-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28983428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T16:29:42.054Z","status":"ssl_error","status_checked_at":"2026-02-01T16:29:41.428Z","response_time":56,"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":[],"created_at":"2026-02-01T17:02:27.429Z","updated_at":"2026-02-01T17:02:28.348Z","avatar_url":"https://github.com/RodolfoFerro.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image classification using One-Shot Learning Techniques\n\nThis repository contains a technical demo for an **Image Classification** system of CAD figures and tickets. \n\n![Overview](assets/samples.png)\n\nThe goal of this project is to showcase a production-ready workflow that combines:\n\n- **Computer vision (OpenCV)** for preprocessing and image handling.\n- **Deep learning (TensorFlow)** for image classification.\n- **Optical Character Recognition (OCR with pytesseract)** for text extraction.\n- **Web service (Flask/FastAPI)** to expose inference via REST API.\n\n## 📊 System Diagram\n\n_A general overview of the system integrating the complete workflow:_\n\n![Overview](assets/overview.png)\n\n## 🧩 Workflow\n\nThe system is divided into several stages:\n\n1. **Preprocessing (OpenCV).** The module `src/dataset.py` contains a function to prepare images, which includes an OpenCV pipeline that:\n    - Loads an image and converts it to grayscale from a given path.\n    - Binarizes the image using an Otsu threshold.\n    - Applies a morphological transformation (erosion, dilation or none).\n    - Resizes the image to a given size.\n    - Adds the dimension channel (1).\n    - Normalizes the image to range [0, 1].\n    - The dataset includes 2 classes:\n        - Cylinder\n        - Ticket (this ticket is used with `pytesseract`in a posterior process)\n\n2. **Model training (TensorFlow).** The content for this task is conteined in several files:\n    - The module `src/fsl.py` includes a function to build a model that uses a Few-Shot Learning (FSL) technique with a Siamese Network for image classifiaction tasks.\n    - The model is trained using the `notebooks/Train Siamese Network.ipynb` Jupyter Notebook. \n    - The trained model was saved in the `models/siamese.weights.h5` file.\n\n3. **OCR Extraction (Tesseract).**  For this task, an integration with `pytesseeract`is added in the web service (API):\n   - If the classified images corresponds to the `ticket` class, then the OCR is run over the image.\n\n4. **API Service (Flask/FastAPI)**  \n   - `/` endpoint: Health check for monitoring.  \n   - `/inference` endpoint: Receives an image and returns the resulting score.  \n   - `/inference-ocr` endpoint: Receives an image and returns the resulting score, as well as the detected text.\n\n\n## Future work/Improvements\n\n- **Containerization (Docker)** for deployment in scalable environments.\n- **Security** with an API bearer/auth token.\n- **Deployment** in a production environment.\n- **Model improvement** and extension to use more classes.\n\n## Credits\n\nThe dataset used in this project was completely built using the following public datsets from Kaggle:\n- [3D Geometric Objects in 2D plane (Sketch-like)](https://www.kaggle.com/datasets/breadzin/3d-geometric-objects-in-2d-plane-sketch-like)\n- [Find it again! Dataset](https://www.kaggle.com/datasets/nikita2998/find-it-again-dataset)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodolfoferro%2Fcv-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodolfoferro%2Fcv-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodolfoferro%2Fcv-demo/lists"}