This commit is contained in:
yayoimizuha 2024-02-06 19:09:20 +09:00
parent 000b6d7504
commit 1b6494955d
2 changed files with 16 additions and 8 deletions

View File

@ -34,6 +34,8 @@ torch.use_deterministic_algorithms = True
image = Image.open(r"C:\Users\tomokazu\CLionProjects\ameba_blog_downloader\manaka_test.jpg").convert(mode="RGB")
image_arr = from_numpy(np.array(object=image, dtype=np.float32)).unsqueeze(0).permute(0, 3, 1, 2)
py_model: Model = get_model(model_name='resnet50_2020-07-20', max_size=512)
print(py_model.predict_jsons(array(image)))
max_size = 512
example_input = randn(size=[10, 3, 256, 256]).float()

View File

@ -1,27 +1,33 @@
from torch import load, randn, float, half, jit, ones, no_grad
import torch_tensorrt
# import torch_tensorrt
from torchinfo import summary
from torch.nn import Module
from torch.onnx import export
model: Module = load(
f='/home/tomokazu/PycharmProjects/helloproject-ai/data/artifact/facenet-tl_2023-10-15 14:46:51.187699/checkpoints/80.pth')
model.cuda()
f=r"\\tomokazu-ubuntu-server\share\helloproject-ai-data\artifact\facenet-tl_2023-10-22 213825.539264\model.pth")
# model.cuda()
model.eval()
model = model.half()
summary(
model=model,
input_size=[1, 3, 224, 224],
device='cpu',
col_names=["input_size", "output_size", "num_params", "params_percent", "kernel_size", "mult_adds", "trainable"]
)
with no_grad():
example_input = randn(1, 3, 224, 224).cuda().half()
example_input = randn(1, 3, 224, 224)
export(
model=model,
args=example_input,
f="onnx_test.onnx",
f="face_recognition.onnx",
input_names=["input"],
output_names=["output"],
dynamic_axes={
"input": {
0: "batch_size",
2: "height",
3: "width"
# 2: "height",
# 3: "width"
}
},
verbose=False