{
  "id": 150982,
  "title": "Hierarchical Multi label image classification (CNN )",
  "url": "/competitions/dog-breed-identification/discussion/150982",
  "author_name": "",
  "post_date": "2020-05-14T01:56:16.359517800Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>I would like to know if there is any example available that show how to create a model that combines two classification levels:\n1 - Is a dog or a cat ?\n2- If is a dog, what Dog breed ?  If is a cat, what cat breed ? </p>\n\n<p>I have found just examples using multi-class classification (not considering hierarchy):</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2008341%2Facbad2ccd13955b802e4378b1524c1ee%2Fkeras_multi_label_dataset.jpg?generation=1589420916983958&amp;alt=media\" alt=\"multi-class\"></p>\n\n<p>In this case, both features can happen (all clothes can have all colors). However, my case is different because the dog breed is different from cat breed. So the first label will define the second.</p>\n\n<p>If someone can help me, I would be very thankful.</p>",
  "messages": [
    {
      "id": "846757",
      "postDate": "05/14/2020 01:56:16",
      "content": "<p>I would like to know if there is any example available that show how to create a model that combines two classification levels:\n1 - Is a dog or a cat ?\n2- If is a dog, what Dog breed ?  If is a cat, what cat breed ? </p>\n\n<p>I have found just examples using multi-class classification (not considering hierarchy):</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2008341%2Facbad2ccd13955b802e4378b1524c1ee%2Fkeras_multi_label_dataset.jpg?generation=1589420916983958&amp;alt=media\" alt=\"multi-class\"></p>\n\n<p>In this case, both features can happen (all clothes can have all colors). However, my case is different because the dog breed is different from cat breed. So the first label will define the second.</p>\n\n<p>If someone can help me, I would be very thankful.</p>",
      "rawMarkdown": "I would like to know if there is any example available that show how to create a model that combines two classification levels:\n1 - Is a dog or a cat ?\n2- If is a dog, what Dog breed ?  If is a cat, what cat breed ? \n\nI have found just examples using multi-class classification (not considering hierarchy):\n\n\n![multi-class](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2008341%2Facbad2ccd13955b802e4378b1524c1ee%2Fkeras_multi_label_dataset.jpg?generation=1589420916983958&amp;alt=media)\n\nIn this case, both features can happen (all clothes can have all colors). However, my case is different because the dog breed is different from cat breed. So the first label will define the second.\n\nIf someone can help me, I would be very thankful.",
      "votes": null
    },
    {
      "id": "879016",
      "postDate": "06/09/2020 05:44:48",
      "content": "<p>I think, You need to make a pipeline of two models. One for dog/cat, and other - for breed</p>",
      "rawMarkdown": "I think, You need to make a pipeline of two models. One for dog/cat, and other - for breed",
      "votes": null
    },
    {
      "id": "1608125",
      "postDate": "12/06/2021 08:37:26",
      "content": "<p>There could be multiple approaches to the design and highly depends on constraints do you wish to have. If resources and latency are not an issue, train a hierarchical model, feeding the features and the output from the lower level model to the higher level model. Eg, getting the feature maps and output from cat/dog classification model and feeding it to the breed classification model. </p>\n<p>Alternatively, you could also train 1 single model, combining all the breeds of cats and dogs as your classes (a prediction of dog breed implicitly implies that the model predicted it to be a dog). However, the accuracies might suffer, given the number of possible outcomes.</p>\n<p>You could also train a multi label classification using single shot learning technique, where the model outputs both the class (dog/cat) as well as the breed.</p>\n<p>Again here, you could make a choice of assigning different weights to the two categories of output for computing the loss.</p>",
      "rawMarkdown": "There could be multiple approaches to the design and highly depends on constraints do you wish to have. If resources and latency are not an issue, train a hierarchical model, feeding the features and the output from the lower level model to the higher level model. Eg, getting the feature maps and output from cat/dog classification model and feeding it to the breed classification model. \n\nAlternatively, you could also train 1 single model, combining all the breeds of cats and dogs as your classes (a prediction of dog breed implicitly implies that the model predicted it to be a dog). However, the accuracies might suffer, given the number of possible outcomes.\n\nYou could also train a multi label classification using single shot learning technique, where the model outputs both the class (dog/cat) as well as the breed.\n\nAgain here, you could make a choice of assigning different weights to the two categories of output for computing the loss.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1608125,
      "author_name": "saag22",
      "author_url": "",
      "post_date": "12/06/2021 08:37:26",
      "content": "<p>There could be multiple approaches to the design and highly depends on constraints do you wish to have. If resources and latency are not an issue, train a hierarchical model, feeding the features and the output from the lower level model to the higher level model. Eg, getting the feature maps and output from cat/dog classification model and feeding it to the breed classification model. </p>\n<p>Alternatively, you could also train 1 single model, combining all the breeds of cats and dogs as your classes (a prediction of dog breed implicitly implies that the model predicted it to be a dog). However, the accuracies might suffer, given the number of possible outcomes.</p>\n<p>You could also train a multi label classification using single shot learning technique, where the model outputs both the class (dog/cat) as well as the breed.</p>\n<p>Again here, you could make a choice of assigning different weights to the two categories of output for computing the loss.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 879016,
      "author_name": "makarbaderko",
      "author_url": "",
      "post_date": "06/09/2020 05:44:48",
      "content": "<p>I think, You need to make a pipeline of two models. One for dog/cat, and other - for breed</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "846757": "I would like to know if there is any example available that show how to create a model that combines two classification levels:\n1 - Is a dog or a cat ?\n2- If is a dog, what Dog breed ?  If is a cat, what cat breed ? \n\nI have found just examples using multi-class classification (not considering hierarchy):\n\n\n![multi-class](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2008341%2Facbad2ccd13955b802e4378b1524c1ee%2Fkeras_multi_label_dataset.jpg?generation=1589420916983958&amp;alt=media)\n\nIn this case, both features can happen (all clothes can have all colors). However, my case is different because the dog breed is different from cat breed. So the first label will define the second.\n\nIf someone can help me, I would be very thankful.",
    "879016": "I think, You need to make a pipeline of two models. One for dog/cat, and other - for breed",
    "1608125": "There could be multiple approaches to the design and highly depends on constraints do you wish to have. If resources and latency are not an issue, train a hierarchical model, feeding the features and the output from the lower level model to the higher level model. Eg, getting the feature maps and output from cat/dog classification model and feeding it to the breed classification model. \n\nAlternatively, you could also train 1 single model, combining all the breeds of cats and dogs as your classes (a prediction of dog breed implicitly implies that the model predicted it to be a dog). However, the accuracies might suffer, given the number of possible outcomes.\n\nYou could also train a multi label classification using single shot learning technique, where the model outputs both the class (dog/cat) as well as the breed.\n\nAgain here, you could make a choice of assigning different weights to the two categories of output for computing the loss."
  },
  "source": "meta"
}