import torch
import cv2
import numpy as np
from model.unet_model import UNet
import torchvision.transforms as transforms
import torch.nn as nn
from model.u2net import fastU2NET
from model.unetpp3 import NestedUNet
def letter_box(image):
m_width = 368
m_height = 368
scale_x = m_width / image.shape[1]
scale_y = m_height / image.shape[0]
scale = min(scale_x, scale_y)
M = np.array([[scale, 0, (-scale * image.shape[1] + m_width + scale - 1) * 0.5],
[0, scale, (-scale * image.shape[0] + m_height + scale - 1) * 0.5]])
M_T = cv2.invertAffineTransform(M)
value=np.random.randint(0,255)
image = cv2.warpAffine(image ,
M,
(m_width , m_hei
03-11
5952

12-06
578

04-23
1万+

07-23
2076

03-28