{
  "id": 73749,
  "title": "How to encode temporal information into images?",
  "url": "/competitions/quickdraw-doodle-recognition/discussion/73749",
  "author_name": "[he.ai]soulmachine",
  "post_date": "2018-12-05T11:14:43.948000",
  "votes": 0,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Hi everyone, I'm curious how you guys encode temporal information, i.e., the ordering of strokes, into images, for now I'm using Beluga's method:</p>\n\n<p><code>python\ndef draw_cv2(raw_strokes, size=256, lw=6, time_color=True):\n    img = np.zeros((BASE_SIZE, BASE_SIZE), np.uint8)\n    for t, stroke in enumerate(raw_strokes):\n        for i in range(len(stroke[0]) - 1):\n            color = 255 - min(t, 10) * 13 if time_color else 255\n            _ = cv2.line(img, (stroke[0][i], stroke[1][i]),\n                         (stroke[0][i + 1], stroke[1][i + 1]), color, lw)\n    if size != BASE_SIZE:\n        return cv2.resize(img, (size, size))\n    else:\n        return img\n</code>\nThe method above is quite similar to this paper, <a href=\"https://arxiv.org/pdf/1501.07873.pdf\">Sketch-a-Net that Beats Humans</a></p>\n\n<p>And today I saw two newly published methods:</p>\n\n<ol>\n<li>Siyuan Dang's kenel, <a href=\"https://www.kaggle.com/sheboke93/how-i-colored-strokes\">How I colored strokes</a></li>\n<li>Gunther's kenel, <a href=\"https://www.kaggle.com/guntherthepenguin/fastai-resnet18-color-coded-and-focalloss\">Fastai conform dataset with resnet18</a> , </li>\n</ol>\n\n<p>There is another paper,  <a href=\"https://arxiv.org/pdf/1811.08170.pdf\">Sketch-R2CNN - An Attentive Network for Vector Sketch Recognition</a>, it doesn't use hard coded colors, instead its colors are learnt by a RNN model, which looks very promising. However  the author didn't publish the code so I don't have a chance to try it.  Lukasz Grad has published his implementation here, <a href=\"https://www.kaggle.com/c/quickdraw-doodle-recognition/discussion/73699\">https://www.kaggle.com/c/quickdraw-doodle-recognition/discussion/73699</a> , I'll give it a try later.</p>\n\n<p>The four methods above are what I know so far.</p>\n\n<p>Could you share your code in this thread to show how you generate images? Thanks a lot!</p>",
  "messages": [
    {
      "id": 433698,
      "postDate": "2018-12-05T11:14:43.950Z",
      "content": "<p>Hi everyone, I'm curious how you guys encode temporal information, i.e., the ordering of strokes, into images, for now I'm using Beluga's method:</p>\n\n<p><code>python\ndef draw_cv2(raw_strokes, size=256, lw=6, time_color=True):\n    img = np.zeros((BASE_SIZE, BASE_SIZE), np.uint8)\n    for t, stroke in enumerate(raw_strokes):\n        for i in range(len(stroke[0]) - 1):\n            color = 255 - min(t, 10) * 13 if time_color else 255\n            _ = cv2.line(img, (stroke[0][i], stroke[1][i]),\n                         (stroke[0][i + 1], stroke[1][i + 1]), color, lw)\n    if size != BASE_SIZE:\n        return cv2.resize(img, (size, size))\n    else:\n        return img\n</code>\nThe method above is quite similar to this paper, <a href=\"https://arxiv.org/pdf/1501.07873.pdf\">Sketch-a-Net that Beats Humans</a></p>\n\n<p>And today I saw two newly published methods:</p>\n\n<ol>\n<li>Siyuan Dang's kenel, <a href=\"https://www.kaggle.com/sheboke93/how-i-colored-strokes\">How I colored strokes</a></li>\n<li>Gunther's kenel, <a href=\"https://www.kaggle.com/guntherthepenguin/fastai-resnet18-color-coded-and-focalloss\">Fastai conform dataset with resnet18</a> , </li>\n</ol>\n\n<p>There is another paper,  <a href=\"https://arxiv.org/pdf/1811.08170.pdf\">Sketch-R2CNN - An Attentive Network for Vector Sketch Recognition</a>, it doesn't use hard coded colors, instead its colors are learnt by a RNN model, which looks very promising. However  the author didn't publish the code so I don't have a chance to try it.  Lukasz Grad has published his implementation here, <a href=\"https://www.kaggle.com/c/quickdraw-doodle-recognition/discussion/73699\">https://www.kaggle.com/c/quickdraw-doodle-recognition/discussion/73699</a> , I'll give it a try later.</p>\n\n<p>The four methods above are what I know so far.</p>\n\n<p>Could you share your code in this thread to show how you generate images? Thanks a lot!</p>",
      "rawMarkdown": "Hi everyone, I'm curious how you guys encode temporal information, i.e., the ordering of strokes, into images, for now I'm using Beluga's method:\n\n```python\ndef draw_cv2(raw_strokes, size=256, lw=6, time_color=True):\n    img = np.zeros((BASE_SIZE, BASE_SIZE), np.uint8)\n    for t, stroke in enumerate(raw_strokes):\n        for i in range(len(stroke[0]) - 1):\n            color = 255 - min(t, 10) * 13 if time_color else 255\n            _ = cv2.line(img, (stroke[0][i], stroke[1][i]),\n                         (stroke[0][i + 1], stroke[1][i + 1]), color, lw)\n    if size != BASE_SIZE:\n        return cv2.resize(img, (size, size))\n    else:\n        return img\n```\nThe method above is quite similar to this paper, [Sketch-a-Net that Beats Humans][1]\n\nAnd today I saw two newly published methods:\n\n2. Siyuan Dang's kenel, [How I colored strokes](https://www.kaggle.com/sheboke93/how-i-colored-strokes)\n3. Gunther's kenel, [Fastai conform dataset with resnet18](https://www.kaggle.com/guntherthepenguin/fastai-resnet18-color-coded-and-focalloss) , \n\n\n\nThere is another paper,  [Sketch-R2CNN - An Attentive Network for Vector Sketch Recognition][2], it doesn't use hard coded colors, instead its colors are learnt by a RNN model, which looks very promising. However  the author didn't publish the code so I don't have a chance to try it.  Lukasz Grad has published his implementation here, https://www.kaggle.com/c/quickdraw-doodle-recognition/discussion/73699 , I'll give it a try later.\n\nThe four methods above are what I know so far.\n\nCould you share your code in this thread to show how you generate images? Thanks a lot!\n\n\n  [1]: https://arxiv.org/pdf/1501.07873.pdf\n  [2]: https://arxiv.org/pdf/1811.08170.pdf"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "433698": "Hi everyone, I'm curious how you guys encode temporal information, i.e., the ordering of strokes, into images, for now I'm using Beluga's method:\n\n```python\ndef draw_cv2(raw_strokes, size=256, lw=6, time_color=True):\n    img = np.zeros((BASE_SIZE, BASE_SIZE), np.uint8)\n    for t, stroke in enumerate(raw_strokes):\n        for i in range(len(stroke[0]) - 1):\n            color = 255 - min(t, 10) * 13 if time_color else 255\n            _ = cv2.line(img, (stroke[0][i], stroke[1][i]),\n                         (stroke[0][i + 1], stroke[1][i + 1]), color, lw)\n    if size != BASE_SIZE:\n        return cv2.resize(img, (size, size))\n    else:\n        return img\n```\nThe method above is quite similar to this paper, [Sketch-a-Net that Beats Humans][1]\n\nAnd today I saw two newly published methods:\n\n2. Siyuan Dang's kenel, [How I colored strokes](https://www.kaggle.com/sheboke93/how-i-colored-strokes)\n3. Gunther's kenel, [Fastai conform dataset with resnet18](https://www.kaggle.com/guntherthepenguin/fastai-resnet18-color-coded-and-focalloss) , \n\n\n\nThere is another paper,  [Sketch-R2CNN - An Attentive Network for Vector Sketch Recognition][2], it doesn't use hard coded colors, instead its colors are learnt by a RNN model, which looks very promising. However  the author didn't publish the code so I don't have a chance to try it.  Lukasz Grad has published his implementation here, https://www.kaggle.com/c/quickdraw-doodle-recognition/discussion/73699 , I'll give it a try later.\n\nThe four methods above are what I know so far.\n\nCould you share your code in this thread to show how you generate images? Thanks a lot!\n\n\n  [1]: https://arxiv.org/pdf/1501.07873.pdf\n  [2]: https://arxiv.org/pdf/1811.08170.pdf"
  }
}