Spaces:
Sleeping
Sleeping
Download ocr.py from Goutam112/Text_Extracted: direct link, hf CLI and curl.
- Browser
- Download file 313 Bytes
-
https://huggingface.co/spaces/Goutam112/Text_Extracted/resolve/main/ocr.py
- Command line
-
hf download hf://spaces/Goutam112/Text_Extracted/ocr.py
-
curl -L -o ocr.py https://huggingface.co/spaces/Goutam112/Text_Extracted/resolve/main/ocr.py
313 Bytes
| import easyocr | |
| import json | |
| def extract_text(image_path): | |
| reader = easyocr.Reader(['en', 'hi']) | |
| results = reader.readtext(image_path) | |
| extracted_text = [] | |
| for (bbox, text, prob) in results: | |
| extracted_text.append(text) | |
| return json.dumps({"extracted_text": " ".join(extracted_text)}) | |