text: from __future__ import division
  
  from models import *
  from utils.utils import *
  from utils.datasets import *
  from utils.parse_config import *
  
  import os
  import sys
  import time
  import datetime
  import argparse
  import tqdm
  
  import torch
  import torch.optim as optim
  
  from torch.utils.data import DataLoader
  from torchvision import datasets
  from torchvision import transforms
  from torch.autograd import Variable
  
  
  def evaluate(model, path, iou_thres, conf_thres, nms_thres, img_size, batch_size):
      model.eval()
  
      # 加载数据集
      dataset = ListDataset(path, img_size=img_size, augment=False, multiscale=False)
      dataloader = torch.utils.data.DataLoader(dataset,
                                               batch_size=batch_size,
                                               shuffle=False,
                                               num_workers=1,
                                               collate_fn=dataset.collate_fn)
  
      FloatTensor = torch.cuda.FloatTensor if torch.cuda.is_available() else torch.FloatTensor
      labels = []
      sample_metrics = [] # 元组列表：(TP, confs, pred)
  
      for batch_i, (_, imgs, targets) in enumerate(tqdm.tqdm(dataloader, desc="Detecting objects")):
  
          # 抽取数据
          imgs = Variable(imgs.type(FloatTensor), requires_grad=False)
  
          labels += targets[:, 1].tolist()
          targets[:, 2:] = xywh2xyxy(targets[:, 2:])
          targets[:, 2:] *= img_size
  
          with torch.no_grad():
              outputs = model(imgs)
              outputs = non_max_suppression(outputs, conf_thres=conf_thres, nms_thres=nms_thres)
  
          pass
  