Spaces:
Build error
Build error
Download src/app/main.py from Alimustoofaa/Container-Number-OCR: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/spaces/Alimustoofaa/Container-Number-OCR/resolve/main/src/app/main.py
- Command line
-
hf download hf://spaces/Alimustoofaa/Container-Number-OCR/src/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Alimustoofaa/Container-Number-OCR/resolve/main/src/app/main.py
746 Bytes
| from text_recognition import TextRecognition | |
| if __name__ == '__main__': | |
| import os | |
| import cv2 | |
| import time | |
| import string | |
| root_path = os.path.expanduser('~/.Halotec/Models') | |
| model_config = { | |
| 'filename' : 'crnn_008000.pt', | |
| 'classes' : string.digits+string.ascii_uppercase+'. ', | |
| 'url' : None, | |
| 'file_size' : 592694, | |
| 'img_height': 32, | |
| 'img_width' : 100, | |
| 'map_to_seq_hidden': 64, | |
| 'rnn_hidden': 256, | |
| 'leaky_relu': False | |
| } | |
| text_recognition = TextRecognition(root_path, model_config, jic=True) | |
| image = cv2.imread('./images/12022041113414598_14.jpg') | |
| start = time.time() | |
| for i in range(10): | |
| result = text_recognition.recognition(image, decode='beam_search', beam_size=10) | |
| print(result) | |
| print(time.time() - start) |