This code is wrong in pytorch1.3 result=[]

Deep_learning_labora: <h1><a name="h-1" class="anchor" href="#h-1"></a>生成验证集的结果，并检查验证集上的预测效果</h1>
<blockquote>
<p>[ptrblck] Add translation:<br>
Generate the results of the validation set and check the prediction effect on the validation set</p>
</blockquote>
<pre data-code-wrap="python"><code class="lang-python">def boxes_to_lines(preds, image_id):
 
    r = []
    for bbox, label, score in zip(
        preds[0]["boxes"].cpu().detach().numpy(),
        preds[0]["labels"].cpu().detach().numpy(),
        preds[0]["scores"].cpu().detach().numpy(),
    ):
        # torchvision生成的bounding box格式为xyxy，需要转成xywh
        xyxy = list(bbox)
        xywh = [xyxy[0], xyxy[1], xyxy[2] - xyxy[0], xyxy[3]- xyxy[1]]
        r.append(
            {
                "image_id": image_id,
                "bbox": xywh,
                "category_id": label,
                "score": score,
            }
        )
    return r
 
 
def output_result(image_paths):
    result = []
    model = get_model(num_classes=NUM_CLASS)
    if os.path.exists(MODEL_PATH):
        model.load_state_dict(torch.load(MODEL_PATH))
    model.to(device)
    model.eval()
    for image_path in tqdm(image_paths):
        img = Image.open(image_path)
        image_id = os.path.basename(image_path).split(".")[0]
        transform = T.Compose([T.ToTensor()])  # Defing PyTorch Transform
        img_tensor = transform(img)  # Apply the transform to the image
        preds = model([img_tensor.to(device)])
        result += boxes_to_lines(preds, image_id)
 
    bboxes, labels = list(zip(*[
        (bbox, label)
        for bbox, label in zip(
            preds[0]["boxes"].cpu().detach().numpy(),
            preds[0]["labels"].cpu().detach().numpy()) ]))
    img = draw_boxes(np.array(img), bboxes, labels)
    plt.imshow(img)
 
    return result
 
result = output_result(val_image_paths)
</code></pre>

ptrblck: <p>Could you post the error message you are seeing and explain, what is not working?</p>
<p>PS: I’ve translated the title and added another translation in your post, but am still unsure, what the issue is. Could you please post the translated text, in your follow-up?</p>

Deep_learning_labora: <p>value error: not enough values to unpack (expected 2, got 0)</p>

Deep_learning_labora: <pre><code>    result += boxes_to_lines(preds, image_id)
</code></pre>
<p>我打印result result返回空</p>

ptrblck: <p>Could you post the shapes of <code>preds[0]["boxes"]</code>, <code>preds[0]["labels"]</code>, and `preds[0][“scores”], please?</p>

Deep_learning_labora: <p>我打印了result没有返回值，得到的是空值</p>

Deep_learning_labora: <p>preds[0][“boxes”]，preds[0][“labels”]和`preds [0] [“分数”]都是空值</p>

Deep_learning_labora: <p>Torchvision0.3.0可以运行，Torchvision0.4返回空值</p>

ptrblck: <p>Using Google translate, it seems that <code>preds</code> are empty, which would mean that your model is not returning anything in this line:</p>
<pre><code class="lang-python">preds = model([img_tensor.to(device)])
</code></pre>
<p>Check your model’s <code>forward</code> method and make sure you are returning the output.</p>
<p>PS: Again, could you please translate your posts before posting them?</p>

Deep_learning_labora: <p>As a result, there is no imported model prediction and the value is empty. Why is there such a strange suffix?</p>

Deep_learning_labora: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/2/222a8e635a4828545f4b081089ead1a3ff40c10b.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/222a8e635a4828545f4b081089ead1a3ff40c10b" title="Screenshot_20200426_000457"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/2/222a8e635a4828545f4b081089ead1a3ff40c10b_2_690x444.jpeg" alt="Screenshot_20200426_000457" data-base62-sha1="4SfpqXRrzL9eZWEtzqyQuqBPU95" width="690" height="444" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/2/222a8e635a4828545f4b081089ead1a3ff40c10b_2_690x444.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/2/2/222a8e635a4828545f4b081089ead1a3ff40c10b_2_1035x666.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/2/222a8e635a4828545f4b081089ead1a3ff40c10b.jpeg 2x" data-dominant-color="A8A49D"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot_20200426_000457</span><span class="informations">1080×696 115 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Now it can be predicted, but there are many duplicate detection</p>