-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from tukcomCD2024/AIflask
A iflask
- Loading branch information
Showing
18 changed files
with
104 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import app as a | ||
|
||
app = a.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-578 Bytes
(66%)
AI/app/controllers/__pycache__/example_controllers.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from PIL import Image | ||
import numpy as np | ||
|
||
# 이미지를 흑백으로 변환 | ||
def convertMono(img: Image): | ||
fn = lambda x: 255 if x > 0 else 0 | ||
img = img.convert('L').point(fn, mode='1') | ||
return img | ||
|
||
|
||
# 이미지 크기를 128*128로 변경 후 이미지를 배열화 | ||
def resizing(img): | ||
img = img.resize((128, 128)) | ||
img = img.convert('RGB') | ||
return img | ||
|
||
|
||
# 이미지를 배열화 | ||
def imageToArray(img): | ||
img = np.array(img) | ||
img = np.expand_dims(img, axis=0) | ||
return img | ||
|
||
|
||
# 이미지를 AI에 맞게 전환 | ||
def imageProcessing(img: Image): | ||
img = convertMono(img) | ||
img = resizing(img) | ||
img = imageToArray(img) | ||
return img |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
FROM python:3.8-slim | ||
# NVIDIA CUDA 베이스 이미지 사용 | ||
FROM nvidia/cuda:11.2.2-cudnn8-runtime-ubuntu20.04 | ||
|
||
COPY . . | ||
# 환경 변수 설정 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN pip3 install flask | ||
RUN pip3 install tensorflow | ||
RUN pip3 install pillow | ||
RUN pip3 install boto3 | ||
# NVIDIA 패키지 리포지토리 추가 및 TensorRT 설치 | ||
RUN apt-get update && apt-get install -y gnupg2 | ||
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub && \ | ||
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64/7fa2af80.pub && \ | ||
sh -c 'echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list' && \ | ||
apt-get update && apt-get install -y \ | ||
tzdata \ | ||
build-essential \ | ||
libhdf5-dev \ | ||
pkg-config \ | ||
python3 \ | ||
python3-pip \ | ||
libnvinfer8 \ | ||
libnvonnxparsers8 \ | ||
libnvparsers8 \ | ||
libnvinfer-plugin8 \ | ||
python3-libnvinfer-dev \ | ||
&& ln -fs /usr/share/zoneinfo/Asia/Seoul /etc/localtime \ | ||
&& dpkg-reconfigure --frontend noninteractive tzdata | ||
|
||
WORKDIR . | ||
# 작업 디렉토리 설정 | ||
WORKDIR /app | ||
|
||
ENV FLASK_APP=app.py | ||
# 애플리케이션 코드 복사 | ||
COPY . /app | ||
|
||
CMD ["python3", "-m", "flask", "run","--host=0.0.0.0"] | ||
# pip 업그레이드 및 패키지 설치 | ||
RUN pip3 install --upgrade pip | ||
RUN pip3 install --no-cache-dir tensorflow gunicorn -r requirements.txt | ||
|
||
# Gunicorn을 사용하여 Flask 애플리케이션 실행 | ||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "aiflask:app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
flask | ||
pillow | ||
boto3 |