{
  "id": 302241,
  "title": "Logging F2 score while training YOLOv5",
  "url": "/competitions/tensorflow-great-barrier-reef/discussion/302241",
  "author_name": "Sanchit Vijay",
  "post_date": "2022-01-21T14:32:14.366000",
  "votes": 79,
  "comment_count": 28,
  "views": 0,
  "content": "<p>This post is continuation of <a href=\"https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343\" target=\"_blank\">link</a>.<br>\nIn order to visualize and log F2 score during validation of <a href=\"https://github.com/ultralytics/yolov5\" target=\"_blank\">yolov5</a> follow the steps in <a href=\"https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343\" target=\"_blank\">this</a> discussion, (thanks to <a href=\"https://www.kaggle.com/amiiiney\" target=\"_blank\">@amiiiney</a>) or below I am providing all the steps.</p>\n<ul>\n<li>In <code>metrics.py</code> file<br>\n-- change <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/metrics.py#L73\" target=\"_blank\">this</a> line to <code>f2 = 5 * p * r / (4 * p + r + 1e-16)</code> and below this change <code>f1</code> to <code>f2</code> everywhere in the <code>ap_per_class</code> function and return <code>return tp, fp, p, r, f2, ap, unique_classes.astype(\"int32\")</code>.<br>\n-- next modify <code>fitness</code> function as below:</li>\n</ul>\n<pre><code>def fitness(x):\n    # Model fitness as a weighted combination of metrics\n    w = [0.0, 0.0, 0.0, 0.0, 1.0] # weights for [P, R, mAP@0.5, mAP@0.5:0.95, F2@0.3:0.8]\n    return (x[:, :5] * w).sum(1)\n</code></pre>\n<ul>\n<li>In <code>val.py</code> file<br>\n-- modify <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L160\" target=\"_blank\">this</a> line with <code>iouv= torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)</code><br>\n-- change <code>f1</code> in <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L176\" target=\"_blank\">this</a> to <code>f2</code> and same for <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L254\" target=\"_blank\">this</a> line and -- modify next 2 lines to </li>\n</ul>\n<pre><code>ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\nmp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n</code></pre>\n<p>-- change the following two lines in val.py <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\" target=\"_blank\">here</a> and <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263\" target=\"_blank\">here</a>, we can have Yolo display the F2 on the command line while training. (thanks <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> )<br>\n--and <code>return (mp, mr, map50, map, f2, *(loss.cpu() / len(dataloader)).tolist()), maps, t</code></p>\n<ul>\n<li>In <a href=\"https://github.com/ultralytics/yolov5/blob/master/utils/loggers/__init__.py\" target=\"_blank\">this</a> file<br>\n-- add <code>\"metrics/F2\"</code> to <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47\" target=\"_blank\">this</a> list and in a list <code>self.best_keys</code> in next line <code>\"best/F2\"</code> <br>\n-- In <code>on_fit_epoch_end</code> function modify <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L130\" target=\"_blank\">this</a> line with <code>best_results = [epoch] + vals[3:8]</code> </li>\n</ul>\n<hr>\n<p>After making these modifications you will be able to visualize and log F2 score on <code>wandb</code>(not sure about other loggers).</p>\n<ul>\n<li>Thanks to <a href=\"https://www.kaggle.com/amiiiney\" target=\"_blank\">@amiiiney</a> for providing solution.</li>\n<li>Thanks to <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> for suggestion.<br>\nSugggestions or modifications are welcome :)</li>\n</ul>\n<p>LAST UPDATED:</p>\n<ul>\n<li>22 Jan, 2 PM (IST)</li>\n<li>1 Feb, 11 AM (IST)</li>\n</ul>",
  "messages": [
    {
      "id": 1659077,
      "postDate": "2022-01-21T14:32:14.367Z",
      "content": "<p>This post is continuation of <a href=\"https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343\" target=\"_blank\">link</a>.<br>\nIn order to visualize and log F2 score during validation of <a href=\"https://github.com/ultralytics/yolov5\" target=\"_blank\">yolov5</a> follow the steps in <a href=\"https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343\" target=\"_blank\">this</a> discussion, (thanks to <a href=\"https://www.kaggle.com/amiiiney\" target=\"_blank\">@amiiiney</a>) or below I am providing all the steps.</p>\n<ul>\n<li>In <code>metrics.py</code> file<br>\n-- change <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/metrics.py#L73\" target=\"_blank\">this</a> line to <code>f2 = 5 * p * r / (4 * p + r + 1e-16)</code> and below this change <code>f1</code> to <code>f2</code> everywhere in the <code>ap_per_class</code> function and return <code>return tp, fp, p, r, f2, ap, unique_classes.astype(\"int32\")</code>.<br>\n-- next modify <code>fitness</code> function as below:</li>\n</ul>\n<pre><code>def fitness(x):\n    # Model fitness as a weighted combination of metrics\n    w = [0.0, 0.0, 0.0, 0.0, 1.0] # weights for [P, R, mAP@0.5, mAP@0.5:0.95, F2@0.3:0.8]\n    return (x[:, :5] * w).sum(1)\n</code></pre>\n<ul>\n<li>In <code>val.py</code> file<br>\n-- modify <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L160\" target=\"_blank\">this</a> line with <code>iouv= torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)</code><br>\n-- change <code>f1</code> in <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L176\" target=\"_blank\">this</a> to <code>f2</code> and same for <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L254\" target=\"_blank\">this</a> line and -- modify next 2 lines to </li>\n</ul>\n<pre><code>ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\nmp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n</code></pre>\n<p>-- change the following two lines in val.py <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\" target=\"_blank\">here</a> and <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263\" target=\"_blank\">here</a>, we can have Yolo display the F2 on the command line while training. (thanks <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> )<br>\n--and <code>return (mp, mr, map50, map, f2, *(loss.cpu() / len(dataloader)).tolist()), maps, t</code></p>\n<ul>\n<li>In <a href=\"https://github.com/ultralytics/yolov5/blob/master/utils/loggers/__init__.py\" target=\"_blank\">this</a> file<br>\n-- add <code>\"metrics/F2\"</code> to <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47\" target=\"_blank\">this</a> list and in a list <code>self.best_keys</code> in next line <code>\"best/F2\"</code> <br>\n-- In <code>on_fit_epoch_end</code> function modify <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L130\" target=\"_blank\">this</a> line with <code>best_results = [epoch] + vals[3:8]</code> </li>\n</ul>\n<hr>\n<p>After making these modifications you will be able to visualize and log F2 score on <code>wandb</code>(not sure about other loggers).</p>\n<ul>\n<li>Thanks to <a href=\"https://www.kaggle.com/amiiiney\" target=\"_blank\">@amiiiney</a> for providing solution.</li>\n<li>Thanks to <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> for suggestion.<br>\nSugggestions or modifications are welcome :)</li>\n</ul>\n<p>LAST UPDATED:</p>\n<ul>\n<li>22 Jan, 2 PM (IST)</li>\n<li>1 Feb, 11 AM (IST)</li>\n</ul>",
      "rawMarkdown": "This post is continuation of [link](https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343).\nIn order to visualize and log F2 score during validation of [yolov5](https://github.com/ultralytics/yolov5) follow the steps in [this](https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343) discussion, (thanks to @amiiiney) or below I am providing all the steps.\n\n- In `metrics.py` file\n-- change [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/metrics.py#L73) line to `f2 = 5 * p * r / (4 * p + r + 1e-16)` and below this change `f1` to `f2` everywhere in the `ap_per_class` function and return `return tp, fp, p, r, f2, ap, unique_classes.astype(\"int32\")`.\n-- next modify `fitness` function as below:\n```\ndef fitness(x):\n    # Model fitness as a weighted combination of metrics\n    w = [0.0, 0.0, 0.0, 0.0, 1.0] # weights for [P, R, mAP@0.5, mAP@0.5:0.95, F2@0.3:0.8]\n    return (x[:, :5] * w).sum(1)\n```\n\n- In `val.py` file\n-- modify [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L160) line with `iouv= torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)`\n-- change `f1` in [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L176) to `f2` and same for [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L254) line and -- modify next 2 lines to \n```\nap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\nmp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n```\n-- change the following two lines in val.py [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175) and [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263), we can have Yolo display the F2 on the command line while training. (thanks @cdeotte )\n--and `return (mp, mr, map50, map, f2, *(loss.cpu() / len(dataloader)).tolist()), maps, t`\n\n- In [this](https://github.com/ultralytics/yolov5/blob/master/utils/loggers/__init__.py) file\n-- add `\"metrics/F2\"` to [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47) list and in a list `self.best_keys` in next line `\"best/F2\"` \n-- In `on_fit_epoch_end` function modify [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L130) line with `best_results = [epoch] + vals[3:8]` \n\n---\n\nAfter making these modifications you will be able to visualize and log F2 score on `wandb`(not sure about other loggers).\n- Thanks to @amiiiney for providing solution.\n- Thanks to @cdeotte for suggestion.\nSugggestions or modifications are welcome :)\n\nLAST UPDATED:\n- 22 Jan, 2 PM (IST)\n- 1 Feb, 11 AM (IST)",
      "votes": 78
    },
    {
      "id": 1670785,
      "postDate": "2022-01-31T21:35:56.273Z",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> and <a href=\"https://www.kaggle.com/amiiiney\" target=\"_blank\">@amiiiney</a>, this works perfectly! Note the first file's name is <code>metrics.py</code> not <code>matrix.py</code>. Also, if we change the following two lines in <code>val.py</code> <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\" target=\"_blank\">here</a> and <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263\" target=\"_blank\">here</a>, we can have Yolo display the F2 on the command line while training.</p>",
      "rawMarkdown": "Thanks @sanchitvj and @amiiiney, this works perfectly! Note the first file's name is `metrics.py` not `matrix.py`. Also, if we change the following two lines in `val.py` [here][1] and [here][2], we can have Yolo display the F2 on the command line while training.\n\n[1]: https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\n[2]: https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263",
      "votes": 5,
      "replies": [
        {
          "id": 1671042,
          "postDate": "2022-02-01T05:38:39.633Z",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> for valuable suggestion. I have made the changes :)</p>",
          "rawMarkdown": "Thank you @cdeotte for valuable suggestion. I have made the changes :)",
          "votes": 1
        },
        {
          "id": 1671048,
          "postDate": "2022-02-01T05:47:25.557Z",
          "content": "<p>I have a question for you experts！！<br>\nI trained yolov5s6 with size3600 and then used the following notebook <a href=\"https://www.kaggle.com/kocha1/only-yolov5-tracking-lb-642\" target=\"_blank\">https://www.kaggle.com/kocha1/only-yolov5-tracking-lb-642</a> for inference. conf0.34 iou0.5, in the case where I only change the img-size of inference:<br>\nimg-size 3600 lb0.579<br>\nimg-size 9000 lb0.577<br>\nWhy does my self-trained model infer no change at large scale?<br>\nHave you encountered this situation?</p>",
          "rawMarkdown": "I have a question for you experts！！\nI trained yolov5s6 with size3600 and then used the following notebook https://www.kaggle.com/kocha1/only-yolov5-tracking-lb-642 for inference. conf0.34 iou0.5, in the case where I only change the img-size of inference:\nimg-size 3600 lb0.579\nimg-size 9000 lb0.577\nWhy does my self-trained model infer no change at large scale?\nHave you encountered this situation?",
          "votes": 1
        }
      ]
    },
    {
      "id": 1674965,
      "postDate": "2022-02-03T22:57:08.903Z",
      "content": "<blockquote>\n  <p>change the following two lines in val.py <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\" target=\"_blank\">here</a> and <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263\" target=\"_blank\">here</a>, we can have Yolo display the F2 on the command line while training.</p>\n</blockquote>\n<p>What should I change in these lines? i tried to add \"f2\" but it did not work. Need help.</p>",
      "rawMarkdown": "> change the following two lines in val.py [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175) and [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263), we can have Yolo display the F2 on the command line while training.\n\nWhat should I change in these lines? i tried to add \"f2\" but it did not work. Need help.\n",
      "votes": 3,
      "replies": [
        {
          "id": 1675041,
          "postDate": "2022-02-04T01:31:22.747Z",
          "content": "<p>Change the first line to <br>\n<code>s = ('%20s' + '%11s' * 6) % ('Class', 'Images', 'Labels', 'P', 'R', 'F2', 'mAP@.5')</code></p>\n<p>Change the second line to<br>\n<code>LOGGER.info(pf % ('all', seen, nt.sum(), mp, mr, f2, map50))</code></p>\n<p>(and do all the other changes in original discussion post above)</p>",
          "rawMarkdown": "Change the first line to \n`s = ('%20s' + '%11s' * 6) % ('Class', 'Images', 'Labels', 'P', 'R', 'F2', 'mAP@.5')`\n\nChange the second line to\n`LOGGER.info(pf % ('all', seen, nt.sum(), mp, mr, f2, map50))`\n\n(and do all the other changes in original discussion post above)",
          "votes": 5
        },
        {
          "id": 1675702,
          "postDate": "2022-02-04T12:22:32.880Z",
          "content": "<p>Thank you, it is working now.</p>",
          "rawMarkdown": "Thank you, it is working now.",
          "votes": 1
        }
      ]
    },
    {
      "id": 1674065,
      "postDate": "2022-02-03T07:44:18.903Z",
      "content": "<p>Why change the <code>self.csv = False</code>? If we keep this line in <code>__init__.py</code> , we can have the PLT chart result.</p>",
      "rawMarkdown": "Why change the `self.csv = False`? If we keep this line in `__init__.py` , we can have the PLT chart result.",
      "votes": 4
    },
    {
      "id": 1668295,
      "postDate": "2022-01-29T14:07:59.347Z",
      "content": "<p>I think, The code should only modify w = [0.2, 0.8, 0.0, 0.0] in fitness function. Because, in F2 score P less important than R 4 times.</p>",
      "rawMarkdown": "I think, The code should only modify w = [0.2, 0.8, 0.0, 0.0] in fitness function. Because, in F2 score P less important than R 4 times.\n",
      "votes": 1,
      "replies": [
        {
          "id": 1670282,
          "postDate": "2022-01-31T11:39:28.160Z",
          "content": "<p><code>w = [0.0, 0.0, 0.0, 0.0, 1.0]</code> here we are giving priority to F2 score. So by default P is less prioritized</p>",
          "rawMarkdown": "`w = [0.0, 0.0, 0.0, 0.0, 1.0]` here we are giving priority to F2 score. So by default P is less prioritized",
          "votes": 1
        }
      ]
    },
    {
      "id": 1667045,
      "postDate": "2022-01-28T09:30:12.307Z",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a>,<br>\nDo you use the same hyperparameters as \"Sheep\" shared in this post: <a href=\"https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data\" target=\"_blank\"></a><a href=\"https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data\" target=\"_blank\">https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data</a> </p>\n<p>Do you use albumentations and is the LB score that you reached with yolov5l6 or a smaller model?  </p>\n<p>Thank you for the interesting discussions in this competition!</p>",
      "rawMarkdown": "Hi @sanchitvj,\nDo you use the same hyperparameters as \"Sheep\" shared in this post: [https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data ](https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data)\n\nDo you use albumentations and is the LB score that you reached with yolov5l6 or a smaller model?  \n\nThank you for the interesting discussions in this competition!",
      "votes": 1,
      "replies": [
        {
          "id": 1667073,
          "postDate": "2022-01-28T09:44:41.597Z",
          "content": "<p>Hi, no hyperparams are different, no albumentations and model is s6 only. Happy to help :) </p>",
          "rawMarkdown": "Hi, no hyperparams are different, no albumentations and model is s6 only. Happy to help :) ",
          "votes": 3
        },
        {
          "id": 1667110,
          "postDate": "2022-01-28T10:22:57.100Z",
          "content": "<p>Oh wow! TY <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> I'm now testing what the right img size is. What img size do you use for train and infer now?</p>",
          "rawMarkdown": "Oh wow! TY @sanchitvj I'm now testing what the right img size is. What img size do you use for train and infer now?"
        }
      ]
    },
    {
      "id": 1659734,
      "postDate": "2022-01-22T04:44:56.327Z",
      "content": "<p>Did you check your LB when you infer with original size? (size when you training) Thanks</p>",
      "rawMarkdown": "Did you check your LB when you infer with original size? (size when you training) Thanks",
      "votes": 1,
      "replies": [
        {
          "id": 1659747,
          "postDate": "2022-01-22T05:10:59.820Z",
          "content": "<p>Not yet. But planning to do this once done with hyperparameter optimization.</p>",
          "rawMarkdown": "Not yet. But planning to do this once done with hyperparameter optimization.",
          "votes": 1
        },
        {
          "id": 1659891,
          "postDate": "2022-01-22T07:20:53.420Z",
          "content": "<p>I understood. So your LB is upscale inference?</p>",
          "rawMarkdown": "I understood. So your LB is upscale inference?"
        },
        {
          "id": 1660061,
          "postDate": "2022-01-22T11:03:20.040Z",
          "content": "<p>yes….1.6, 2x, 2.2x</p>",
          "rawMarkdown": "yes....1.6, 2x, 2.2x\n",
          "votes": 1
        },
        {
          "id": 1660267,
          "postDate": "2022-01-22T14:40:24.237Z",
          "content": "<p><a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> is is best conf selected from F2_curves ? </p>",
          "rawMarkdown": "@sanchitvj is is best conf selected from F2_curves ? "
        },
        {
          "id": 1660334,
          "postDate": "2022-01-22T15:45:23.557Z",
          "content": "<p>We are still working on that. </p>",
          "rawMarkdown": "We are still working on that. ",
          "votes": 1
        }
      ]
    },
    {
      "id": 1659140,
      "postDate": "2022-01-21T15:15:23.347Z",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> <br>\nthis line seem to compute F1 AP50? so you are calculating F2 at AP50 and not average 0.3:0.8:0.05 per class (this case is 1). Correct me if I wrong. Thanks </p>",
      "rawMarkdown": "Hi @sanchitvj \nthis line seem to compute F1 AP50? so you are calculating F2 at AP50 and not average 0.3:0.8:0.05 per class (this case is 1). Correct me if I wrong. Thanks ",
      "votes": 1,
      "replies": [
        {
          "id": 1659366,
          "postDate": "2022-01-21T18:28:17.950Z",
          "content": "<p>In step2 I am taking the average <code>torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)</code></p>",
          "rawMarkdown": "In step2 I am taking the average `torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)`"
        }
      ]
    },
    {
      "id": 1659138,
      "postDate": "2022-01-21T15:14:26.093Z",
      "content": "<p>Traceback (most recent call last):<br>\n  File \"train.py\", line 637, in <br>\n    main(opt)<br>\n  File \"train.py\", line 534, in main<br>\n    train(opt.hyp, opt, device, callbacks)<br>\n  File \"train.py\", line 376, in train<br>\n    compute_loss=compute_loss)<br>\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/torch/autograd/grad_mode.py\", line 28, in decorate_context<br>\n    return func(*args, **kwargs)<br>\n  File \"/home/ubuntu/Kaggle/yolov5/val.py\", line 255, in run<br>\n    ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(1)  # AP@0.5, AP@0.5:0.95<br>\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 167, in _mean<br>\n    rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)<br>\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 76, in _count_reduce_items<br>\n    items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]<br>\nnumpy.AxisError: axis 1 is out of bounds for array of dimension 1</p>\n<p>GOT this error</p>",
      "rawMarkdown": "Traceback (most recent call last):\n  File \"train.py\", line 637, in <module>\n    main(opt)\n  File \"train.py\", line 534, in main\n    train(opt.hyp, opt, device, callbacks)\n  File \"train.py\", line 376, in train\n    compute_loss=compute_loss)\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/torch/autograd/grad_mode.py\", line 28, in decorate_context\n    return func(*args, **kwargs)\n  File \"/home/ubuntu/Kaggle/yolov5/val.py\", line 255, in run\n    ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(1)  # AP@0.5, AP@0.5:0.95\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 167, in _mean\n    rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 76, in _count_reduce_items\n    items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]\nnumpy.AxisError: axis 1 is out of bounds for array of dimension 1\n\n\n\nGOT this error",
      "votes": 1,
      "replies": [
        {
          "id": 1659139,
          "postDate": "2022-01-21T15:15:18.307Z",
          "content": "<p><a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a>  can u help in this?</p>",
          "rawMarkdown": "@sanchitvj  can u help in this?"
        },
        {
          "id": 1659369,
          "postDate": "2022-01-21T18:30:57.590Z",
          "content": "<blockquote>\n<pre><code>ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\nmp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n</code></pre>\n  <p>Sorry for the mistake changed to <code>f2.mean(0)</code> in first line </p>\n</blockquote>",
          "rawMarkdown": "> ```\n> ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\n> mp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n> ```\nSorry for the mistake changed to `f2.mean(0)` in first line \n"
        },
        {
          "id": 1659722,
          "postDate": "2022-01-22T04:27:34.520Z",
          "content": "<p><a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> thanks bro its working now</p>",
          "rawMarkdown": "@sanchitvj thanks bro its working now",
          "votes": 1
        }
      ]
    },
    {
      "id": 1659927,
      "postDate": "2022-01-22T08:17:01.590Z",
      "content": "<p>For wandb logging, need to add <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47\" target=\"_blank\">this</a> to add 'metrics/f2'.</p>",
      "rawMarkdown": "For wandb logging, need to add [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47) to add 'metrics/f2'.",
      "votes": 2,
      "replies": [
        {
          "id": 1659940,
          "postDate": "2022-01-22T08:30:27.573Z",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/ichimarugin\" target=\"_blank\">@ichimarugin</a>…. I have updated :)</p>",
          "rawMarkdown": "Thank you @ichimarugin.... I have updated :)"
        }
      ]
    },
    {
      "id": 1679104,
      "postDate": "2022-02-07T01:30:19.510Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 1674619,
      "postDate": "2022-02-03T16:37:03.663Z",
      "content": "<p>Thank you for sharing.</p>",
      "rawMarkdown": "Thank you for sharing.",
      "votes": 1
    }
  ],
  "comments": [
    {
      "id": 1670785,
      "author_name": "Chris Deotte",
      "author_url": "",
      "post_date": "2022-01-31T21:35:56.273000",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> and <a href=\"https://www.kaggle.com/amiiiney\" target=\"_blank\">@amiiiney</a>, this works perfectly! Note the first file's name is <code>metrics.py</code> not <code>matrix.py</code>. Also, if we change the following two lines in <code>val.py</code> <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\" target=\"_blank\">here</a> and <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263\" target=\"_blank\">here</a>, we can have Yolo display the F2 on the command line while training.</p>",
      "votes": 5,
      "replies": [
        {
          "id": 1671042,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-02-01T05:38:39.633000",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> for valuable suggestion. I have made the changes :)</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1671048,
          "author_name": "zhiqiang he",
          "author_url": "",
          "post_date": "2022-02-01T05:47:25.557000",
          "content": "<p>I have a question for you experts！！<br>\nI trained yolov5s6 with size3600 and then used the following notebook <a href=\"https://www.kaggle.com/kocha1/only-yolov5-tracking-lb-642\" target=\"_blank\">https://www.kaggle.com/kocha1/only-yolov5-tracking-lb-642</a> for inference. conf0.34 iou0.5, in the case where I only change the img-size of inference:<br>\nimg-size 3600 lb0.579<br>\nimg-size 9000 lb0.577<br>\nWhy does my self-trained model infer no change at large scale?<br>\nHave you encountered this situation?</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1674965,
      "author_name": "somuSan",
      "author_url": "",
      "post_date": "2022-02-03T22:57:08.903000",
      "content": "<blockquote>\n  <p>change the following two lines in val.py <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\" target=\"_blank\">here</a> and <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263\" target=\"_blank\">here</a>, we can have Yolo display the F2 on the command line while training.</p>\n</blockquote>\n<p>What should I change in these lines? i tried to add \"f2\" but it did not work. Need help.</p>",
      "votes": 3,
      "replies": [
        {
          "id": 1675041,
          "author_name": "Chris Deotte",
          "author_url": "",
          "post_date": "2022-02-04T01:31:22.747000",
          "content": "<p>Change the first line to <br>\n<code>s = ('%20s' + '%11s' * 6) % ('Class', 'Images', 'Labels', 'P', 'R', 'F2', 'mAP@.5')</code></p>\n<p>Change the second line to<br>\n<code>LOGGER.info(pf % ('all', seen, nt.sum(), mp, mr, f2, map50))</code></p>\n<p>(and do all the other changes in original discussion post above)</p>",
          "votes": 5,
          "replies": []
        },
        {
          "id": 1675702,
          "author_name": "somuSan",
          "author_url": "",
          "post_date": "2022-02-04T12:22:32.880000",
          "content": "<p>Thank you, it is working now.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1674065,
      "author_name": "grhuang",
      "author_url": "",
      "post_date": "2022-02-03T07:44:18.903000",
      "content": "<p>Why change the <code>self.csv = False</code>? If we keep this line in <code>__init__.py</code> , we can have the PLT chart result.</p>",
      "votes": 4,
      "replies": []
    },
    {
      "id": 1668295,
      "author_name": "SenTran",
      "author_url": "",
      "post_date": "2022-01-29T14:07:59.347000",
      "content": "<p>I think, The code should only modify w = [0.2, 0.8, 0.0, 0.0] in fitness function. Because, in F2 score P less important than R 4 times.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1670282,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-31T11:39:28.160000",
          "content": "<p><code>w = [0.0, 0.0, 0.0, 0.0, 1.0]</code> here we are giving priority to F2 score. So by default P is less prioritized</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1667045,
      "author_name": "Meesz9",
      "author_url": "",
      "post_date": "2022-01-28T09:30:12.307000",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a>,<br>\nDo you use the same hyperparameters as \"Sheep\" shared in this post: <a href=\"https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data\" target=\"_blank\"></a><a href=\"https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data\" target=\"_blank\">https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data</a> </p>\n<p>Do you use albumentations and is the LB score that you reached with yolov5l6 or a smaller model?  </p>\n<p>Thank you for the interesting discussions in this competition!</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1667073,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-28T09:44:41.597000",
          "content": "<p>Hi, no hyperparams are different, no albumentations and model is s6 only. Happy to help :) </p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 1667110,
          "author_name": "Meesz9",
          "author_url": "",
          "post_date": "2022-01-28T10:22:57.100000",
          "content": "<p>Oh wow! TY <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> I'm now testing what the right img size is. What img size do you use for train and infer now?</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1659734,
      "author_name": "Hiếu Phạm Trần Minh",
      "author_url": "",
      "post_date": "2022-01-22T04:44:56.327000",
      "content": "<p>Did you check your LB when you infer with original size? (size when you training) Thanks</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1659747,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-22T05:10:59.820000",
          "content": "<p>Not yet. But planning to do this once done with hyperparameter optimization.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1659891,
          "author_name": "Hiếu Phạm Trần Minh",
          "author_url": "",
          "post_date": "2022-01-22T07:20:53.420000",
          "content": "<p>I understood. So your LB is upscale inference?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1660061,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-22T11:03:20.040000",
          "content": "<p>yes….1.6, 2x, 2.2x</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1660267,
          "author_name": "SeshuRaju 🧘‍♂️",
          "author_url": "",
          "post_date": "2022-01-22T14:40:24.237000",
          "content": "<p><a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> is is best conf selected from F2_curves ? </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1660334,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-22T15:45:23.557000",
          "content": "<p>We are still working on that. </p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1659140,
      "author_name": "Ơ con lừa!",
      "author_url": "",
      "post_date": "2022-01-21T15:15:23.347000",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> <br>\nthis line seem to compute F1 AP50? so you are calculating F2 at AP50 and not average 0.3:0.8:0.05 per class (this case is 1). Correct me if I wrong. Thanks </p>",
      "votes": 1,
      "replies": [
        {
          "id": 1659366,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-21T18:28:17.950000",
          "content": "<p>In step2 I am taking the average <code>torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)</code></p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1659138,
      "author_name": "Anshul Khadse",
      "author_url": "",
      "post_date": "2022-01-21T15:14:26.093000",
      "content": "<p>Traceback (most recent call last):<br>\n  File \"train.py\", line 637, in <br>\n    main(opt)<br>\n  File \"train.py\", line 534, in main<br>\n    train(opt.hyp, opt, device, callbacks)<br>\n  File \"train.py\", line 376, in train<br>\n    compute_loss=compute_loss)<br>\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/torch/autograd/grad_mode.py\", line 28, in decorate_context<br>\n    return func(*args, **kwargs)<br>\n  File \"/home/ubuntu/Kaggle/yolov5/val.py\", line 255, in run<br>\n    ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(1)  # AP@0.5, AP@0.5:0.95<br>\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 167, in _mean<br>\n    rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)<br>\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 76, in _count_reduce_items<br>\n    items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]<br>\nnumpy.AxisError: axis 1 is out of bounds for array of dimension 1</p>\n<p>GOT this error</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1659139,
          "author_name": "Anshul Khadse",
          "author_url": "",
          "post_date": "2022-01-21T15:15:18.307000",
          "content": "<p><a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a>  can u help in this?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1659369,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-21T18:30:57.590000",
          "content": "<blockquote>\n<pre><code>ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\nmp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n</code></pre>\n  <p>Sorry for the mistake changed to <code>f2.mean(0)</code> in first line </p>\n</blockquote>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1659722,
          "author_name": "Anshul Khadse",
          "author_url": "",
          "post_date": "2022-01-22T04:27:34.520000",
          "content": "<p><a href=\"https://www.kaggle.com/sanchitvj\" target=\"_blank\">@sanchitvj</a> thanks bro its working now</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1659927,
      "author_name": "Ichimaru Gin",
      "author_url": "",
      "post_date": "2022-01-22T08:17:01.590000",
      "content": "<p>For wandb logging, need to add <a href=\"https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47\" target=\"_blank\">this</a> to add 'metrics/f2'.</p>",
      "votes": 2,
      "replies": [
        {
          "id": 1659940,
          "author_name": "Sanchit Vijay",
          "author_url": "",
          "post_date": "2022-01-22T08:30:27.573000",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/ichimarugin\" target=\"_blank\">@ichimarugin</a>…. I have updated :)</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1679104,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-02-07T01:30:19.510000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 1674619,
      "author_name": "DongYuan",
      "author_url": "",
      "post_date": "2022-02-03T16:37:03.663000",
      "content": "<p>Thank you for sharing.</p>",
      "votes": 1,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1659077": "This post is continuation of [link](https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343).\nIn order to visualize and log F2 score during validation of [yolov5](https://github.com/ultralytics/yolov5) follow the steps in [this](https://www.kaggle.com/c/tensorflow-great-barrier-reef/discussion/300638#1658343) discussion, (thanks to @amiiiney) or below I am providing all the steps.\n\n- In `metrics.py` file\n-- change [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/metrics.py#L73) line to `f2 = 5 * p * r / (4 * p + r + 1e-16)` and below this change `f1` to `f2` everywhere in the `ap_per_class` function and return `return tp, fp, p, r, f2, ap, unique_classes.astype(\"int32\")`.\n-- next modify `fitness` function as below:\n```\ndef fitness(x):\n    # Model fitness as a weighted combination of metrics\n    w = [0.0, 0.0, 0.0, 0.0, 1.0] # weights for [P, R, mAP@0.5, mAP@0.5:0.95, F2@0.3:0.8]\n    return (x[:, :5] * w).sum(1)\n```\n\n- In `val.py` file\n-- modify [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L160) line with `iouv= torch.from_numpy(np.arange(0.3, 0.85, 0.05)).to(device)`\n-- change `f1` in [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L176) to `f2` and same for [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L254) line and -- modify next 2 lines to \n```\nap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(0)  # AP@0.5, AP@0.5:0.95\nmp, mr, f2, map50, map = p.mean(), r.mean(), f2.mean(), ap50.mean(), ap.mean()\n```\n-- change the following two lines in val.py [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175) and [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263), we can have Yolo display the F2 on the command line while training. (thanks @cdeotte )\n--and `return (mp, mr, map50, map, f2, *(loss.cpu() / len(dataloader)).tolist()), maps, t`\n\n- In [this](https://github.com/ultralytics/yolov5/blob/master/utils/loggers/__init__.py) file\n-- add `\"metrics/F2\"` to [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47) list and in a list `self.best_keys` in next line `\"best/F2\"` \n-- In `on_fit_epoch_end` function modify [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L130) line with `best_results = [epoch] + vals[3:8]` \n\n---\n\nAfter making these modifications you will be able to visualize and log F2 score on `wandb`(not sure about other loggers).\n- Thanks to @amiiiney for providing solution.\n- Thanks to @cdeotte for suggestion.\nSugggestions or modifications are welcome :)\n\nLAST UPDATED:\n- 22 Jan, 2 PM (IST)\n- 1 Feb, 11 AM (IST)",
    "1670785": "Thanks @sanchitvj and @amiiiney, this works perfectly! Note the first file's name is `metrics.py` not `matrix.py`. Also, if we change the following two lines in `val.py` [here][1] and [here][2], we can have Yolo display the F2 on the command line while training.\n\n[1]: https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175\n[2]: https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263",
    "1674965": "> change the following two lines in val.py [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L175) and [here](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/val.py#L263), we can have Yolo display the F2 on the command line while training.\n\nWhat should I change in these lines? i tried to add \"f2\" but it did not work. Need help.\n",
    "1674065": "Why change the `self.csv = False`? If we keep this line in `__init__.py` , we can have the PLT chart result.",
    "1668295": "I think, The code should only modify w = [0.2, 0.8, 0.0, 0.0] in fitness function. Because, in F2 score P less important than R 4 times.\n",
    "1667045": "Hi @sanchitvj,\nDo you use the same hyperparameters as \"Sheep\" shared in this post: [https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data ](https://www.kaggle.com/steamedsheep/yolov5-high-resolution-training/data)\n\nDo you use albumentations and is the LB score that you reached with yolov5l6 or a smaller model?  \n\nThank you for the interesting discussions in this competition!",
    "1659734": "Did you check your LB when you infer with original size? (size when you training) Thanks",
    "1659140": "Hi @sanchitvj \nthis line seem to compute F1 AP50? so you are calculating F2 at AP50 and not average 0.3:0.8:0.05 per class (this case is 1). Correct me if I wrong. Thanks ",
    "1659138": "Traceback (most recent call last):\n  File \"train.py\", line 637, in <module>\n    main(opt)\n  File \"train.py\", line 534, in main\n    train(opt.hyp, opt, device, callbacks)\n  File \"train.py\", line 376, in train\n    compute_loss=compute_loss)\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/torch/autograd/grad_mode.py\", line 28, in decorate_context\n    return func(*args, **kwargs)\n  File \"/home/ubuntu/Kaggle/yolov5/val.py\", line 255, in run\n    ap50, ap, f2 = ap[:, 0], ap.mean(1), f2.mean(1)  # AP@0.5, AP@0.5:0.95\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 167, in _mean\n    rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)\n  File \"/home/ubuntu/anaconda3/envs/yolo5/lib/python3.7/site-packages/numpy/core/_methods.py\", line 76, in _count_reduce_items\n    items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]\nnumpy.AxisError: axis 1 is out of bounds for array of dimension 1\n\n\n\nGOT this error",
    "1659927": "For wandb logging, need to add [this](https://github.com/ultralytics/yolov5/blob/bd815d48df18a23e2bb08d88e430183bfb48eb78/utils/loggers/__init__.py#L47) to add 'metrics/f2'.",
    "1679104": "",
    "1674619": "Thank you for sharing."
  }
}