update
This commit is contained in:
parent
000b6d7504
commit
1b6494955d
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 213825.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
|
||||
|
|
|
|||
Loading…
Reference in New Issue