<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									All about Segmentation - คุยกันภาษา AI				            </title>
            <link>https://thaikeras.com/community/main-forum/all-about-segmentation/</link>
            <description>ThAI Keras Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 10 Nov 2026 18:04:57 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: All about Segmentation</title>
                        <link>https://thaikeras.com/community/main-forum/all-about-segmentation/#post-769</link>
                        <pubDate>Thu, 26 Jan 2023 06:42:42 +0000</pubDate>
                        <description><![CDATA[ครบเครื่องเรื่อง Segmentation ด้วย Universal Segmentation ที่ Huggingface=========  หยิบรูปภาพที่เราสนใจมาหนึ่งรูป สมมติมีขนาดกว้างและยาว HxW pixels, โมเดล segmentation จะทำหน้าที่ระบุว่า pi...]]></description>
                        <content:encoded><![CDATA[<p>ครบเครื่องเรื่อง Segmentation ด้วย Universal Segmentation ที่ Huggingface</p><p>=========</p><p> </p><p><img src="https://i.imgur.com/A7ZZbmZ.png" /><br /> </p><p>หยิบรูปภาพที่เราสนใจมาหนึ่งรูป สมมติมีขนาดกว้างและยาว HxW pixels, โมเดล segmentation จะทำหน้าที่ระบุว่า pixels ไหนบ้างที่มี objects ที่เราสนใจอยู่ (รูปที่ 1)</p><p> </p><p>โดยมาตรฐานการทำ segmentation นั้นมีอยู่ 3 แบบคือ</p><ol><li>Instance Segmentation (รูป 1.c) ซึ่งเป็นงานที่พัฒนาต่อยอดจาก "Object Detection" ซึ่งคืองานที่จะสร้าง Box สี่เหลี่ยมล้อมรอบ object ต่างๆ ที่เราสนใจ เช่น คน สัตว์ สิ่งของที่สำคัญต่างๆ  โดย Instance Segmentation จะพยายามระบุ pixels ทั้งหมดของ object นั้นๆ มาเลย แทนที่จะระบุ box สี่เหลี่ยมง่ายๆ แบบ object detection<br /><br />งาน Instance Segmentation และ Object Detection จะมีจุดเด่น ดังนี้<br /><br />1.i) detect แต่ละ objects แยกกัน แม้จะเป็นชนิดเดียวกัน เช่นในรูป 1.c มีคนอยู่ 3 คน  เจ้าโมเดล Instance Segmentation ก็จะ return output มา 3 objects คือ "คน 1", "คน 2" และ "คน 3" แทนที่จะ detect ทั้ง 3 คนรวมเป็นก้อนเดียวกันและเรียกว่า "กลุ่มคน"</li></ol><p><br />1.ii) แต่ละ object จะ overlap กันได้ เช่น มีคน 2 คนยืนซ้อนกันอยู่ เจ้า object detection ก็จะพยายาม return box ที่ครอบคลุมส่วนที่ถูกทับมาให้ด้วย ส่วน Instance Segmentation ก็เช่นเดียวกัน จะพยายาม return pixels ที่ถูกทับซ้อนมาให้ด้วย (แต่จะแม่นยำหรือเปล่า เป็นอีกเรื่อง)<br /><br />1.iii) มักไม่สนใจ background เช่น พื้นดิน ท้องฟ้า ทะเล เป็นต้น ดังนั้น pixels ของ background ทั้งหลายจะไม่ถูก detect</p><p><br />.<br /><br />2) Semantic Segmentation (รูป 1.b) มีเป้าหมายที่แตกต่างจาก Instance segmentation นั่นคือต้องการระบุ class ให้ทุกๆ pixel ในรูปว่าเป็น pixel ของอะไร ดังนั้น</p><p> </p><p>2.i) งาน semantic segmentation จึงไม่แยก background หรือ object จึงมี class ของ ท้องฟ้า ทะเล พื้นดิน ด้วย</p><p> </p><p>2.ii) ในทางตรงข้ามกับ 1.i) เจ้า semantic segmentation จะ detect "กลุ่มคน" หรือ "กลุ่ม objects" ที่เป็นชนิดเดียวกันมัดรวมกันมาเลย จะไม่แยก object เหมือน instance detection <br /><br />สังเกตรูป 1.b) ที่ semantic segmentation ให้สีคนทั้ง 3 เป็นสีเดียวกัน นั่นคือมอง pixels ทั้ง 3 กลุ่มนี้เป็นชนิดเดียวกัน<br /> </p><p>.<br /><br />3) Panoptic segmentation ถูกเสนอในปี 2018 โดยทีมของ Facebook AI โดยต้องการเอาจุดเด่นของ Instance และ Semantic segmentation มารวมกัน นั่นคือใน Panoptic segmentation นั้นจะระบุ class ให้ทุก pixel เช่นเดียวกับโมเดล semantic แต่ขณะเดียวกันก็จะระบุ object ต่างๆ แยกกัน เช่นเดียวกันกับ 1.i)  โดยรูป 1.d แสดงตัวอย่าง Output ของ panoptic<br /><br />อย่างไรก็ดีเนื่องจากแต่ละ pixel จะมี 1 class, ถ้ามีคน 2 คนยืนซ้อนกันอยู่ Panoptic model จะไม่สามารถระบุได้<br /> </p><p>.</p><p> </p><p>ไม่ว่าเพื่อนๆ จะสนใจงาน segmentation แบบไหนใน 3 แบบมาตรฐานด้านบน ในวันนี้เราสามารถโหลดโมเดลที่ถูกสอนมาแล้วได้จาก Huggingface model hub ครับ</p><p> </p><p>อย่างไรก็ดี ในปัจจุบันมีโมเดล 3-in-1 ที่เรียกว่า Universal Segmentation ออกมาทำให้เราไม่ต้องโหลดหลายโมเดลในการทำทั้ง 3 งาน</p><p> </p><p>อนึ่ง วันนี้ Huggingface Model Hub ไม่ได้เป็นเบอร์หนึ่งแค่เรื่อง Text/Language  models เท่านั้นอีกต่อไปแล้ว โดย Huggingface นั้นส่งสัญญาณจะเป็นศูนย์รวมของโมเดลชั้นนำทุกหมวดหมู่ เช่น Image/Vision, Audio และ Generative models โดยเฉพาะหลังจากดึงตัว Ross Wrightman เจ้าของ github repo "pytorch image model" เข้าร่วมทีม</p><p> </p><p>.</p><p> </p><p>3-in-1 และ Universal Image Segmentation</p><p>--------------</p><p> </p><p>ปัจจุบันมีโมเดล Mask2Former และ OneFormer ที่เป็นโมเดลแบบ 3-in-1นั่นคือ architecture เดียวสามารถ segment ได้ทั้ง 3 แบบ</p><p> </p><p>อย่างไรก็ดี ในการใช้งานแต่ละแบบนั้นโมเดล Mask2Former จำเป็นต้องเทรนข้อมูลในแต่ละแบบก่อนที่จะใช้งาน ในขณะที่โมเดล OneFormer ถูกออกแบบมาให้เป็น one-architecture, all-dataset นั่นคือสามารถเทรน datasets ของงาน segmentation ทั้ง 3 แบบได้พร้อมกัน (รูปที่ 2)</p><p><img src="https://i.imgur.com/sbjF9S1.png" /></p><p> </p><p> </p><p>จึงเป็นที่มาของชื่อ Universal Image Segmentation ของ Oneformer นั่นเองครับ</p><p> </p><p>ซึ่งเพื่อนๆ สามารถดูวิธีใช้งานง่ายๆ จาก Huggingface Model Hub ได้อย่างละเอียดที่นี่ครับ</p><p> </p><p>Mask2Former:</p><p><a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/Mask2Former/Inference_with_Mask2Former.ipynb">https://github.com/NielsRogge/Transformers-Tutorials/blob/master/Mask2Former/Inference_with_Mask2Former.ipynb</a><br /><br />OneFormer:<br /><a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/OneFormer/Inference_with_OneFormer.ipynb">https://github.com/NielsRogge/Transformers-Tutorials/blob/master/OneFormer/Inference_with_OneFormer.ipynb</a><br /><br />ส่วนการ FineTune โมเดลกับข้อมูลสอนของเพื่อนๆ เองสามารถดูตัวอย่างได้ที่นี่ครับ<br /><a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/MaskFormer/Fine-tuning">https://github.com/NielsRogge/Transformers-Tutorials/tree/master/MaskFormer/Fine-tuning</a><br /> </p><p> </p><p>Credit : โครงหลักและดูลิงก์อ้างอิงเพิ่มเติมได้ที่ blog นี้ครับ : <a href="https://huggingface.co/blog/mask2former">https://huggingface.co/blog/mask2former</a></p><p><br />.</p><p> </p><p>รายละเอียดศึกษาเพิ่มเติม A<br />--------</p><p> </p><p>เดิม Semantic Segmentation ถูก formulate ให้เป็นปัญหา pixel classification ซึ่งทำให้เรากำหนด labels และ loss function ได้ง่ายๆ (นั่้นคือใช้ category crossentropy)</p><p> </p><p>ในขณะที่ Instance Segmentation เนื่องจากวัตถุสามารถซ้อนกันได้ นั่นคือแต่ละ pixel สามารถเป็นส่วนนึงของ object ต่างกันที่ซ้อนกันอยู่ได้,  Instance Segmentation (และโมเดลหลังๆ เช่น DETR, Mask2Former, OneFormer) จะ return output ต่างออกไป เรียกว่า "Binary Mask" output<br /> </p><p><img src="https://i.imgur.com/yfRU41i.png" /></p><p>รูปที่ 3</p><p><br />ดูรูปที่ 3, โมเดลที่ใช้ Binary Mask output จะ return N (masks, class) prediction มา โดย N จะเป็น constant ของโมเดลเช่นถ้า N=100 (ค่ามาตรฐาน) นั่นหมายความว่าโมเดลจะ assume ว่าในรูปจะมีวัตถุไม่เกิน 100 objects</p><p> </p><p>และเนื่องจากบางรูปมีวัตถุ M &lt; N วัตถุ, ในกรณีนี้ "Binary Mask output" ของโมเดลที่แม่นยำก็จะทำนาย Null-class (ไม่มีวัตถุ) ใน N-M masks นั่นเอง</p><p> </p><p>ความยากทางเทคนิคอย่างหนึ่งของ BinaryMask output ก็คือการออกแบบ loss function เนื่องจาก set ของ Binary Masks ที่ทำนายไม่มี natural order หรือตำแหน่งที่ชัดเหมือนกับ pixels นั่นทำให้ในการคำนวณ loss function เราจะไม่ทราบว่า ควรจะเอา Binary Mask ไหนไปเทียบกับ label ไหน</p><p> </p><p>เช่นในรูปที่ 3 โมเดล return output mask-ท้องฟ้า mask-พื้นดิน mask-อาคาร และอีก 97 Null-mask ตามลำดับ ทว่าใน labels ของรูปนี้อาจเป็น "mask-อาคาร" "mask-ท้องฟ้า" และ "mask-พื้นดิน" ซึ่งสังเกตว่า "ลำดับ" ของ prediction กับ label นั้นไม่ตรงกัน</p><p> </p><p>ถ้าเทียบตามลำดับตรงๆ จะทำให้เราเอา predicted-mask-ท้องฟ้า เทียบกับ label-mask-อาคาร เป็นต้น</p><p> </p><p>การคำนวณ loss function ของ Binary Mask Output (ซึ่งในงานวิจัยเรียกว่า Bipartite-Matching Loss) จึงมีขั้นตอนหา Best Matching อีกขั้นตอนหนึ่งก่อนที่จะคำนวณ loss ในแต่ละ mask</p><p> </p><p>โดย Bipartite Matching Loss นั้นใช้ Hugarian Matching Algorithm เพื่อ preprocess สลับลำดับของ labels ก่อนที่จะ match กับแต่ละ predicted Binary mask output</p><p> </p><p>จุดกำเนิดของ Bipartite-Matching Loss นั้นเริ่มมาจากงาน DETR ซึ่งโมเดลหลังๆ ก็นำมาใช้ สามารถศึกษารายละเอียดได้จากแหล่งนี้ครับ</p><p><br />- <a href="https://www.youtube.com/watch?v=BNx-wno-0-g">DETR: End-to-End Object Detection with Transformers | Paper Explained</a> :</p><p><a href="https://www.youtube.com/watch?v=BNx-wno-0-g">https://www.youtube.com/watch?v=BNx-wno-0-g</a></p><p> </p><p> </p><ul><li><a href="https://www.youtube.com/watch?v=xkuoZ50gK4Q">Facebook DETR | ML Coding Series | End to end object detection with transformers</a> :</li></ul><p>           <a href="https://www.youtube.com/watch?v=xkuoZ50gK4Q">https://www.youtube.com/watch?v=xkuoZ50gK4Q</a></p><p><br />.</p><p> </p><p><br />รายละเอียดศึกษาเพิ่มเติม B<br />--------</p><p> </p><p>ถ้าเพื่อนๆ ต้องการเรียนรู้เพิ่มเติมเกี่ยวกับโมเดล Panoptic Segmentation สามารถดูได้จาก<br /><br /><a href="https://pyimagesearch.com/2022/06/29/semantic-vs-instance-vs-panoptic-segmentation/">https://pyimagesearch.com/2022/06/29/semantic-vs-instance-vs-panoptic-segmentation/</a><br /><br /><a href="https://kharshit.github.io/blog/2019/10/18/introduction-to-panoptic-segmentation-tutorial">https://kharshit.github.io/blog/2019/10/18/introduction-to-panoptic-segmentation-tutorial</a></p><p> </p><p>เปเปอร์ MaskFormer : <a href="https://ar5iv.labs.arxiv.org/html/2107.06278">https://ar5iv.labs.arxiv.org/html/2107.06278</a></p><p>เปเปอร์ Mask2Former : <a href="https://ar5iv.labs.arxiv.org/html/2112.01527">https://ar5iv.labs.arxiv.org/html/2112.01527</a></p><p>เปเปอร์ OneFormer : <a href="https://ar5iv.labs.arxiv.org/html/2211.06220">https://ar5iv.labs.arxiv.org/html/2211.06220</a></p>]]></content:encoded>
						                            <category domain="https://thaikeras.com/community/main-forum/">คุยกันภาษา AI</category>                        <dc:creator>The Neural Engineer</dc:creator>
                        <guid isPermaLink="true">https://thaikeras.com/community/main-forum/all-about-segmentation/#post-769</guid>
                    </item>
				                    <item>
                        <title>All about Segmentation</title>
                        <link>https://thaikeras.com/community/main-forum/all-about-segmentation/#post-768</link>
                        <pubDate>Thu, 26 Jan 2023 06:32:26 +0000</pubDate>
                        <description><![CDATA[หลากหลายบริษัทต้องการทำ AI หรือ Machine Learning ไปประยุกต์ใช้ใน business cases ของตน ทว่าประเด็นนึงที่ต้องตระหนักก็คือโมเดล AI หรือ Machine Learning ส่วนใหญ่นั้นต้องการ &quot;กระบวนการทำ labels&quot;...]]></description>
                        <content:encoded><![CDATA[<div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xdj266r x126k92a"><div dir="auto">หลากหลายบริษัทต้องการทำ AI หรือ Machine Learning ไปประยุกต์ใช้ใน business cases ของตน ทว่าประเด็นนึงที่ต้องตระหนักก็คือโมเดล AI หรือ Machine Learning ส่วนใหญ่นั้นต้องการ "กระบวนการทำ labels" ที่ต้องใช้คนมาระบุประเภทหรือชนิดของข้อมูลใน business cases นั้นๆ ซึ่งกระบวนการทำ labels นี้กินเวลาและค่าใช้จ่ายมาก</div></div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto">โชคยังดีที่ทิศทางใหม่ของการพัฒนาโมเดล AI ให้ความสำคัญกับ "few-shots" (เรียนรู้จากการสอนไม่กี่ครั้ง) รวมทั้ง "zero-shot" (เรียนรู้โดยไม่ต้องสอน -- ใช้เทคนิคดึงข้อมูลต่างๆ ที่มนุษย์บันทึกไว้ในอินเตอร์เน็ตมาใช้แทนการสอน)</div></div><div dir="auto"> </div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto">ตัวอย่างสำคัญของโมเดลประเภท zero-shot คือ CLIP จาก OpenAI ในปี 2021 ที่สามารถจำแนกรูปภาพต่างๆ ได้อย่างมหัศจรรย์ รวมทั้งยังมีจุดเด่นมากกว่าโมเดลมาตรฐานทั่วไป เพราะเข้าใจรูปถ่ายมุมแปลกๆ หรือกระทั่งรูปอื่นๆ ที่ไม่ใช่รูปถ่ายได้อย่างดีอีกด้วย (โมเดลมาตรฐานมักถูกสอนจากรูปถ่ายมุมปกติเป็นหลัก ทำให้จำแนกรูปมุมมองแปลก หรือรูปประเภทอื่นๆ เช่นรูปวาดแทบไม่ได้เลย)</div></div><div dir="auto"> </div><div dir="auto"><img src="https://i.imgur.com/UH8MO50.jpg" /></div><div dir="auto"> </div><div class="x11i5rnm xat24cr x1mh8g0r x1vvkbs xtlvy1s x126k92a"><div dir="auto">ล่าสุด NVIDIA ที่่ได้แรงบันดาลใจจาก CLIP ได้เผยแพร่โมเดล zero-shot semantic segmentation (ดูรูปแนบ) ชื่อว่า "GroupViT" ที่สามารถจำแนกประเภทของวัตถุใน "ระดับ pixels" ซึ่งน่าจะเป็นประโยชน์กับ business cases หลากหลาย และยังแสดงให้เห็นว่า language models มาช่วยขยายความสามารถ vision models ได้อย่างยอดเยี่ยม</div><div dir="auto"> </div></div><div dir="auto">github: <a class="x1fey0fg xmper1u x1edh9d7" href="https://github.com/xvjiarui/GroupViT">https://github.com/xvjiarui/GroupViT</a><br /><br />demo: <a class="x1fey0fg xmper1u x1edh9d7" href="https://huggingface.co/spaces/xvjiarui/GroupViT">https://huggingface.co/spaces/xvjiarui/GroupViT</a><br /><br />colab notebook: <a class="x1fey0fg xmper1u x1edh9d7" href="https://colab.research.google.com/github/xvjiarui/GroupViT/blob/master/demo/GroupViT_hf_inference_notebook.ipynb">https://colab.research.google.com/github/xvjiarui/GroupViT/blob/master/demo/GroupViT_hf_inference_notebook.ipynb</a></div><div dir="auto"> </div><div dir="auto"> </div>]]></content:encoded>
						                            <category domain="https://thaikeras.com/community/main-forum/">คุยกันภาษา AI</category>                        <dc:creator>The Neural Engineer</dc:creator>
                        <guid isPermaLink="true">https://thaikeras.com/community/main-forum/all-about-segmentation/#post-768</guid>
                    </item>
							        </channel>
        </rss>
		