Skip to content

Commit

Permalink
Merge branch 'feat/17-fuzzywuzzy' of https://github.com/CAUSOLDOUTMEN…
Browse files Browse the repository at this point in the history
…/Diareat_OCR into feat/17-fuzzywuzzy
  • Loading branch information
synoti21 committed Nov 12, 2023
2 parents 37e224c + ed63e5d commit 4ad1303
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.gitignore
README.md
README.md
2 changes: 0 additions & 2 deletions .github/workflows/diareat_ocr_cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Diareat OCR CI/CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
*.pyc
*.jpg
*.env
boto.conf.dev
*.jpeg
*.png
24 changes: 19 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
FROM python:3.11.3-slim-buster
FROM amd64/ubuntu:22.04

WORKDIR /app

ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive

COPY Pipfile Pipfile.lock /app/

RUN pip install pipenv && \
pipenv install --deploy --ignore-pipfile
COPY Pipfile Pipfile.lock /app/
RUN apt -y update && apt -y upgrade
RUN apt install -y pip && pip install pipenv
RUN apt install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa && apt -y update
RUN apt-get install -y fonts-noto-cjk
RUN apt install -y python3.11
RUN pipenv --python /usr/bin/python3
RUN pipenv install

COPY . /app/

CMD ["pipenv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
RUN pipenv run pip install cmake
RUN pipenv run pip install easyocr

EXPOSE 8000


CMD ["pipenv", "run","uvicorn", "main:app", "--host","0.0.0.0","--port","8000"]

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2023 CAUSOLDOUTMEN

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 0 additions & 5 deletions boto.conf

This file was deleted.

26 changes: 11 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,19 @@ class ImageRequest(BaseModel):
ocr = PororoOcr()
preprocessor = PreProcessor()

aws_access_key = os.environ.get('AWS_ACCESS_KEY')
aws_secret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
bucket_name = os.environ.get('BUCKET_NAME')
region_name = os.environ.get('REGION_NAME')

parser = configparser.ConfigParser()
parser.read("./boto.conf.dev")
aws_s3_access_key = parser.get("aws_boto_credentials",
"AWS_ACCESS_KEY")
aws_s3_secret_access_key = parser.get("aws_boto_credentials", "AWS_SECRET_ACCESS_KEY")
s3_region_name = parser.get("aws_boto_credentials", "REGION_NAME")
s3_bucket_name = parser.get("aws_boto_credentials",
"BUCKET_NAME")

s3_client = boto3.client(
's3',
aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_access_key,
region_name=region_name,
)

s3_client = boto3.client('s3',
aws_access_key_id=aws_s3_access_key,
aws_secret_access_key=aws_s3_secret_access_key,
region_name=s3_region_name)

BUCKET_NAME = s3_bucket_name

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand All @@ -67,7 +63,7 @@ async def read_item(request: ImageRequest):
if not os.path.exists(file_name):
logger.info("Download image from s3")
try:
s3_client.download_file(BUCKET_NAME, image_name, file_name)
s3_client.download_file(bucket_name, image_name, file_name)
except ClientError:
raise HTTPException(status_code=404, detail='Image not found in S3')
image = cv2.imread(file_name, cv2.IMREAD_COLOR)
Expand Down

0 comments on commit 4ad1303

Please sign in to comment.