{"id":402922,"date":"2024-06-29T16:48:09","date_gmt":"2024-06-29T16:48:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=402922"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=402922","title":{"rendered":"<span>I trained a neural network on my drawings and give the model for free (and teach you to create your own)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Great for seamless patterns, abstract drawings, and watercolor-styled images. <strong>How to use it and train a neural network on your own pictures?<\/strong><\/p>\n<p>Download the model here: <a href=\"https:\/\/huggingface.co\/netsvetaev\/netsvetaev-free?ref=dtf.ru\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/netsvetaev\/netsvetaev-free<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b6d\/509\/c41\/b6d509c4158aa1b0fdd4a21b8e765d4c.png\" width=\"768\" height=\"576\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6d\/509\/c41\/b6d509c4158aa1b0fdd4a21b8e765d4c.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/00e\/baa\/db7\/00ebaadb7ec2a027b7c08b949323df2f.png\" width=\"640\" height=\"640\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/00e\/baa\/db7\/00ebaadb7ec2a027b7c08b949323df2f.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/83f\/aac\/d38\/83faacd3853418d16e7540ba266141b3.png\" width=\"512\" height=\"512\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/83f\/aac\/d38\/83faacd3853418d16e7540ba266141b3.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b6d\/a2b\/f4c\/b6da2bf4c25234e0c1fea7574a425e5e.png\" width=\"512\" height=\"640\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6d\/a2b\/f4c\/b6da2bf4c25234e0c1fea7574a425e5e.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/24a\/475\/282\/24a475282711d4c98ae2e9b0e01b6047.png\" width=\"512\" height=\"640\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/24a\/475\/282\/24a475282711d4c98ae2e9b0e01b6047.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>How to use .ckpt model<\/strong><\/p>\n<p>You download the .ckpt file, put it in your models folder. Then it all depends on what fork you&#8217;re using. In <a href=\"https:\/\/github.com\/invoke-ai\" rel=\"noopener noreferrer nofollow\">InvokeAI<\/a>, which I use, the models are added by usual loading invoke.py and executing <code>!import_model<\/code> command in console.<\/p>\n<p><strong>How to train neural network on your images if you don&#8217;t have nvidia 4090?<\/strong><\/p>\n<p>Google has a wonderful service called Colab: Google gives you free server for about an hour. That&#8217;s enough to build a model from 15-30-50 images.<\/p>\n<p>First go here and get acquainted with colab (but don&#8217;t touch anything): <a href=\"https:\/\/colab.research.google.com\/github\/ShivamShrirao\/diffusers\/blob\/main\/examples\/dreambooth\/DreamBooth_Stable_Diffusion.ipynb\" rel=\"noopener noreferrer nofollow\">https:\/\/colab.research.google.com\/github\/ShivamShrirao\/diffusers\/blob\/main\/examples\/dreambooth\/DreamBooth_Stable_Diffusion.ipynb<\/a><\/p>\n<p>All that is required from you, except for clicking through each code window and uploading pictures, is a hugging face token.<\/p>\n<p>Register at <a href=\"http:\/\/huggingface.co\" rel=\"noopener noreferrer nofollow\">huggingface.co<\/a>, and then create a token in the settings: <a href=\"https:\/\/huggingface.co\/settings\/tokens?ref=dtf.ru\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/settings\/tokens<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d68\/d5e\/29c\/d68d5e29cfd8302e1b98359cf9650cc8.png\" width=\"900\" height=\"577\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d68\/d5e\/29c\/d68d5e29cfd8302e1b98359cf9650cc8.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Insert the token here:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/736\/b62\/639\/736b626393086e5759366d1c83abc12f.png\" width=\"897\" height=\"258\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/736\/b62\/639\/736b626393086e5759366d1c83abc12f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Check the box to save the model to google drive and name a folder, if you want (it will be created automatically)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/74f\/444\/206\/74f4442064d8a63a6e7ffc89da0279ad.png\" width=\"599\" height=\"354\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/74f\/444\/206\/74f4442064d8a63a6e7ffc89da0279ad.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Next, specify how we will call your style or object<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eda\/7ab\/3c9\/eda7ab3c938473edd78a751359c227f6.png\" width=\"898\" height=\"358\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eda\/7ab\/3c9\/eda7ab3c938473edd78a751359c227f6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>This is not so important, but you need to remember this token to invoke your object.<\/p>\n<p>Then upload the pictures:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8da\/e01\/029\/8dae01029fbd6737543897b47f5e81e2.png\" width=\"599\" height=\"178\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8da\/e01\/029\/8dae01029fbd6737543897b47f5e81e2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>You need to use the size of 512&#215;512 pixels, and it is better to prepare them in advance. It&#8217;s up to you to decide what to cut, but I recommend to cut it so that the composition and significant objects were preserved. You can also make several separate zoomed in and cropped pictures.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b36\/c42\/dcf\/b36c42dcf880a994f94fbf1666dc97ac.png\" alt=\"Example images for my model\" title=\"Example images for my model\" width=\"900\" height=\"579\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b36\/c42\/dcf\/b36c42dcf880a994f94fbf1666dc97ac.png\"\/><figcaption>Example images for my model<\/figcaption><\/figure>\n<p>Depending on the number of images, you can change the number of training steps. A reasonable number is 100 steps * number of pictures. For 8 images (at least 8 is enough, btw) \u2014 800 steps is enough. Too many steps is also bad: the generation will become too contrast and you will get artifacts on images (overtrained model).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/269\/575\/cbe\/269575cbe80788f4b4ec7a0a1591177e.png\" alt=\"\" title=\"\" width=\"600\" height=\"432\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/269\/575\/cbe\/269575cbe80788f4b4ec7a0a1591177e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Next, simply start each block in the colab with the Play button in the top left corner and wait for the completion of each code. When you get to the section shown above and start it, you will see the learning process. It will take about 10 minutes to prepare + another 15-30 minutes, depending on the number of pictures and steps. <\/p>\n<p>After training you can test the model on test generation and convert it to .ckpt format:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fc3\/1f0\/f62\/fc31f0f62c23bca5f1ac8d892f9cd538.png\" width=\"600\" height=\"208\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc3\/1f0\/f62\/fc31f0f62c23bca5f1ac8d892f9cd538.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>Now you have the file on your disk: download it and add it to your favorite fork.<\/strong><\/p>\n<p>Additionally you can delete unnecessary files and finish the process<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/06c\/f4f\/fc4\/06cf4ffc415883a09bef2dab460e37b1.png\" width=\"899\" height=\"289\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/06c\/f4f\/fc4\/06cf4ffc415883a09bef2dab460e37b1.png\"\/><figcaption><\/figcaption><\/figure>\n<hr\/>\n<p><strong>About me:<\/strong> My name is Artur Netsvetaev, I am a product manager, entrepreneur and <a href=\"https:\/\/netsvetaev.com\" rel=\"noopener noreferrer nofollow\">UI\/UX designer<\/a>. I help with the development of the<a href=\"https:\/\/github.com\/invoke-ai\" rel=\"noopener noreferrer nofollow\"> InvokeAI <\/a>interface and have been using it myself since the beginning of this project.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/699002\/\"> https:\/\/habr.com\/ru\/articles\/699002\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Great for seamless patterns, abstract drawings, and watercolor-styled images. <strong>How to use it and train a neural network on your own pictures?<\/strong><\/p>\n<p>Download the model here: <a href=\"https:\/\/huggingface.co\/netsvetaev\/netsvetaev-free?ref=dtf.ru\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/netsvetaev\/netsvetaev-free<\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p><strong>How to use .ckpt model<\/strong><\/p>\n<p>You download the .ckpt file, put it in your models folder. Then it all depends on what fork you&#8217;re using. In <a href=\"https:\/\/github.com\/invoke-ai\" rel=\"noopener noreferrer nofollow\">InvokeAI<\/a>, which I use, the models are added by usual loading invoke.py and executing <code>!import_model<\/code> command in console.<\/p>\n<p><strong>How to train neural network on your images if you don&#8217;t have nvidia 4090?<\/strong><\/p>\n<p>Google has a wonderful service called Colab: Google gives you free server for about an hour. That&#8217;s enough to build a model from 15-30-50 images.<\/p>\n<p>First go here and get acquainted with colab (but don&#8217;t touch anything): <a href=\"https:\/\/colab.research.google.com\/github\/ShivamShrirao\/diffusers\/blob\/main\/examples\/dreambooth\/DreamBooth_Stable_Diffusion.ipynb\" rel=\"noopener noreferrer nofollow\">https:\/\/colab.research.google.com\/github\/ShivamShrirao\/diffusers\/blob\/main\/examples\/dreambooth\/DreamBooth_Stable_Diffusion.ipynb<\/a><\/p>\n<p>All that is required from you, except for clicking through each code window and uploading pictures, is a hugging face token.<\/p>\n<p>Register at <a href=\"http:\/\/huggingface.co\" rel=\"noopener noreferrer nofollow\">huggingface.co<\/a>, and then create a token in the settings: <a href=\"https:\/\/huggingface.co\/settings\/tokens?ref=dtf.ru\" rel=\"noopener noreferrer nofollow\">https:\/\/huggingface.co\/settings\/tokens<\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Insert the token here:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Check the box to save the model to google drive and name a folder, if you want (it will be created automatically)<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Next, specify how we will call your style or object<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>This is not so important, but you need to remember this token to invoke your object.<\/p>\n<p>Then upload the pictures:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>You need to use the size of 512&#215;512 pixels, and it is better to prepare them in advance. It&#8217;s up to you to decide what to cut, but I recommend to cut it so that the composition and significant objects were preserved. You can also make several separate zoomed in and cropped pictures.<\/p>\n<figure class=\"full-width\"><figcaption>Example images for my model<\/figcaption><\/figure>\n<p>Depending on the number of images, you can change the number of training steps. A reasonable number is 100 steps * number of pictures. For 8 images (at least 8 is enough, btw) \u2014 800 steps is enough. Too many steps is also bad: the generation will become too contrast and you will get artifacts on images (overtrained model).<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Next, simply start each block in the colab with the Play button in the top left corner and wait for the completion of each code. When you get to the section shown above and start it, you will see the learning process. It will take about 10 minutes to prepare + another 15-30 minutes, depending on the number of pictures and steps. <\/p>\n<p>After training you can test the model on test generation and convert it to .ckpt format:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>Now you have the file on your disk: download it and add it to your favorite fork.<\/strong><\/p>\n<p>Additionally you can delete unnecessary files and finish the process<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<hr\/>\n<p><strong>About me:<\/strong> My name is Artur Netsvetaev, I am a product manager, entrepreneur and <a href=\"https:\/\/netsvetaev.com\" rel=\"noopener noreferrer nofollow\">UI\/UX designer<\/a>. I help with the development of the<a href=\"https:\/\/github.com\/invoke-ai\" rel=\"noopener noreferrer nofollow\"> InvokeAI <\/a>interface and have been using it myself since the beginning of this project.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/699002\/\"> https:\/\/habr.com\/ru\/articles\/699002\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-402922","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/402922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=402922"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/402922\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=402922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=402922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=402922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}