update
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tomokazu Katayama 2023-10-22 07:44:40 +09:00
parent 6e2c6260fd
commit 92749421ed
2 changed files with 33 additions and 6 deletions

View File

@ -1,14 +1,28 @@
from os import getcwd
from os.path import join
from onnxruntime import InferenceSession, SessionOptions
from onnxruntime import InferenceSession, SessionOptions, __version__
from PIL import Image
import numpy
onnx_session = InferenceSession(
path_or_bytes="/home/tomokazu/.insightface/models/buffalo_l/w600k_r50.onnx",
path_or_bytes="test_script/retinaface.onnx",
providers=[
'CUDAExecutionProvider',
('TensorrtExecutionProvider', {
'trt_engine_cache_enable': True,
'trt_engine_cache_path': join(getcwd(), 'onnx_cache'),
'trt_fp16_enable': True,
})
}),
'CPUExecutionProvider'
]
)
print(__version__)
image_arr = numpy.expand_dims(numpy.array(
Image.open(r'C:\Users\tomokazu\CLionProjects\ameba_blog_downloader\manaka_test.jpg').convert('RGB')), 0).transpose(
0, 3, 1, 2).astype(numpy.float32)
print(image_arr)
print(image_arr.shape)
res = onnx_session.run(input_feed={'input': image_arr}, output_names=["bbox", "confidence", "landmark"])
for val in res:
print(val)
print(val.shape)

View File

@ -1,3 +1,4 @@
import random
from itertools import product
from math import ceil
@ -19,9 +20,18 @@ from torchvision.utils import _log_api_usage_once
# model: Model = get_model(model_name='resnet50_2020-07-20', max_size=512, device='cuda')
# model.eval()
# Python random
seed = 0
random.seed(seed)
# Numpy
np.random.seed(seed)
# Pytorch
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
torch.use_deterministic_algorithms = True
image = Image.open(r"C:\Users\tomokazu\すぐ消す\野中美希.jpg").convert(mode="RGB")
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)
max_size = 512
@ -37,6 +47,7 @@ retina_model = RetinaFace(
).eval()
print(image_arr.size())
print(image_arr)
torch.onnx.export(
model=retina_model,
@ -58,7 +69,9 @@ torch.onnx.export(
with no_grad():
bbox_regressions, classifications, ldm_regressions = retina_model(image_arr)
print(bbox_regressions)
print(bbox_regressions.data[0][:, :2])
print(classifications)
print(ldm_regressions)
# print(bbox_regressions.data[0][:, :2])
print(bbox_regressions.size())
print(classifications.size())
print(ldm_regressions.size())