def transform_async(filename, email, model):
# ????
content_file_path = join(app.config['UPLOAD_FOLDER'], filename)
model_file_path = join(app.config['MODEL_FOLDER'], model)
output_folder = app.config['OUTPUT_FOLDER']
output_filename = filename
(shotname, extension) = splitext(output_filename)
output_filename = shotname + '-' + model + extension
output_file_path = join(output_folder, output_filename)
command = 'python eval.py --CONTENT_IMAG %s --MODEL_PATH %s --OUTPUT_FOLDER %s' % (
content_file_path, model_file_path, output_folder)
status, output = subprocess.getstatusoutput(command)
# ????
print(status, output)
# ????
if status == 0:
with app.app_context():
msg = Message("IMAGE-STYLE-TRANSFER",
sender=app.config['MAIL_USERNAME'], recipients=[email])
msg.body = filename
with app.open_resource(output_file_path) as f:
mime_type = 'image/jpg' if splitext(
filename)[1] is not '.png' else 'image/png'
msg.attach(filename, mime_type, f.read())
mail.send(msg)
else:
with app.app_context():
msg = Message("IMAGE-STYLE-TRANSFER",
sender=app.config['MAIL_USERNAME'], recipients=[email])
msg.body = "CONVERT ERROR\n" + filename + "\n HELP - http://host:port/help"
mail.send(msg)
remove_files.apply_async(
args=[[content_file_path, output_file_path]], countdown=60)
评论列表
文章目录