Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update whatIsPipo and howToUse page design #18

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ libs/__pycache__/painting.cpython-38.pyc
libs/__pycache__/utils.cpython-38.pyc
*.pyc
*.pyc
*.pyc
15 changes: 14 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# 2021 EasyPipo
# 2023 EasyPipo

"""Temporary to avoid No Attribute'asscalar' Error
File: __init__.py
Created: 2023-06-22

@author: Minku-Koo
LastModifyDate: 2023-06-22
LastModifier: Ji-yong219
"""
import numpy
def patch_asscalar(a):
return a.item()
setattr(numpy, "asscalar", patch_asscalar)
15 changes: 7 additions & 8 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from web.app import create_app
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.DEBUG) #logging.ERROR

# Temporary to avoid No Attribute'asscalar' Error
import numpy
def patch_asscalar(a):
return a.item()
setattr(numpy, "asscalar", patch_asscalar)
from src.main.app import create_app

app = create_app()
app.run()
if __name__ == "__main__":
app = create_app()
app.run()
Binary file modified __pycache__/__main__.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/brush.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/colorCode.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/drawLine.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/getSession.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/imageProcessing.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/painting.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/painting2.cpython-38.pyc
Binary file not shown.
Binary file removed libs/__pycache__/utils.cpython-38.pyc
Binary file not shown.
File renamed without changes.
30 changes: 30 additions & 0 deletions src/main/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# flask create app
# Author : Ji-yong219
# Project Start:: 2021.03.10.
# Last Modified from Ji-yong 2023.06.22.

from flask import Flask
from src.main.easypipo.index.indexController import contoller as idx_controller
from src.main.easypipo.imageProcess.imageContoller import contoller as img_controller
import os

"""App factory
File: app.py
Created: 2023-06-22

@author: Ji-yong219
LastModifyDate:
LastModifier:
"""
def create_app():
app = Flask(__name__)
app.register_blueprint(img_controller, url_prefix="/imageProcess")
app.register_blueprint(idx_controller)
app.template_folder = "webapp/templates"
app.static_folder = "webapp/static"
app.secret_key = "wh2fdjqw3k4rvna5dml46smv"

UPLOAD_FOLDER = f"{os.getcwd()}/src/main/webapp/static/org_image"
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

return app
121 changes: 121 additions & 0 deletions src/main/easypipo/imageProcess/imageContoller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Image Contoller
# Author : Ji-yong219
# Project Start:: 2021.03.10.
# Last Modified from Ji-yong 2023.07.02.

from flask import (
request,
render_template,
jsonify,
Blueprint,
redirect,
url_for,
session
)
import os

from ..imageProcess.imageService import (
process_start,
reduce_color,
draw_line,
numbering_sector
)

contoller = Blueprint("image_controller", __name__)


@contoller.route("/processStart", methods=["POST"])
def processStart():
image_path = request.form['image_path']
image_name = os.path.basename(image_path)
image_path_o = f"{os.getcwd()}/src/main/webapp/static/org_image/{image_name}"
image_path_r = f"{os.getcwd()}/src/main/webapp/static/render_image/{image_name}"

target, img_name = process_start(image_name, image_path_o, image_path_r)

return jsonify(
target = target,
img_name = img_name
)


@contoller.route("/reduceColor", methods=["POST"])
def reduceColor():
image_path = request.form['image_path']
img_name = os.path.basename(image_path)
image_path = f"{os.getcwd()}/src/main/webapp/static/render_image/{img_name}"

reduce_data = request.form['reduce_data']

clusters = [int(i) for i in reduce_data.split(',')[:3]]

target, img_name, colorNames, colors = reduce_color(
img_name,
image_path,
reduce_data,
clusters,
)

session['colorNames'] = colorNames
session['colors'] = colors

return jsonify(
target = target,
img_name = img_name,
clusters = clusters
)


@contoller.route("/drawLine", methods=["POST"])
def drawLine():
image_path = request.form['image_path']
img_name = os.path.basename(image_path).split("?")[0]
session['reduce_img_name'] = img_name
reduce_data = request.form['reduce_data']

colors = session['colors']

target, img_name, img_lab, lab = draw_line(
img_name,
reduce_data,
colors
)

session['img_lab'] = img_lab
session['lab'] = lab
session['linedraw_img_name'] = img_name

return jsonify(
target = target,
img_name = img_name
)


@contoller.route("/numbering", methods=["POST"])
def numbering():
image_path = request.form['image_path']
img_name = os.path.basename(image_path).split("?")[0]
reduce_data = request.form['reduce_data']

reduce_img_name = session['reduce_img_name']
linedraw_img_name = session['linedraw_img_name']

colors = session['colors']
colorNames = session['colorNames']
img_lab = session['img_lab']
lab = session['lab']

target, img_name = numbering_sector(
reduce_img_name,
linedraw_img_name,
reduce_data,
colors,
colorNames,
img_lab,
lab
)

return jsonify(
target = target,
img_name = img_name
)
Loading