Python을 기반으로 하는 Micro web framework로, Full stack web framework인 Django보다 가볍기 때문에 최소한의 웹 애플리케이션을 개발하는데 주로 사용
구성도의 노란 박스는 디렉토리, 청록 박스는 파일을 나타냄
화살표는 상하위 디렉토리를 의미하며, 실선은 동일 디렉토리 내 존재함을 의미함
모든 구성을 표시하기에는 지면상 불가능하므로 주요 디렉토리 및 파일만 표시
각 디렉토리 및 파일에 대한 상세 내용은 아래 표 참고
디렉토리/파일명 | 구분 | 내용 |
---|---|---|
Root | 디렉토리 | 루트 디렉토리 |
model | 디렉토리 | 프로젝트에서 사용된 딥러닝 모델들의 상위 디렉토리 |
cartoonGAN | 디렉토리 | cartoonGAN 모델에 필요한 파일들이 존재하는 디렉토리 |
hayao, paprika | 디렉토리 | pretrained cartoonGAN 모델 가중치파일(npy)이 존재하는 디렉토리 |
cartoongan.py | 파일 | cartoonGAN 모델의 구동에 필요한 py 파일 |
saved_model | 디렉토리 | 직접 학습시킨 cartoonGAN 모델이 존재하는 디렉토리 |
disney, ladyOscar, monet, Onepiece | 디렉토리 | 직접 학습시킨 cartoonGAN 모델의 variables와 pb 파일이 존재하는 디렉토리 |
Real-ESRGAN | 디렉토리 | real_esrGAN 모델에 필요한 파일들이 존재하는 디렉토리 |
realesrgan | 디렉토리 | real_esrGAN 모델 구동에 필요한 모듈이 존재하는 디렉토리 |
interference_realesrgan.py | 파일 | real_esrGAN 모델의 구동에 필요한 py 파일 |
RealESRGAN_x4plus_anime_6B.pth | 파일 | 애니메이션 이미지에 최적화된 pretrained real_esrGAN 모델 파일 |
static | 디렉토리 | 정적 파일들이 존재하는 디렉토리 |
css | 디렉토리 | html의 화면 스타일 구성을 위한 스타일 시트 파일들이 존재하는 디렉토리 |
img | 디렉토리 | 웹 페이지 화면 구성에 필요한 이미지 파일(로딩 이미지, 홈화면 표시 이미지 등) |
input_img, output_img | 디렉토리 | 사용자가 입력한 사진과 결과 이미지가 저장되는 디렉토리 |
robots.txt, sitemap.xml | 파일 | 검색엔진 최적화(SEO)를 위한 파일 |
templates | 디렉토리 | html 파일들이 존재하는 디렉토리 |
index.html, about.html, service.html, result.html, goods.html, contact.html | 파일 | home/about/service/goods/contact 페이지를 표시할 html 파일 |
flask_app.py | 파일 | flask 메인 py 파일 |
# 모듈 호출
import cv2
import numpy as np
import os
import sys
from datetime import datetime
import tensorflow as tf
from tensorflow.keras.layers import Layer, InputSpec
import PIL
import matplotlib.pyplot as plt
import torch
from torchvision import transforms, models
from flask import Flask, render_template, request, send_from_directory
app = Flask(__name__) # 플라스크 인스턴스 생성
app.debug = False
app.use_reloader= False
@app.route('/robots.txt')
@app.route('/sitemap.xml')
def static_from_root():
return send_from_directory(app.static_folder, request.path[1:])
@app.route('/')
@app.route('/home')
def home():
return render_template('index.html')
@app.route('/service')
def service():
return render_template('service.html')
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/contact')
def contact():
return render_template('contact.html')
@app.route('/goods')
def goods():
return render_template('goods.html')
@app.route('/test', methods = ['GET', 'POST'])
def test():
if request.method == 'POST':
f = request.files['file']
f.save('이미지가 저장될 경로'+f.filename)
image_path = f'이미지가 저장될 경로/{f.filename}'
style = request.form.get('style')
date_string = datetime.now().strftime("%d%m%Y%H%M%S")
#######################################################
# 이미지 분할/이미지 변환/해상도 개선 수행 코드가 존재하는 구간
# 모델 구현 및 테스트에서 작성된 python 코드와 동일하므로 생략
#######################################################
return render_template('result.html', img_file=f'output_img/{style}_{date_string}_out.png' )
if __name__ == '__main__':
app.run()