use flask1, flask2 require python3.7

This commit is contained in:
Sanster 2022-04-18 22:54:34 +08:00
parent 30fdeadc46
commit 0b5494d1f8
2 changed files with 14 additions and 9 deletions

View File

@ -26,6 +26,7 @@ except:
pass pass
from flask import Flask, request, send_file, cli from flask import Flask, request, send_file, cli
# Disable ability for Flask to display warning about using a development server in a production environment. # Disable ability for Flask to display warning about using a development server in a production environment.
# https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356 # https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356
cli.show_server_banner = lambda *_: None cli.show_server_banner = lambda *_: None
@ -52,7 +53,7 @@ BUILD_DIR = os.environ.get("LAMA_CLEANER_BUILD_DIR", "app/build")
class NoFlaskwebgui(logging.Filter): class NoFlaskwebgui(logging.Filter):
def filter(self, record): def filter(self, record):
return 'GET //flaskwebgui-keep-server-alive' not in record.getMessage() return "GET //flaskwebgui-keep-server-alive" not in record.getMessage()
logging.getLogger("werkzeug").addFilter(NoFlaskwebgui()) logging.getLogger("werkzeug").addFilter(NoFlaskwebgui())
@ -91,11 +92,11 @@ def process():
size_limit = int(size_limit) size_limit = int(size_limit)
config = Config( config = Config(
ldm_steps=form['ldmSteps'], ldm_steps=form["ldmSteps"],
hd_strategy=form['hdStrategy'], hd_strategy=form["hdStrategy"],
hd_strategy_crop_margin=form['hdStrategyCropMargin'], hd_strategy_crop_margin=form["hdStrategyCropMargin"],
hd_strategy_crop_trigger_size=form['hdStrategyCropTrigerSize'], hd_strategy_crop_trigger_size=form["hdStrategyCropTrigerSize"],
hd_strategy_resize_limit=form['hdStrategyResizeLimit'], hd_strategy_resize_limit=form["hdStrategyResizeLimit"],
) )
logger.info(f"Origin image shape: {original_shape}") logger.info(f"Origin image shape: {original_shape}")
@ -163,7 +164,7 @@ def set_input_photo():
return send_file( return send_file(
input_image_path, input_image_path,
as_attachment=True, as_attachment=True,
download_name=Path(input_image_path).name, attachment_filename=Path(input_image_path).name,
mimetype=f"image/{get_image_ext(image_in_bytes)}", mimetype=f"image/{get_image_ext(image_in_bytes)}",
) )
else: else:
@ -183,7 +184,10 @@ def main(args):
if args.gui: if args.gui:
app_width, app_height = args.gui_size app_width, app_height = args.gui_size
from flaskwebgui import FlaskUI from flaskwebgui import FlaskUI
ui = FlaskUI(app, width=app_width, height=app_height, host=args.host, port=args.port)
ui = FlaskUI(
app, width=app_width, height=app_height, host=args.host, port=args.port
)
ui.run() ui.run()
else: else:
app.run(host=args.host, port=args.port, debug=args.debug) app.run(host=args.host, port=args.port, debug=args.debug)

View File

@ -1,9 +1,10 @@
torch>=1.8.2 torch>=1.8.2
opencv-python opencv-python
flask_cors flask_cors
flask>=2.1.1 flask==1.1.4
flaskwebgui flaskwebgui
tqdm tqdm
pydantic pydantic
loguru loguru
pytest pytest
markupsafe==2.0.1