{"id":25036680,"url":"https://github.com/codercake/fastapi-detectlang","last_synced_at":"2025-03-30T20:52:23.220Z","repository":{"id":275290204,"uuid":"925657442","full_name":"codercake/fastapi-detectlang","owner":"codercake","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-01T12:22:58.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T22:33:19.845Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/codercake.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":"2025-02-01T12:18:41.000Z","updated_at":"2025-02-02T04:50:25.000Z","dependencies_parsed_at":"2025-02-01T13:35:43.754Z","dependency_job_id":null,"html_url":"https://github.com/codercake/fastapi-detectlang","commit_stats":null,"previous_names":["codercake/fastapi-detectlang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codercake%2Ffastapi-detectlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codercake%2Ffastapi-detectlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codercake%2Ffastapi-detectlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codercake%2Ffastapi-detectlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codercake","download_url":"https://codeload.github.com/codercake/fastapi-detectlang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379385,"owners_count":20767696,"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":[],"created_at":"2025-02-06T00:06:50.265Z","updated_at":"2025-03-30T20:52:23.196Z","avatar_url":"https://github.com/codercake.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Developing an API to Detect Local Languages Using FastAPI  \n\nI am building an API that processes images containing handwritten text in local languages. The API will analyze the text, identify grammatical errors, and return a structured response with corrections and grading.  \n\n\nStep 1: Setting Up My Workspace\nTo get started, I need to install a few essential tools on my computer:  \n- Python – The core programming language for my API  \n- FastAPI – The framework that helps me create the web service  \n- Tesseract OCR– A tool that reads and extracts text from images  \n- Image Processing Libraries – Such as OpenCV and PIL, which help clean and enhance images before processing  \n\n\nStep 2: Setting Up the API Endpoint  \nI will create an API endpoint that runs locally on `localhost:8000`. This serves as the entry point where users can upload images containing handwritten text.  \n\nWhen I navigate to `localhost:8000/docs`, I can access an interactive interface that allows me to test and visualize how the API works.  \n\nStep 3: Processing the Handwritten Image\nOnce an image is uploaded, my API follows a structured pipeline:  \n1. Preprocessing – Enhancing the image by adjusting brightness and contrast for better readability  \n2. Text Extraction – Using Tesseract OCR to read the handwritten text  \n3. Language Identification – Recognizing the language of the extracted text  \n4. Error Detection – Checking for grammatical mistakes  \n5. Grading – Providing feedback on grammar, spelling, and structure  \n\nStep 4: Running the API \nTo start the service, I open my terminal and run the following command:  \n\n`uvicorn main:app --reload`\n\nThis launches my API, making it accessible at `localhost:8000`.  \n\n\nStep 5: Testing the API\nI can test my API using different methods:  \n1. Web Interface – By visiting `localhost:8000/docs` in my browser  \n2. Postman – A tool for sending API requests and analyzing responses  \n3. Terminal Command – Using `curl` to send an image for processing:  \n\n`curl POST -F \"image=@the-image.jpg\" http://localhost:8000/analyze-text`\nin my case, it would look something like this: `curl -v -X POST -F \"image=@/Users/ishitha/Hard_Code/genai-apis/marwadi-lang.jpg\" http://localhost:8000/analyze-text`\n\nHow the API Works\n- It Supports Multiple Indian Languages – Recognizing and analyzing text in languages like Marwadi, Hindi, and Gujarati  \n- Fast and Efficient – The response is quick with high accuracy  \n- Detailed Feedback – The system provides an evaluation of grammar, spelling, and sentence structure  \n- A Virtual Writing Assistant – It helps improve handwritten text quality  \n\nTech Stack \n- Python – Main programming language  \n- FastAPI – Web framework for API development  \n- Tesseract OCR – Reads handwritten text  \n- OpenCV \u0026 PIL – Helps process and clean images  \n\nSystem Architecture Overview \n- The FastAPI endpoint processes multipart/form-data** POST requests, handling JPEG image uploads** asynchronously at port `8000`.  \n- The uploaded image undergoes binary conversion and preprocessing before text extraction using OCR.  \n- The OCR engine, configured with a specific language pack (e.g., Gujarati: `lang='guj'`), extracts text accurately while maintaining Unicode encoding.  \n\nResponse Analysis \nThe API returns a structured JSON response** with:  \n- Confidence Score: 0.95 (95% recognition accuracy)  \n- Text Analysis Metrics: 4 words, 14 characters extracted  \n- Grading Breakdown: \n  - Grammar: 9.0/10  \n  - Spelling: 8.5/10  \n  - Sentence Structure: 8.0/10  \n- File Validation: Ensuring correct MIME type (`image/jpeg`) and size verification  \n\n\nPerformance Insights\n- Returns an HTTP/1.1 200 OK response  \n- Efficient TCP connection handling at `127.0.0.1:8000`  \n- Ensures a clean request-response cycle with minimal latency\n\nFinal Thoughts\nThis API is designed to efficiently process handwritten text in local languages, analyze its structure, and provide meaningful feedback. So, next time I don't have to explain it to my north-indian friend about a sign board that says to not litter, I can just point her to this API.\n\n\u003cimg width=\"1679\" alt=\"Screenshot 2025-02-01 at 17 46 03\" src=\"https://github.com/user-attachments/assets/5279fddc-7940-4c96-b72c-14be43a45a08\" /\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodercake%2Ffastapi-detectlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodercake%2Ffastapi-detectlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodercake%2Ffastapi-detectlang/lists"}