示例#1
0
        legend=dict(x=1,
                    xanchor='right',
                    y=0,
                    yanchor='bottom',
                    bordercolor='#444',
                    borderwidth=0)
        # legend = dict(x = 0, xanchor = 'left', y =0, yanchor = 'bottom', bordercolor = '#444', borderwidth = 0)
    )

    data = [trace_points, trace_depo] + path_traces
    fig = go.Figure(data=data, layout=layout)
    fig.show()


if __name__ == '__main__':
    args = test_parser()
    t1 = time()
    pretrained = load_model(args.path,
                            embed_dim=128,
                            n_customer=args.n_customer,
                            n_encode_layers=3)
    print(f'model loading time:{time()-t1}s')
    if args.txt is not None:
        datatxt = data_from_txt(args.txt)
        data = []
        for i in range(3):
            elem = [datatxt[i].squeeze(0) for j in range(args.batch)]
            data.append(torch.stack(elem, 0))
    else:
        # data = generate_data(n_samples = 2, n_customer = args.n_customer, seed = args.seed)
        data = []
示例#2
0
import torch
from torch.utils.data import DataLoader
import numpy as np
import cv2
import matplotlib.pyplot as plt
from PIL import Image

from model import PSPNet
from dataset import MyDataset
from config import test_parser
from visualize import unnormalize_show, PIL_show

if __name__ == '__main__':
    arg = test_parser()
    device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
    model = PSPNet(n_classes=arg.n_classes)
    if arg.path is not None:
        print('load model ...')
        model.load_state_dict(torch.load(arg.path, map_location=device))

    model = model.to(device)
    test_dataset = MyDataset(img_dir=arg.img_dir,
                             anno_dir=arg.anno_dir,
                             phase='test')
    n_test_img = len(test_dataset)
    test_loader = DataLoader(test_dataset,
                             batch_size=arg.batch,
                             shuffle=True,
                             pin_memory=True,
                             num_workers=arg.num_workers)
    model.eval()