File size: 449 Bytes
35aaf1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import torch
import numpy as np
import random
import onnxruntime as ort
def set_random_seed(seed=0):
    ort.set_seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.backends.cudnn.deterministic = True
    random.seed(seed)
    np.random.seed(seed)

def runonnx(model_path, **kwargs):
    ort_session = ort.InferenceSession(model_path)
    outputs = ort_session.run(
        None,
        kwargs
    )
    return outputs