{
  "id": 299721,
  "title": "Yolo Weights in Keras TensorFlow",
  "url": "/competitions/tensorflow-great-barrier-reef/discussion/299721",
  "author_name": "Ravi Shah",
  "post_date": "2022-01-09T17:20:38.690000",
  "votes": 1,
  "comment_count": 0,
  "views": 0,
  "content": "<p><a href=\"https://www.kaggle.com/ravishah1/keras-yolo-weights\" target=\"_blank\">Linked is the dataset with the weights</a></p>\n<p>The yolo_weights.h5 file contains keras weights to the yolov3 darknet architecture. <br>\nIt is currently set up to work on 80 labels and pretrained on the coco dataset. I am still figuring out how to make this model work for this specific task.</p>\n<p><strong>How to import the weights/model</strong></p>\n<p>Add the dataset to your notebook then write the following:</p>\n<pre><code>import tensorflow as tf\nmodel = tf.keras.models.load_model(\"../input/keras-yolo-weights/yolo_weights.h5\")\nmodel.summary() # to see the model was loaded\n</code></pre>\n<p><strong>Understanding the output</strong></p>\n<ul>\n<li>For each considered bounding box, the model predicts x, y, w, h, an objectness score, and class scores. </li>\n<li>Therefore, the shape of the detection kernel is 1 x 1 x (B x (4 + 1 + C))</li>\n<li>The B is the number of bounding boxes a cell on the feature map can predict, 4 is the x,y,w,h attributes, the 1 is for the object confidence, and C is the number of object classes.</li>\n<li>On the pretrained coco dataset the output shape would be 1 x 1 x 255 because this model has a B of 3, and there are 80 pretrained classes for C. 1 x 1 x (3 x (4+1+80)) == 1 x 1 x 255</li>\n</ul>\n<p>Hopefully this dataset and discussion help you to import and train a yolo model in keras. If you get this to work, you will also have a yolo model that could be eligible for the TensorFlow Performance Prize. </p>\n<p>Feel free to comment any questions, tips, or ideas. </p>",
  "messages": [
    {
      "id": 1643740,
      "postDate": "2022-01-09T17:20:38.690Z",
      "content": "<p><a href=\"https://www.kaggle.com/ravishah1/keras-yolo-weights\" target=\"_blank\">Linked is the dataset with the weights</a></p>\n<p>The yolo_weights.h5 file contains keras weights to the yolov3 darknet architecture. <br>\nIt is currently set up to work on 80 labels and pretrained on the coco dataset. I am still figuring out how to make this model work for this specific task.</p>\n<p><strong>How to import the weights/model</strong></p>\n<p>Add the dataset to your notebook then write the following:</p>\n<pre><code>import tensorflow as tf\nmodel = tf.keras.models.load_model(\"../input/keras-yolo-weights/yolo_weights.h5\")\nmodel.summary() # to see the model was loaded\n</code></pre>\n<p><strong>Understanding the output</strong></p>\n<ul>\n<li>For each considered bounding box, the model predicts x, y, w, h, an objectness score, and class scores. </li>\n<li>Therefore, the shape of the detection kernel is 1 x 1 x (B x (4 + 1 + C))</li>\n<li>The B is the number of bounding boxes a cell on the feature map can predict, 4 is the x,y,w,h attributes, the 1 is for the object confidence, and C is the number of object classes.</li>\n<li>On the pretrained coco dataset the output shape would be 1 x 1 x 255 because this model has a B of 3, and there are 80 pretrained classes for C. 1 x 1 x (3 x (4+1+80)) == 1 x 1 x 255</li>\n</ul>\n<p>Hopefully this dataset and discussion help you to import and train a yolo model in keras. If you get this to work, you will also have a yolo model that could be eligible for the TensorFlow Performance Prize. </p>\n<p>Feel free to comment any questions, tips, or ideas. </p>",
      "rawMarkdown": "[Linked is the dataset with the weights](https://www.kaggle.com/ravishah1/keras-yolo-weights)\n\nThe yolo_weights.h5 file contains keras weights to the yolov3 darknet architecture. \nIt is currently set up to work on 80 labels and pretrained on the coco dataset. I am still figuring out how to make this model work for this specific task.\n\n**How to import the weights/model**\n\nAdd the dataset to your notebook then write the following:\n\n```\nimport tensorflow as tf\nmodel = tf.keras.models.load_model(\"../input/keras-yolo-weights/yolo_weights.h5\")\nmodel.summary() # to see the model was loaded\n```\n\n**Understanding the output**\n\n- For each considered bounding box, the model predicts x, y, w, h, an objectness score, and class scores. \n- Therefore, the shape of the detection kernel is 1 x 1 x (B x (4 + 1 + C))\n- The B is the number of bounding boxes a cell on the feature map can predict, 4 is the x,y,w,h attributes, the 1 is for the object confidence, and C is the number of object classes.\n- On the pretrained coco dataset the output shape would be 1 x 1 x 255 because this model has a B of 3, and there are 80 pretrained classes for C. 1 x 1 x (3 x (4+1+80)) == 1 x 1 x 255\n\nHopefully this dataset and discussion help you to import and train a yolo model in keras. If you get this to work, you will also have a yolo model that could be eligible for the TensorFlow Performance Prize. \n\nFeel free to comment any questions, tips, or ideas. \n",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1643740": "[Linked is the dataset with the weights](https://www.kaggle.com/ravishah1/keras-yolo-weights)\n\nThe yolo_weights.h5 file contains keras weights to the yolov3 darknet architecture. \nIt is currently set up to work on 80 labels and pretrained on the coco dataset. I am still figuring out how to make this model work for this specific task.\n\n**How to import the weights/model**\n\nAdd the dataset to your notebook then write the following:\n\n```\nimport tensorflow as tf\nmodel = tf.keras.models.load_model(\"../input/keras-yolo-weights/yolo_weights.h5\")\nmodel.summary() # to see the model was loaded\n```\n\n**Understanding the output**\n\n- For each considered bounding box, the model predicts x, y, w, h, an objectness score, and class scores. \n- Therefore, the shape of the detection kernel is 1 x 1 x (B x (4 + 1 + C))\n- The B is the number of bounding boxes a cell on the feature map can predict, 4 is the x,y,w,h attributes, the 1 is for the object confidence, and C is the number of object classes.\n- On the pretrained coco dataset the output shape would be 1 x 1 x 255 because this model has a B of 3, and there are 80 pretrained classes for C. 1 x 1 x (3 x (4+1+80)) == 1 x 1 x 255\n\nHopefully this dataset and discussion help you to import and train a yolo model in keras. If you get this to work, you will also have a yolo model that could be eligible for the TensorFlow Performance Prize. \n\nFeel free to comment any questions, tips, or ideas. \n"
  }
}