{
  "id": 413266,
  "title": "submission score error",
  "url": "/competitions/hubmap-hacking-the-human-vasculature/discussion/413266",
  "author_name": "",
  "post_date": "2023-05-27T19:17:42.506859200Z",
  "votes": null,
  "comment_count": 1,
  "views": 0,
  "content": "<h2>This approach is correct?</h2>\n<pre><code>for idx, (image_id, images) in tqdm(enumerate(test_loader), total=len(test_loader)):\n\nimg = images.to(device, dtype=torch.float)\n\nsize = img.size()\n\nw = size[2]\n\n h = size[3]\n\nmsk = np.zeros((512, 512), np.bool8)\n\nwith torch.no_grad():\n    out = model(img)\n\nmasks = out.cpu()  # Access the output tensor directly\nconfidence = 1#torch.max(masks)  # Assuming confidence is the maximum value in the output tensor\nprint (confidence) \n# Process the masks and confidence scores as needed\nfor i in range(len(images)):\n    mask = masks[i]\n    score = confidence\n    plt.figure()\n    plt.imshow(mask.permute(1, 2, 0), cmap='viridis')\n    binary_mask = np.where(mask &gt;= 0.5, 1, 0).astype(bool)  # Convert uint8 mask to bool\n\n    # Assuming you have defined the encode_binary_mask function\n\n    encoded = encode_binary_mask(binary_mask)\n\n    ids.append(image_id[0].split('.')[0])\n    heights.append(h)\n    widths.append(w)\n\n    prediction_strings.append(f\"0 {score} {encoded.decode('utf-8')}\")\n</code></pre>",
  "messages": [
    {
      "id": "2277458",
      "postDate": "05/27/2023 19:17:42",
      "content": "<h2>This approach is correct?</h2>\n<pre><code>for idx, (image_id, images) in tqdm(enumerate(test_loader), total=len(test_loader)):\n\nimg = images.to(device, dtype=torch.float)\n\nsize = img.size()\n\nw = size[2]\n\n h = size[3]\n\nmsk = np.zeros((512, 512), np.bool8)\n\nwith torch.no_grad():\n    out = model(img)\n\nmasks = out.cpu()  # Access the output tensor directly\nconfidence = 1#torch.max(masks)  # Assuming confidence is the maximum value in the output tensor\nprint (confidence) \n# Process the masks and confidence scores as needed\nfor i in range(len(images)):\n    mask = masks[i]\n    score = confidence\n    plt.figure()\n    plt.imshow(mask.permute(1, 2, 0), cmap='viridis')\n    binary_mask = np.where(mask &gt;= 0.5, 1, 0).astype(bool)  # Convert uint8 mask to bool\n\n    # Assuming you have defined the encode_binary_mask function\n\n    encoded = encode_binary_mask(binary_mask)\n\n    ids.append(image_id[0].split('.')[0])\n    heights.append(h)\n    widths.append(w)\n\n    prediction_strings.append(f\"0 {score} {encoded.decode('utf-8')}\")\n</code></pre>",
      "rawMarkdown": "## This approach is correct?\n \n    for idx, (image_id, images) in tqdm(enumerate(test_loader), total=len(test_loader)):\n    \n    img = images.to(device, dtype=torch.float)\n    \n    size = img.size()\n    \n    w = size[2]\n    \n     h = size[3]\n     \n    msk = np.zeros((512, 512), np.bool8)\n\n    with torch.no_grad():\n        out = model(img)\n\n    masks = out.cpu()  # Access the output tensor directly\n    confidence = 1#torch.max(masks)  # Assuming confidence is the maximum value in the output tensor\n    print (confidence) \n    # Process the masks and confidence scores as needed\n    for i in range(len(images)):\n        mask = masks[i]\n        score = confidence\n        plt.figure()\n        plt.imshow(mask.permute(1, 2, 0), cmap='viridis')\n        binary_mask = np.where(mask >= 0.5, 1, 0).astype(bool)  # Convert uint8 mask to bool\n\n        # Assuming you have defined the encode_binary_mask function\n        \n        encoded = encode_binary_mask(binary_mask)\n\n        ids.append(image_id[0].split('.')[0])\n        heights.append(h)\n        widths.append(w)\n\n        prediction_strings.append(f\"0 {score} {encoded.decode('utf-8')}\")",
      "votes": null
    },
    {
      "id": "2367110",
      "postDate": "07/31/2023 11:08:34",
      "content": "<p>was this approach correct in the end </p>",
      "rawMarkdown": "was this approach correct in the end",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2367110,
      "author_name": "blueprint123",
      "author_url": "",
      "post_date": "07/31/2023 11:08:34",
      "content": "<p>was this approach correct in the end </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2277458": "## This approach is correct?\n \n    for idx, (image_id, images) in tqdm(enumerate(test_loader), total=len(test_loader)):\n    \n    img = images.to(device, dtype=torch.float)\n    \n    size = img.size()\n    \n    w = size[2]\n    \n     h = size[3]\n     \n    msk = np.zeros((512, 512), np.bool8)\n\n    with torch.no_grad():\n        out = model(img)\n\n    masks = out.cpu()  # Access the output tensor directly\n    confidence = 1#torch.max(masks)  # Assuming confidence is the maximum value in the output tensor\n    print (confidence) \n    # Process the masks and confidence scores as needed\n    for i in range(len(images)):\n        mask = masks[i]\n        score = confidence\n        plt.figure()\n        plt.imshow(mask.permute(1, 2, 0), cmap='viridis')\n        binary_mask = np.where(mask >= 0.5, 1, 0).astype(bool)  # Convert uint8 mask to bool\n\n        # Assuming you have defined the encode_binary_mask function\n        \n        encoded = encode_binary_mask(binary_mask)\n\n        ids.append(image_id[0].split('.')[0])\n        heights.append(h)\n        widths.append(w)\n\n        prediction_strings.append(f\"0 {score} {encoded.decode('utf-8')}\")",
    "2367110": "was this approach correct in the end"
  },
  "source": "meta"
}