{"id":29372,"date":"2025-03-01T09:26:31","date_gmt":"2025-03-01T01:26:31","guid":{"rendered":"https:\/\/www.1ai.net\/?p=29372"},"modified":"2025-02-21T21:29:33","modified_gmt":"2025-02-21T13:29:33","slug":"stable-diffusion%e6%80%8e%e4%b9%88%e7%94%a8%ef%bc%9fstable-diffusion%e6%8f%92%e4%bb%b6controlnet%e7%9a%84%e7%ba%bf%e7%a8%bf%e7%a1%ac%e8%be%b9%e7%bc%98%e4%b8%8e%e8%bd%af%e8%be%b9%e7%bc%98%e6%a8%a1","status":"publish","type":"post","link":"https:\/\/www.1ai.net\/en\/29372.html","title":{"rendered":"How to use Stable Diffusion, the Stable Diffusion plugin ControlNet's line drawing hard and soft edge modes."},"content":{"rendered":"<p>In this section we will take an in-depth look at ControlNet's Line Drawing Hard and Soft Edge modes. Through this section, you will learn the basic principles of line constraints, the application of hard and soft edge modes, and their importance in real projects.<\/p>\n<p>I. What are line constraints?<\/p>\n<p>Line constraints are used in ControlNet for guiding the<a href=\"https:\/\/www.1ai.net\/en\/tag\/stable-diffusion\" title=\"_Other Organiser\" target=\"_blank\" >Stable Diffusion<\/a>A way of generating results which influences the generation of the final image by extracting line features. The importance of line constraints in Stable Diffusion cannot be overstated, as they allow us to control the generation of the image in multiple dimensions.<\/p>\n<p>II. Hard edge mode (Canny)<\/p>\n<p>Hard edge mode is one of the first features of ControlNet that can accurately extract the edges of items in a picture, making the resulting picture very similar in outline to the input picture.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29373\" title=\"634a4a46j00ss1c2y005md000u000esm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/634a4a46j00ss1c2y005md000u000esm.jpg\" alt=\"634a4a46j00ss1c2y005md000u000esm\" width=\"1080\" height=\"532\" \/><\/p>\n<p>Hard Edge Mode Use Cases<\/p>\n<p>1.1 Product redesign<\/p>\n<p>Take a commercial order case as an example of how to use the hard edge pattern to provide inspiration for designers by making random substitutions of colors and materials while preserving the silhouette and fit of the shoe.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29374\" title=\"c2b12ab7j00ss1c2v001dd000sg00hsm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/c2b12ab7j00ss1c2v001dd000sg00hsm.jpg\" alt=\"c2b12ab7j00ss1c2v001dd000sg00hsm\" width=\"1024\" height=\"640\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29375\" title=\"8c6845e5j00ss1c2y0035d000u000irm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/8c6845e5j00ss1c2y0035d000u000irm.jpg\" alt=\"8c6845e5j00ss1c2y0035d000u000irm\" width=\"1080\" height=\"675\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29376\" title=\"e51bc2cdj00ss1c2v000yd000lc00e8m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/e51bc2cdj00ss1c2v000yd000lc00e8m.jpg\" alt=\"e51bc2cdj00ss1c2v000yd000lc00e8m\" width=\"768\" height=\"512\" \/><\/p>\n<p>1.2 Line drawing generation<\/p>\n<p>We use a secondary character generation line drawing as an example to illustrate the application of hard edge mode for line drawing generation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29377\" title=\"7bcbb8e2j00ss1c2v000id000e800e8m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/7bcbb8e2j00ss1c2v000id000e800e8m.jpg\" alt=\"7bcbb8e2j00ss1c2v000id000e800e8m\" width=\"512\" height=\"512\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29378\" title=\"73acccf9j00ss1c2y00dvd000u000u0m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/73acccf9j00ss1c2y00dvd000u000u0m.jpg\" alt=\"73acccf9j00ss1c2y00dvd000u000u0m\" width=\"1080\" height=\"1080\" \/><\/p>\n<p>1.3 Colorize the line drawings<\/p>\n<p>We can also color the line drawing, which is the opposite process of line generation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29379\" title=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/cdf2bfbfj00ss1c2y00a5d000e800lcm.jpg\" alt=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29380\" title=\"650401b9j00ss1c31025ud000sg016om\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/650401b9j00ss1c31025ud000sg016om.jpg\" alt=\"650401b9j00ss1c31025ud000sg016om\" width=\"1024\" height=\"1536\" \/><\/p>\n<p>Advantages and Disadvantages of Hard Edge Mode<\/p>\n<p>The advantage of the hard edge mode is its accuracy, but it also has some problems, such as the details can not withstand a close look, and the reproduction of the material is not careful enough. In addition, the hard edge mode is prone to recognizing the contours as double when dealing with quadratic images, which leads to some problems in the generated images.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29379\" title=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/cdf2bfbfj00ss1c2y00a5d000e800lcm.jpg\" alt=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29381\" title=\"fee96562j00ss1c2y002ld000lc00w0m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/fee96562j00ss1c2y002ld000lc00w0m.jpg\" alt=\"fee96562j00ss1c2y002ld000lc00w0m\" width=\"768\" height=\"1152\" \/><\/p>\n<p>Third, the soft edge mode (SoftEdge)<\/p>\n<p>To solve the problem of hard edge mode, soft edge mode was created. It avoids the problem of double lines by softening the edges, but at the same time sacrifices some constraining power.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29382\" title=\"42863c9ej00ss1c2x005vd000u000esm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/42863c9ej00ss1c2x005vd000u000esm.jpg\" alt=\"42863c9ej00ss1c2x005vd000u000esm\" width=\"1080\" height=\"532\" \/><\/p>\n<p>Soft Edge Model Use Cases<\/p>\n<p>We show the advantages of the soft edge mode in dealing with edge extraction, especially in avoiding the double line problem, through a cat case.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29383\" title=\"56f18ed9j00ss1c2v000xd000e800e8m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/56f18ed9j00ss1c2v000xd000e800e8m.jpg\" alt=\"56f18ed9j00ss1c2v000xd000e800e8m\" width=\"512\" height=\"512\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29385\" title=\"422a081cj00ss1c2y0086d000lc00lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/422a081cj00ss1c2y0086d000lc00lcm.jpg\" alt=\"422a081cj00ss1c2y0086d000lc00lcm\" width=\"768\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29384\" title=\"7af95349j00ss1c32017zd000sg00sgm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/7af95349j00ss1c32017zd000sg00sgm.jpg\" alt=\"7af95349j00ss1c32017zd000sg00sgm\" width=\"1024\" height=\"1024\" \/><\/p>\n<p>Advantages and Disadvantages of Soft Edge Mode<\/p>\n<p>The advantage of the soft edge mode is its softening of the edges, but it has weak constraints that may cause the generated image to differ in structure from the original.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29379\" title=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/cdf2bfbfj00ss1c2y00a5d000e800lcm.jpg\" alt=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29380\" title=\"650401b9j00ss1c31025ud000sg016om\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/650401b9j00ss1c31025ud000sg016om.jpg\" alt=\"650401b9j00ss1c31025ud000sg016om\" width=\"1024\" height=\"1536\" \/><\/p>\n<p>IV. ControlNet preprocessor<\/p>\n<p>ControlNet offers a wide range of preprocessors, including different variants of hard and soft edges, to suit different application scenarios.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29387\" title=\"43c0a2ebj00ss1c2x004ed000u000esm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/43c0a2ebj00ss1c2x004ed000u000esm.jpg\" alt=\"43c0a2ebj00ss1c2x004ed000u000esm\" width=\"1080\" height=\"532\" \/><\/p>\n<p>There is also a \"None\" option in the preprocessor that allows us to upload feature maps directly for generation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29386\" title=\"a12237e7j00ss1c2x004yd000u000esm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/a12237e7j00ss1c2x004yd000u000esm.jpg\" alt=\"a12237e7j00ss1c2x004yd000u000esm\" width=\"1080\" height=\"532\" \/><\/p>\n<p>Preprocessor's Inversion Mode<\/p>\n<p>The preprocessor's inversion mode allows us to convert a line drawing with black lines on a white background into a computer-recognizable feature map with white lines on a black background for different generative needs.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29388\" title=\"99978313j00ss1c2x002jd000rp009km\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/99978313j00ss1c2x002jd000rp009km.jpg\" alt=\"99978313j00ss1c2x002jd000rp009km\" width=\"997\" height=\"344\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29379\" title=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/cdf2bfbfj00ss1c2y00a5d000e800lcm.jpg\" alt=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29389\" title=\"0e3520e9j00ss1c2x00a6d000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/0e3520e9j00ss1c2x00a6d000e800lcm.jpg\" alt=\"0e3520e9j00ss1c2x00a6d000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p>Threshold control<\/p>\n<p>The control of thresholding in ControlNet determines the fineness of feature extraction. By adjusting the threshold, we can control the sparseness of the lines in the generated image.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29390\" title=\"3eb5fc54j00ss1c2w0012d000po008sm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/3eb5fc54j00ss1c2w0012d000po008sm.jpg\" alt=\"3eb5fc54j00ss1c2w0012d000po008sm\" width=\"924\" height=\"316\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29379\" title=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/cdf2bfbfj00ss1c2y00a5d000e800lcm.jpg\" alt=\"cdf2bfbfj00ss1c2y00a5d000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29391\" title=\"0bf8c986j00ss1c30001gd000e800lcm\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/0bf8c986j00ss1c30001gd000e800lcm.jpg\" alt=\"0bf8c986j00ss1c30001gd000e800lcm\" width=\"512\" height=\"768\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29381\" title=\"fee96562j00ss1c2y002ld000lc00w0m\" src=\"https:\/\/www.1ai.net\/wp-content\/uploads\/2025\/02\/fee96562j00ss1c2y002ld000lc00w0m.jpg\" alt=\"fee96562j00ss1c2y002ld000lc00w0m\" width=\"768\" height=\"1152\" \/><\/p>\n<p>V. Summary<\/p>\n<p>Through the study of this section, we have gained a deep understanding of ControlNet's hard and soft edge modes, and mastered how to choose the appropriate line constraints according to project requirements.<\/p>\n<p>This knowledge will provide us with a solid foundation for subsequent study and practice.<\/p>\n<p>I hope this article helps you better understand ControlNet's line constraint model.<\/p>","protected":false},"excerpt":{"rendered":"<p>In this section we will take an in-depth look at ControlNet's Line Drawing Hard and Soft Edge modes. Through this section, you will learn the basic principles of line constraints, the application of hard edge mode and soft edge mode, and their importance in real projects. I. What is Line Constraints? Line constraints are a way used in ControlNet to guide the results of Stable Diffusion, which affects the generation of the final image by extracting line features. The importance of line constraints in Stable Diffusion is self-evident, as it allows us to control the image generation from multiple dimensions. Hard Edge Mode (Canny) Hard Edge Mode is one of the earliest features of ControlNet, which can precisely<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[149,144],"tags":[2328,197,198],"collection":[262],"class_list":{"0":"post-29372","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-jiaocheng","7":"category-baike","8":"tag-ai","9":"tag-stable-diffusion","11":"collection-stablediffusion"},"acf":[],"_links":{"self":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/posts\/29372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/comments?post=29372"}],"version-history":[{"count":0,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/posts\/29372\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/media?parent=29372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/categories?post=29372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/tags?post=29372"},{"taxonomy":"collection","embeddable":true,"href":"https:\/\/www.1ai.net\/en\/wp-json\/wp\/v2\/collection?post=29372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}