import Net
import configparser
import torch
from PIL import Image

config = configparser.ConfigParser()
config.read('./config.ini')
MODEL = config.get("Network", "Model")

transformations = Net.transformations
net = Net.Net()

net.eval()
net.load_state_dict(torch.load(MODEL))

image = Image.open("./html/rwby.jpg")
image = transformations(image).float()
image = torch.autograd.Variable(image[None, ...])

torch.onnx.export(
    net,
    image,
    MODEL.split('pth')[0] + 'onnx',
    export_params=True,
    output_names=['toy-car']
)

print("finish")

[((6, 9, 6, 36), 'configparser.ConfigParser', 'configparser.ConfigParser', ({}, {}), '()', False, 'import configparser\n'), ((11, 6, 11, 15), 'Net.Net', 'Net.Net', ({}, {}), '()', False, 'import Net\n'), ((16, 8, 16, 37), 'PIL.Image.open', 'Image.open', ({(16, 19, 16, 36): '"""./html/rwby.jpg"""'}, {}), "('./html/rwby.jpg')", False, 'from PIL import Image\n'), ((18, 8, 18, 49), 'torch.autograd.Variable', 'torch.autograd.Variable', ({(18, 32, 18, 48): 'image[None, ...]'}, {}), '(image[None, ...])', False, 'import torch\n'), ((14, 20, 14, 37), 'torch.load', 'torch.load', ({(14, 31, 14, 36): 'MODEL'}, {}), '(MODEL)', False, 'import torch\n')]