{"id":2504,"date":"2021-08-31T09:00:00","date_gmt":"2021-08-31T01:00:00","guid":{"rendered":"https:\/\/blog.ailia.ai\/uncategorized\/m-lsd-machine-learning-model-for-detecting-wireframes\/"},"modified":"2025-05-20T17:26:24","modified_gmt":"2025-05-20T09:26:24","slug":"m-lsd-machine-learning-model-for-detecting-wireframes","status":"publish","type":"post","link":"https:\/\/blog.ailia.ai\/en\/tips-en\/m-lsd-machine-learning-model-for-detecting-wireframes\/","title":{"rendered":"M-LSD : Machine Learning Model for Detecting Wireframes"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"cbf1\"><strong>Overview<\/strong><\/h3>\n\n\n\n<p id=\"3f52\"><em>M-LSD<\/em>\u00a0is a machine learning model developed by\u00a0<em>NAVER\u00a0<\/em>to detect wireframes of objects. Since it can accurately detect the contours of sheets of paper and books, it can be used for pre-processing of OCR.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"746\" height=\"255\" src=\"https:\/\/blog.ailia.ai\/wp-content\/uploads\/image-45-1.jpg\" alt=\"\" class=\"wp-image-279\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/github.com\/navervision\/mlsd\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/navervision\/mlsd<\/a><\/figcaption><\/figure>\n\n\n\n<p><a href=\"https:\/\/arxiv.org\/abs\/2106.00186?source=post_page-----876bef18d908--------------------------------\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><a href=\"https:\/\/arxiv.org\/abs\/2106.00186\" target=\"_blank\" rel=\"noreferrer noopener\">Towards Real-time and Light-weight Line Segment Detection<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3dd5\"><strong>Architecture<\/strong><\/h3>\n\n\n\n<p id=\"3e48\">The classic approach to line detection is complex and made of with multiple modules, whereas M-LSD detects lines in a single shot, which allows for fast processing.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"812\" height=\"569\" src=\"https:\/\/blog.ailia.ai\/wp-content\/uploads\/image-45.png\" alt=\"\" class=\"wp-image-280\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/arxiv.org\/pdf\/2106.00186.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/arxiv.org\/pdf\/2106.00186.pdf<\/a><\/figcaption><\/figure>\n\n\n\n<p id=\"5d1e\">The model uses\u00a0<em>MobileNetV2\u00a0<\/em>as backbone, with the addition of a block for generating heatmaps in the later stage.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1315\" height=\"654\" src=\"https:\/\/blog.ailia.ai\/wp-content\/uploads\/image-46.jpg\" alt=\"\" class=\"wp-image-281\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/arxiv.org\/pdf\/2106.00186.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/arxiv.org\/pdf\/2106.00186.pdf<\/a><\/figcaption><\/figure>\n\n\n\n<p id=\"8f34\">Line segments are defined as\u00a0<em>Tri-Points (TP)<\/em>, as shown below. The line segment is defined by\u00a0<code>lc<\/code>, which indicates the center point,\u00a0<code>ds<\/code>\u00a0which is the displacement vector to the start point, and\u00a0<code>de<\/code>\u00a0which is the displacement vector to the end point.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"587\" height=\"444\" src=\"https:\/\/blog.ailia.ai\/wp-content\/uploads\/image-44.png\" alt=\"\" class=\"wp-image-277\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/arxiv.org\/pdf\/2106.00186.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/arxiv.org\/pdf\/2106.00186.pdf<\/a><\/figcaption><\/figure>\n\n\n\n<p id=\"a513\">The output of the model is a (1,200,2) vector\u00a0<code>lc<\/code>\u00a0representing the center point of the line segments, a (1,200) vector which is the confidence of the line segments, and a displacement map (1,256,256,4) representing the displacement from the center point to the start and end points of the line segments. Line segments can then be calculated by adding the three vectors of center points, start points, and end points.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"390\" height=\"91\" src=\"https:\/\/blog.ailia.ai\/wp-content\/uploads\/image-43.png\" alt=\"\" class=\"wp-image-276\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/arxiv.org\/pdf\/2106.00186.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/arxiv.org\/pdf\/2106.00186.pdf<\/a><\/figcaption><\/figure>\n\n\n\n<p id=\"dfa6\">The data sets used for training are\u00a0<em>Wireframe<\/em>\u00a0and\u00a0<em>YorkUrban<\/em>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"594\" src=\"https:\/\/blog.ailia.ai\/wp-content\/uploads\/image-45.jpg\" alt=\"\" class=\"wp-image-278\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/arxiv.org\/pdf\/2106.00186.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/arxiv.org\/pdf\/2106.00186.pdf<\/a><\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Usage<\/strong><\/h3>\n\n\n\n<p id=\"3432\">M-LSD can be used with ailia SDK 1.2.8 and later with the following command to detect wireframes from the webcam video stream.<\/p>\n\n\n\n<p id=\"3432\"><code>$ python3 mlsd.py -v 0<\/code><a href=\"https:\/\/github.com\/axinc-ai\/ailia-models\/tree\/master\/line_segment_detection\/mlsd?source=post_page-----876bef18d908--------------------------------\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/axinc-ai\/ailia-models\/tree\/master\/line_segment_detection\/mlsd\" target=\"_blank\" rel=\"noreferrer noopener\">ailia-models\/line_segment_detection\/mlsd at master \u00b7 axinc-ai\/ailia-models<\/a><\/p>\n\n\n\n<p id=\"d0e1\">Here is the result you can expect.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"ailia MODELS : M-LSD\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/GkJy7qwdiy0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p id=\"8b1e\"><a href=\"https:\/\/axinc.jp\/en\/\" rel=\"noreferrer noopener\" target=\"_blank\">ax Inc.<\/a>&nbsp;has developed&nbsp;<a href=\"https:\/\/ailia.jp\/en\/\" rel=\"noreferrer noopener\" target=\"_blank\">ailia SDK<\/a>, which enables cross-platform, GPU-based rapid inference.<\/p>\n\n\n\n<p id=\"8b1e\">ax Inc. provides a wide range of services from consulting and model creation, to the development of AI-based applications and SDKs. Feel free to&nbsp;<a href=\"https:\/\/axinc.jp\/en\/\" rel=\"noreferrer noopener\" target=\"_blank\">contact us<\/a>&nbsp;for any inquiry.<\/p>\n\n\n\n<p><a href=\"https:\/\/medium.com\/@kyakuno?source=post_page-----876bef18d908--------------------------------\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview M-LSD\u00a0is a machine learning model developed by\u00a0NAVER\u00a0to detect wireframes of objects. Since it can accurately detect the contours of sheets of paper and books, it can be used for pre-processing of OCR. Towards Real-time and Light-weight Line Segment Detection Architecture The classic approach to line detection is complex and made of with multiple modules, whereas M-LSD detects lines in a single shot, which allows for fast processing. The model uses\u00a0MobileNetV2\u00a0as backbone, with the addition of a block for generating heatmaps in the later stage. Line segments are defined as\u00a0Tri-Points (TP), as shown below. The line segment is defined by\u00a0lc, which indicates the center point,\u00a0ds\u00a0which is the displacement vector to [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":2403,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[255],"tags":[266],"class_list":["post-2504","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips-en","tag-ailiamodels-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/posts\/2504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/comments?post=2504"}],"version-history":[{"count":1,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/posts\/2504\/revisions"}],"predecessor-version":[{"id":2506,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/posts\/2504\/revisions\/2506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/media\/2403"}],"wp:attachment":[{"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/media?parent=2504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/categories?post=2504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ailia.ai\/en\/wp-json\/wp\/v2\/tags?post=2504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}