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")

[((76, 103), 'configparser.ConfigParser', 'configparser.ConfigParser', ([], {}), '()\n', (101, 103), False, 'import configparser\n'), ((216, 225), 'Net.Net', 'Net.Net', ([], {}), '()\n', (223, 225), False, 'import Net\n'), ((286, 315), 'PIL.Image.open', 'Image.open', (['"""./html/rwby.jpg"""'], {}), "('./html/rwby.jpg')\n", (296, 315), False, 'from PIL import Image\n'), ((363, 404), 'torch.autograd.Variable', 'torch.autograd.Variable', (['image[None, ...]'], {}), '(image[None, ...])\n', (386, 404), False, 'import torch\n'), ((258, 275), 'torch.load', 'torch.load', (['MODEL'], {}), '(MODEL)\n', (268, 275), False, 'import torch\n')]