Git Product home page Git Product logo

extract-information-from-identity-card's Introduction

Extract-information-from-identity-card

Tutorial: Recognize Identity Card Tutorial

1. Pipeline

1.1. Corner Detection and Alignment

1.2. Text Detection

1.3. Recognize image text and final results

Final Result

{
  "id": "38138424",
  "name": "LÊ KIỀU DIỄM",
  "birth": "1989",
  "add": "Tân Hưng Tây Phú Tân Cà Mau",
  "home": "Khóm 8 Phường 8 TP Cà Mau Cà Mau"
}

2. How to run project

2.1. Install dependecies

pip install -r requirement.txt

2.2. Download weight from gg drive

Download weight from here , then put into src/vietocr/config_text_recognition folder.

2.3. Start server

python main.py

Note

Phiên bản này dành riêng cho cộng đồng. Mọi người nếu có mong muốn tìm giải pháp thương mại xin vui lòng liên hệ mình theo email [email protected]

extract-information-from-identity-card's People

Contributors

buiquangmanhhp1999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

extract-information-from-identity-card's Issues

path to the Files?

Hello Sir Hope you are doing well .After installing the dependencies and running the main.py I am not getting any output where we have to give path to images and path to weights i mean in which file we should give this path and which files we have to run along with main.py file

OCR

Hi bro,

 Bài viết của bạn rất hữu ít vời mình, cám ơn bạn. Mình thấy bạn đang xài file pretrained của anh Quốc. 
 Thì nó chưa chính xác nên mình hỏi là cần phải train lại không? hay do mình làm sai nên kq chưa chính xác?
   Cám ơn nhiều nhé

RuntimeError: Error(s) in loading state_dict for VietOCR:

I tried to run server.py and got this error, please help

Many thanks

File "server.py", line 4, in <module> from serve_model import * File "/root/extract-information-from-identity-card/complete/serve_model.py", line 4, in <module> from merged_model import CompletedModel File "/root/extract-information-from-identity-card/complete/merged_model.py", line 94, in <module> model = CompletedModel() File "/root/extract-information-from-identity-card/complete/merged_model.py", line 17, in __init__ self.text_recognition_model = TextRecognition(path_to_checkpoint='./config_text_recognition/transformerocr.pth') File "/root/extract-information-from-identity-card/complete/recognition.py", line 11, in __init__ self.detector = Predictor(self.config) File "/root/extract-information-from-identity-card/complete/predictor.py", line 17, in __init__ model.load_state_dict(torch.load(weights, map_location=torch.device(device))) File "/root/idcard-ocr/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1224, in load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for VietOCR: size mismatch for transformer.embed_tgt.weight: copying a param with shape torch.Size([232, 256]) from checkpoint, the shape in current model is torch.Size([233, 256]). size mismatch for transformer.fc.weight: copying a param with shape torch.Size([232, 256]) from checkpoint, the shape in current model is torch.Size([233, 256]). size mismatch for transformer.fc.bias: copying a param with shape torch.Size([232]) from checkpoint, the shape in current model is torch.Size([233]).

AttributeError: 'tuple' object has no attribute 'tolist'

Hi bạn,
Cảm ơn bạn vì repo này và bài viết chia sẻ rất tuyệt vời.

Hiện khi chạy mình bị lỗi này:

INFO:     127.0.0.1:65113 - "POST /predict/image HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/protocols/http/h11_impl.py", line 394, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/middleware/debug.py", line 81, in __call__
    raise exc from None
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/middleware/debug.py", line 78, in __call__
    await self.app(scope, receive, inner_send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/fastapi/applications.py", line 201, in __call__
    await super().__call__(scope, receive, send)  # pragma: no cover
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/fastapi/routing.py", line 202, in app
    dependant=dependant, values=values, is_coroutine=is_coroutine
  File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
    return await dependant.call(**values)
  File "server.py", line 27, in predict_api
    prediction = predict(image)
  File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/serve_model.py", line 23, in predict
    result = model.predict(img)
  File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/merged_model.py", line 94, in predict
    self.text_recognition(cropped_image)
  File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/merged_model.py", line 78, in text_recognition
    result = self.text_recognition_model.predict_on_batch(np.array(list_ans))
  File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/recognition.py", line 63, in predict_on_batch
    return self.detector.batch_predict(batch_images)
  File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/predictor.py", line 58, in batch_predict
    sent = translate(batch, self.model).tolist()
AttributeError: 'tuple' object has no attribute 'tolist'

Mình print cái translate(batch, self.model) ra thì nó như này:

(array([
    [  1, 139,   2,   2,   2],
    [  1, 194, 197,   2,  98],
    [  1, 143, 120,   2,   2],
    [  1, 145, 137,   2,   2],
    [  1, 145,  28,  98,   2],
    [  1,  77, 114,   2,   2],
    [  1,  43,  76,  86,   2]]),
array([0.58601838, 0.83988384, 0.89621916, 0.92887259, 0.9296508 ,0.71749118, 0.93631878]))

Bạn có thể gợi ý cho mình về kết quả của translate(batch, self.model) để mình fix lỗi này được không?
Cảm ơn bạn rất nhiều!

ERROR OpenCV

image
khi chạy mình gặp lỗi này. mong mng giúp đỡ

Không thể dùng cho căn cước công dân

Chào anh, em đã chạy được project nhưng có vẻ nó không thể nhận dạng được căn cước công dân mới, anh có thể hướng dẫn train lại với ảnh căn cước công dân không ạ?

No module named 'complete'

When I run last step: python3 server.py
It show error:

Traceback (most recent call last):
  File "server.py", line 4, in <module>
    from serve_model import *
  File "/home/python/extract-information-from-identity-card/complete/serve_model.py", line 4, in <module>
    from merged_model import CompletedModel
  File "/home/python/extract-information-from-identity-card/complete/merged_model.py", line 1, in <module>
    from complete.detector import Detector
ModuleNotFoundError: No module named 'complete'

I'm using python3, already install uvicorn and fastapi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.