download small size image

This commit is contained in:
Sanster 2022-02-09 18:01:19 +08:00
parent c5f4accbff
commit 5450fd2234
2 changed files with 20 additions and 9 deletions

View File

@ -96,7 +96,13 @@ export default function Editor(props: EditorProps) {
context.clearRect(0, 0, context.canvas.width, context.canvas.height)
const currRender = renders[renders.length - 1]
if (currRender?.src) {
context.drawImage(currRender, 0, 0)
context.drawImage(
currRender,
0,
0,
original.naturalWidth,
original.naturalHeight
)
} else {
context.drawImage(original, 0, 0)
}

21
main.py
View File

@ -14,9 +14,14 @@ import torch
from flask import Flask, request, send_file
from flask_cors import CORS
from lama_cleaner.helper import (download_model, load_img, norm_img,
numpy_to_bytes, pad_img_to_modulo,
resize_max_size)
from lama_cleaner.helper import (
download_model,
load_img,
norm_img,
numpy_to_bytes,
pad_img_to_modulo,
resize_max_size,
)
NUM_THREADS = str(multiprocessing.cpu_count())
@ -63,11 +68,11 @@ def process():
res_np_img = run(image, mask)
# resize to original size
res_np_img = cv2.resize(
res_np_img,
dsize=(original_shape[1], original_shape[0]),
interpolation=interpolation,
)
# res_np_img = cv2.resize(
# res_np_img,
# dsize=(original_shape[1], original_shape[0]),
# interpolation=interpolation,
# )
return send_file(
io.BytesIO(numpy_to_bytes(res_np_img)),