From dd8be397bc0559c9f9f75b88a5121849946257df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C6=B0=C6=A1ng=20Nguy=E1=BB=85n?= <65907920+ntvuongg@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:54:25 +0700 Subject: [PATCH 1/2] Update README.md --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 0fef5a3..87f6582 100644 --- a/README.md +++ b/README.md @@ -1,8 +1 @@ # **Vietnamese ID Card Extractor v2.0** - -## **Team Member** - -- Nguyễn Thành Vương - 19522542 -- Huỳnh Thiện Tùng - 19522492 -- Lê Thị Thanh Thanh - 19520954 -- Trương Minh Sơn - 19522143 From 1e00d67ef8cf8e1e380a0ea0d62a7f2aa03e5329 Mon Sep 17 00:00:00 2001 From: Vuong Nguyen Date: Tue, 25 Oct 2022 19:59:13 +0700 Subject: [PATCH 2/2] [DEL] remove redundant files --- .gitignore | 3 + Dockerfile | 9 + README.md | 33 ++++ requirements.txt | 55 ++---- sources/Controllers/main.py | 32 +++- sources/Database/database.db | Bin 12288 -> 12288 bytes sources/Models/database.py | 2 +- sources/Models/models.py | 1 + sources/Views/templates/contact.html | 64 +++++++ sources/Views/templates/ekyc.html | 4 +- sources/Views/templates/feedback.html | 15 +- sources/Views/templates/idcard.html | 2 +- sources/static/css/contact.css | 243 ++++++++++++++++++++++++++ sources/static/css/feedback.css | 4 + sources/static/css/home.css | 2 +- sources/static/face/face_crop.jpg | Bin 0 -> 4336 bytes sources/static/js/contact.js | 53 ++++++ sources/static/js/feedback.js | 8 +- sources/static/js/script.js | 2 +- 19 files changed, 475 insertions(+), 57 deletions(-) create mode 100644 Dockerfile create mode 100644 sources/Views/templates/contact.html create mode 100644 sources/static/css/contact.css create mode 100644 sources/static/face/face_crop.jpg create mode 100644 sources/static/js/contact.js diff --git a/.gitignore b/.gitignore index e43b0f9..3f94205 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .DS_Store +__pycache__/ +sources/Database/uploads +sources/static/results \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..142d725 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:latest +WORKDIR /app +RUN apt-get update -y && apt upgrade -y +RUN apt-get install -y software-properties-common python3-pip python3-dev build-essential hdf5-tools libgl1 libgtk2.0-dev +RUN apt-get -y install libgeos-dev +COPY . /app +RUN pip3 install -r requirements.txt +EXPOSE 8080 +CMD ["python3", "run.py"] \ No newline at end of file diff --git a/README.md b/README.md index 87f6582..48e19b8 100644 --- a/README.md +++ b/README.md @@ -1 +1,34 @@ # **Vietnamese ID Card Extractor v2.0** + +## **Introduction** + +An web application helps us to extract information from Vietnamese chip-based ID card in a second. This application aims to reduce human typing workload and saves more time. + +## **Installation** +All requirement libraries are listed in requirements.txt. You can install it by using: + +``` bash +# Virtual env recommended +pip install -r requirements.txt +``` +or build through **[Docker](https://www.docker.com/)** by: + +``` +docker build -t . +``` + +## **Usage** + +``` python +python run.py +``` +With Docker: +``` +docker run -p 8080:8080 +``` + +## **Demo** +https://user-images.githubusercontent.com/65907920/197776185-da82f1e3-bc4e-41c9-9be6-95254e4c2dfa.mov + +## **Contributors** +Special thanks to [Huynh Thien Tung](https://github.com/tuilatung), [Le Thi Thanh Thanh](https://github.com/thanhthanhthile) and [Truong Minh Son](https://github.com/truongminhson) have contributed for this project. I heartly thankful to you all. diff --git a/requirements.txt b/requirements.txt index a7075eb..85f7f54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,37 +1,20 @@ # pip install -r requirements.txt - -# Base ---------------------------------------- -matplotlib>=3.2.2 -numpy>=1.18.5 -opencv-python>=4.1.2 -Pillow>=7.1.2 -PyYAML>=5.3.1 -requests>=2.23.0 -scipy>=1.4.1 -torch>=1.7.0 -torchvision>=0.8.1 -tqdm>=4.41.0 - -# Logging ------------------------------------- -# tensorboard>=2.4.1 -# wandb - -# Plotting ------------------------------------ -# pandas>=1.1.4 -# seaborn>=0.11.0 - -# Export -------------------------------------- -# coremltools>=4.1 # CoreML export -# onnx>=1.9.0 # ONNX export -# onnx-simplifier>=0.3.6 # ONNX simplifier -# scikit-learn==0.19.2 # CoreML quantization -# tensorflow>=2.4.1 # TFLite export -# tensorflowjs>=3.9.0 # TF.js export -# openvino-dev # OpenVINO export - -# Extras -------------------------------------- -# albumentations>=1.0.3 -# Cython # for pycocotools https://github.com/cocodataset/cocoapi/issues/172 -# pycocotools>=2.0 # COCO mAP -# roboflow -# thop # FLOPs computation +vietocr +uvicorn==0.17.6 # Newer version has deprecated debug in run() +fastapi +pylibsrtp +databases +yolov5 +aiosqlite +python-multipart +Jinja2 +shapely==1.7.1 +# numpy>=1.18.5 +# opencv-python>=4.1.2 +# Pillow>=7.1.2 +# PyYAML>=5.3.1 +# requests>=2.23.0 +# scipy>=1.4.1 +# torch>=1.7.0 +# torchvision>=0.8.1 +# tqdm>=4.41.0 \ No newline at end of file diff --git a/sources/Controllers/main.py b/sources/Controllers/main.py index 9fb64f1..480dc86 100644 --- a/sources/Controllers/main.py +++ b/sources/Controllers/main.py @@ -1,3 +1,4 @@ +from typing import Optional from pylibsrtp import Session from sources import app, templates from fastapi import Request, UploadFile, File, Depends, Form @@ -16,7 +17,6 @@ from vietocr.tool.predictor import Predictor from vietocr.tool.config import Cfg import sources.Controllers.config as cfg -import shutil """ ---- Setup ---- """ # Init Database @@ -61,6 +61,15 @@ async def shutdown(): """ ---- ##### -----""" class feedback_Request(BaseModel): content: str + rating: int + class Config: + orm_mode = True + +class contact_Request(BaseModel): + name: str + email: str + phone: Optional[str] = None + message: str class Config: orm_mode = True @@ -82,18 +91,21 @@ async def home(request: Request): return templates.TemplateResponse("home.html", {"request": request}) @app.get("/id_card") -async def home(request: Request): +async def id_extract_page(request: Request): return templates.TemplateResponse("idcard.html", {"request": request}) @app.get("/ekyc") -async def ekyc_home(request: Request): +async def ekyc_page(request: Request): return templates.TemplateResponse("ekyc.html", {"request": request}) - @app.get("/feedback") -async def feedback_home(request: Request): +async def feedback_page(request: Request): return templates.TemplateResponse("feedback.html", {"request": request}) +@app.get("/contact") +async def contact_page(request: Request): + return templates.TemplateResponse("contact.html", {"request": request}) + @app.post("/uploader") async def upload(file: UploadFile = File(...)): INPUT_IMG = os.listdir(UPLOAD_FOLDER) @@ -157,7 +169,7 @@ async def extract_info(ekyc=False, path_id = None): # CORNER.show() CONTENT = CONTENT_MODEL(aligned) - CONTENT.save(save_dir='results/') + # CONTENT.save(save_dir='results/') predictions = CONTENT.pred[0] categories = predictions[:, 5].tolist() # Class if 7 not in categories: @@ -215,9 +227,10 @@ async def download(file: str = Form(...)): return JSONResponse(status_code=405, content={"message": error}) @app.post("/feedback") -async def save_feedback(content: str = Form(...), db: Session = Depends(get_db)): +async def save_feedback(content: str = Form(...), rating: int = Form(...), db: Session = Depends(get_db)): feedback = Feedback() feedback.content = content + feedback.rating = rating db.add(feedback) db.commit() @@ -228,6 +241,11 @@ async def save_feedback(content: str = Form(...), db: Session = Depends(get_db)) return JSONResponse(content=response) +@app.post("/contact") +async def contact(request: contact_Request): + # print(request.name) + pass + @app.post("/ekyc/uploader") async def get_id_card(id: UploadFile = File(...), img: UploadFile = File(...)): INPUT_IMG = os.listdir(UPLOAD_FOLDER) diff --git a/sources/Database/database.db b/sources/Database/database.db index 42cdb3d935924debf860e8589ce5cc9b6f66741e..1306bc85f14aeb29cadf4c4c75a5f3a94b3a098e 100644 GIT binary patch delta 189 zcmZojXh@hK&B!uQ##xYsK`+{fmw|zSiJymoKY^cTW8oaW$#VRmoU)AU;_~v0O`MZ! z_+xmB5=%1k(iJ@YLR{TlCtv0_%1o>b!iO^zldLMv!K8_zR5iNp`6@|?BeqBjE$+2 zv-o2s-{99_W8}ZWz<*`4pu#DBGc86I231Fo)SR4r9fh#c{JeA{10y3{12bJC0|f&M nD + + + Contact + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CONTACT + ME +
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ +
+
+
+
+ + + + diff --git a/sources/Views/templates/ekyc.html b/sources/Views/templates/ekyc.html index db7e188..aba3aea 100644 --- a/sources/Views/templates/ekyc.html +++ b/sources/Views/templates/ekyc.html @@ -61,7 +61,7 @@ About
  • - + Contact @@ -111,7 +111,7 @@

    Upload your ID image :

    - +
    Drag & Drop or Click here to browse diff --git a/sources/Views/templates/feedback.html b/sources/Views/templates/feedback.html index e8c47b4..afa0c40 100644 --- a/sources/Views/templates/feedback.html +++ b/sources/Views/templates/feedback.html @@ -11,6 +11,7 @@ + @@ -65,7 +66,7 @@ About
  • - + Contact @@ -75,7 +76,7 @@
    - +
    Nguyen Thanh Vuong
    Computer Science
    @@ -97,11 +98,11 @@
    Your feedback help us to improve.
    Please let us know about your services experience.
    - - - - - + + + + +
    diff --git a/sources/Views/templates/idcard.html b/sources/Views/templates/idcard.html index 192b919..dfc2f07 100644 --- a/sources/Views/templates/idcard.html +++ b/sources/Views/templates/idcard.html @@ -62,7 +62,7 @@ About
  • - + Contact diff --git a/sources/static/css/contact.css b/sources/static/css/contact.css new file mode 100644 index 0000000..be3d5ce --- /dev/null +++ b/sources/static/css/contact.css @@ -0,0 +1,243 @@ +*, +*:before, +*:after { + box-sizing: border-box; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +body { + background: linear-gradient(181.2deg, rgb(181, 239, 249) 10.5%, rgb(254, 254, 254) 86.8%); + font-size: 12px; +} + +body, +button, +input { + font-family: "Montserrat", sans-serif; + font-weight: 700; + letter-spacing: 1.4px; +} + +.background { + display: flex; + min-height: 100vh; +} + +.container { + flex: 0 1 700px; + margin: auto; + padding: 10px; +} + +.screen { + position: relative; + background: white; + border-radius: 15px; +} + +.screen:after { + content: ""; + display: block; + position: absolute; + top: 0; + left: 20px; + right: 20px; + bottom: 0; + border-radius: 15px; + box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4); + z-index: -1; +} + +.screen-header { + display: flex; + align-items: center; + padding: 10px 20px; + background: #4d4d4f; + border-top-left-radius: 15px; + border-top-right-radius: 15px; +} + +.screen-header-left { + margin-right: auto; +} + +.screen-header-button { + display: inline-block; + width: 8px; + height: 8px; + margin-right: 3px; + border-radius: 8px; + background: white; +} + +.screen-header-button.close { + background: #ed1c6f; +} + +.screen-header-button.maximize { + background: #e8e925; +} + +.screen-header-button.minimize { + background: #74c54f; +} + +.screen-header-right { + display: flex; +} + +.screen-header-ellipsis { + width: 3px; + height: 3px; + margin-left: 2px; + border-radius: 8px; + background: #999; +} + +.screen-body { + display: flex; +} + +.screen-body-item { + flex: 1; + padding: 50px; +} + +.screen-body-item.left { + display: flex; + flex-direction: column; +} + +.app-title { + display: flex; + flex-direction: column; + position: relative; + color: #ea1d6f; + font-size: 26px; +} + +.app-title:after { + content: ""; + display: block; + position: absolute; + left: 0; + bottom: -10px; + width: 25px; + height: 4px; + background: #ea1d6f; +} + +.app-contact { + margin-top: auto; + font-size: 8px; + color: #888; +} + +.app-form-group { + margin-bottom: 15px; +} + +.app-form-group.message { + margin-top: 40px; +} + +.app-form-group.buttons { + margin-bottom: 0; + text-align: right; +} + +.app-form-control { + width: 100%; + padding: 10px 0; + background: none; + border: none; + border-bottom: 1px solid #666; + color: #4d4d4f; + font-size: 14px; + text-transform: uppercase; + outline: none; + transition: border-color 0.2s; +} + +.app-form-control::placeholder { + color: gray; +} + +.app-form-control:focus { + border-bottom-color: #ea1d6f; +} + +.app-form-button { + padding: 8px 16px; + width: 100px; + height: 40px; + background-color: #ea1d6f; + color: #fff; + border: 1px solid #ccc; + border-radius: 30px; + margin-top: 10px; + font-size: 16px; + transition: 0.3s; +} + +.app-form-button:hover { + background-color: #c4135a; +} + +.credits { + display: flex; + justify-content: center; + align-items: center; + margin-top: 20px; + color: #ffa4bd; + font-family: "Roboto Condensed", sans-serif; + font-size: 16px; + font-weight: normal; +} + +.credits-link { + display: flex; + align-items: center; + color: #fff; + font-weight: bold; + text-decoration: none; +} + +.dribbble { + width: 20px; + height: 20px; + margin: 0 5px; +} + +@media screen and (max-width: 520px) { + .screen-body { + flex-direction: column; + } + + .screen-body-item.left { + margin-bottom: 30px; + } + + .app-title { + flex-direction: row; + } + + .app-title span { + margin-right: 12px; + } + + .app-title:after { + display: none; + } +} + +@media screen and (max-width: 600px) { + .screen-body { + padding: 40px; + } + + .screen-body-item { + padding: 0; + } +} diff --git a/sources/static/css/feedback.css b/sources/static/css/feedback.css index fc938ec..cf3a666 100644 --- a/sources/static/css/feedback.css +++ b/sources/static/css/feedback.css @@ -99,6 +99,10 @@ p.mt-3{ .icon{ transition: all 0.2s ease ; + margin-top: 10px; +} +.icon.selected{ + margin-top: 0px; } .icon:hover{ diff --git a/sources/static/css/home.css b/sources/static/css/home.css index ec17b35..a1b829e 100644 --- a/sources/static/css/home.css +++ b/sources/static/css/home.css @@ -20,7 +20,7 @@ body,h1,h2,h3,h4,h5,h6 { #bg_img{ width: 100%; - height: 100%; + height: 100vh; } .welcome{ diff --git a/sources/static/face/face_crop.jpg b/sources/static/face/face_crop.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9d9567fd9963204f36840d9af174d24ec4a5b919 GIT binary patch literal 4336 zcmbW)XHXMbn+NcOgdUI86yS0d zpbem*qN1jvq@kv!rlqB!gRn6`=;rql`bb#L9UV(c$9|QAlS@QYO#C`bUO`bwSp}}GqpPQH zU}$7*V{2#c;OK<#@Vtlg^7aV|4hanle-IHDpOBc8{3InS`x!PTH!mMoR$ftARb4}< zecsaA*51)c>Kc48G(0joHax;AglQ@2(k3+urxxXzyg4LEM z0ID(_030TOLQH!4=<^9T1+q5`3&Xl$g0AVE2Tse6QS*}8n zXN{=HU{`H`ZjjSqbS|?T?2A2D@2hS7TD7=Ww#u&hb8`!emZPFK5LERy>#q3aVx6A_ke45<;shmCyRx2iin~iqGEUF@nbi2Je z_#*6LN1`zywSm!a9^0`gU79-f%%+F6{ccOPI%@7!R;W*Q`HG_N62Lqt6YDf-9}`SS z)c|D09Bfr{@w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