{"id":453596,"date":"2025-03-28T09:01:35","date_gmt":"2025-03-28T09:01:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=453596"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=453596","title":{"rendered":"<span>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c FLUX 1 Dev \u0432 Google Colab<\/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>\u0420\u0430\u043d\u0435\u0435 \u044f \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b <a href=\"https:\/\/habr.com\/ru\/articles\/825142\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043f\u0440\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0432 \u043f\u0430\u0440\u0443 \u043a\u043b\u0438\u043a\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 Stable Diffusion \u0432 Google Colab \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Fooocus (\u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439), \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e FLUX 1 Dev, \u043d\u043e \u0431\u0435\u0437 web \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p><strong>\u0428\u0430\u0433 1<\/strong><br \/>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 Google Colab, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 &#171;\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u04224&#187;, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0435\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ed2\/76b\/d08\/ed276bd087f1efc5dbc048af2985461c.png\" alt=\"\u041c\u0435\u043d\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\" title=\"\u041c\u0435\u043d\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\" width=\"1245\" height=\"621\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ed2\/76b\/d08\/ed276bd087f1efc5dbc048af2985461c.png\"\/><\/p>\n<div><figcaption>\u041c\u0435\u043d\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/26b\/72a\/2d6\/26b72a2d6434f232a3db9c7063028503.png\" alt=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u0440\u0435\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b \u044d\u043a\u0440\u0430\u043d\u0430)\" title=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u0440\u0435\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b \u044d\u043a\u0440\u0430\u043d\u0430)\" width=\"508\" height=\"253\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/26b\/72a\/2d6\/26b72a2d6434f232a3db9c7063028503.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u0440\u0435\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b \u044d\u043a\u0440\u0430\u043d\u0430)<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430, \u0432\u0441\u0435\u0433\u043e \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430.<\/p>\n<pre><code>%cd \/content !git clone -b totoro3 https:\/\/github.com\/camenduru\/ComfyUI \/content\/TotoroUI %cd \/content\/TotoroUI  !pip install -q torchsde==0.2.6 einops diffusers accelerate xformers==0.0.29.post3 !apt -y install -qq aria2  !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/flux1-dev-fp8.safetensors -d \/content\/TotoroUI\/models\/unet -o flux1-dev-fp8.safetensors !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/ae.sft -d \/content\/TotoroUI\/models\/vae -o ae.sft !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/clip_l.safetensors -d \/content\/TotoroUI\/models\/clip -o clip_l.safetensors !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/t5xxl_fp8_e4m3fn.safetensors -d \/content\/TotoroUI\/models\/clip -o t5xxl_fp8_e4m3fn.safetensors  import random import torch import numpy as np from PIL import Image import nodes from nodes import NODE_CLASS_MAPPINGS from totoro_extras import nodes_custom_sampler from totoro import model_management  DualCLIPLoader = NODE_CLASS_MAPPINGS[\"DualCLIPLoader\"]() UNETLoader = NODE_CLASS_MAPPINGS[\"UNETLoader\"]() RandomNoise = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"RandomNoise\"]() BasicGuider = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"BasicGuider\"]() KSamplerSelect = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"KSamplerSelect\"]() BasicScheduler = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"BasicScheduler\"]() SamplerCustomAdvanced = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"SamplerCustomAdvanced\"]() VAELoader = NODE_CLASS_MAPPINGS[\"VAELoader\"]() VAEDecode = NODE_CLASS_MAPPINGS[\"VAEDecode\"]() EmptyLatentImage = NODE_CLASS_MAPPINGS[\"EmptyLatentImage\"]()  with torch.inference_mode():     clip = DualCLIPLoader.load_clip(\"t5xxl_fp8_e4m3fn.safetensors\", \"clip_l.safetensors\", \"flux\")[0]     unet = UNETLoader.load_unet(\"flux1-dev-fp8.safetensors\", \"fp8_e4m3fn\")[0]     vae = VAELoader.load_vae(\"ae.sft\")[0]  def closestNumber(n, m):     q = int(n \/ m)     n1 = m * q     if (n * m) &gt; 0:         n2 = m * (q + 1)     else:         n2 = m * (q - 1)     if abs(n - n1) &lt; abs(n - n2):         return n1     return n2<\/code><\/pre>\n<p>\u0416\u043c\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ee\/229\/4b1\/8ee2294b1aa0970333bf1637832342d6.png\" alt=\"\u0417\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u0434\u0430\" title=\"\u0417\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u0434\u0430\" width=\"703\" height=\"238\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ee\/229\/4b1\/8ee2294b1aa0970333bf1637832342d6.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u044d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 5 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p><strong>\u0428\u0430\u0433 2<\/strong><\/p>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430.<\/p>\n<pre><code>sdelatraz = 1  while sdelatraz &lt; 88:   with torch.inference_mode():       positive_prompt = \"A brown bear carries a toilet bowl in his hands and smiles\"       width = 1024       height = 1024       seed = 0       steps = 20       sampler_name = \"euler\"       scheduler = \"simple\"        if seed == 0:           seed = random.randint(0, 18446744073709551615)       print(seed)        soseed = str(seed)       sdelatraz += 1        cond, pooled = clip.encode_from_tokens(clip.tokenize(positive_prompt), return_pooled=True)       cond = [[cond, {\"pooled_output\": pooled}]]       noise = RandomNoise.get_noise(seed)[0]       guider = BasicGuider.get_guider(unet, cond)[0]       sampler = KSamplerSelect.get_sampler(sampler_name)[0]       sigmas = BasicScheduler.get_sigmas(unet, scheduler, steps, 1.0)[0]       latent_image = EmptyLatentImage.generate(closestNumber(width, 16), closestNumber(height, 16))[0]       sample, sample_denoised = SamplerCustomAdvanced.sample(noise, guider, sampler, sigmas, latent_image)       model_management.soft_empty_cache()       decoded = VAEDecode.decode(vae, sample)[0].detach()       Image.fromarray(np.array(decoded*255, dtype=np.uint8)[0]).save(\"\/content\/\" + soseed + \"flux.png\")    Image.fromarray(np.array(decoded*255, dtype=np.uint8)[0]) print(\"\u0414\u0435\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e\")<\/code><\/pre>\n<p>\u0412 \u043f\u044f\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430 <strong>positive_prompt = &#171;\u0421\u044e\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u043c\u0442&#187; , <\/strong>\u0434\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430. \u041d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c seed, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043e\u0442\u0442\u0443\u0434\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a3e\/503\/dc7\/a3e503dc7a3e08762963fcd18463a9a9.png\" alt=\"\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\" title=\"\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\" width=\"595\" height=\"457\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a3e\/503\/dc7\/a3e503dc7a3e08762963fcd18463a9a9.png\"\/><\/p>\n<div><figcaption>\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0441\u0432\u043e\u0439 Google \u0414\u0438\u0441\u043a, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u0441\u044c \u0438 \u0431\u0435\u0437 \u043c\u0435\u043d\u044f \u044f \u0434\u0443\u043c\u0430\u044e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b64\/e9f\/263\/b64e9f2639ade9a73e610d09ffdb87ac.png\" alt=\"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\" title=\"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\" width=\"1244\" height=\"575\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b64\/e9f\/263\/b64e9f2639ade9a73e610d09ffdb87ac.png\"\/><\/p>\n<div><figcaption>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 FLUX 1 Dev \u0432 Google Colab, \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043c\u043e\u0435\u0439 RTX 3060 12 gb \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 FLUX 1 Dev 8fp \u0432 ComfyUI \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0441\u0435\u043c\u043f\u043b\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0433\u0440\u0435\u0432 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0434\u043e 60 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 (\u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 60-70% \u043e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u043e \u0432 ComfyUI, \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c. <\/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\/895212\/\"> https:\/\/habr.com\/ru\/articles\/895212\/<\/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>\u0420\u0430\u043d\u0435\u0435 \u044f \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b <a href=\"https:\/\/habr.com\/ru\/articles\/825142\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043f\u0440\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0432 \u043f\u0430\u0440\u0443 \u043a\u043b\u0438\u043a\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 Stable Diffusion \u0432 Google Colab \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Fooocus (\u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439), \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e FLUX 1 Dev, \u043d\u043e \u0431\u0435\u0437 web \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p><strong>\u0428\u0430\u0433 1<\/strong><br \/>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 Google Colab, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 &#171;\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u04224&#187;, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0435\u0439.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041c\u0435\u043d\u044f\u0435\u043c \u0441\u0440\u0435\u0434\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\">\n<div><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u0440\u0435\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b \u044d\u043a\u0440\u0430\u043d\u0430)<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430, \u0432\u0441\u0435\u0433\u043e \u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430.<\/p>\n<pre><code>%cd \/content !git clone -b totoro3 https:\/\/github.com\/camenduru\/ComfyUI \/content\/TotoroUI %cd \/content\/TotoroUI  !pip install -q torchsde==0.2.6 einops diffusers accelerate xformers==0.0.29.post3 !apt -y install -qq aria2  !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/flux1-dev-fp8.safetensors -d \/content\/TotoroUI\/models\/unet -o flux1-dev-fp8.safetensors !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/ae.sft -d \/content\/TotoroUI\/models\/vae -o ae.sft !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/clip_l.safetensors -d \/content\/TotoroUI\/models\/clip -o clip_l.safetensors !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https:\/\/huggingface.co\/camenduru\/FLUX.1-dev\/resolve\/main\/t5xxl_fp8_e4m3fn.safetensors -d \/content\/TotoroUI\/models\/clip -o t5xxl_fp8_e4m3fn.safetensors  import random import torch import numpy as np from PIL import Image import nodes from nodes import NODE_CLASS_MAPPINGS from totoro_extras import nodes_custom_sampler from totoro import model_management  DualCLIPLoader = NODE_CLASS_MAPPINGS[\"DualCLIPLoader\"]() UNETLoader = NODE_CLASS_MAPPINGS[\"UNETLoader\"]() RandomNoise = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"RandomNoise\"]() BasicGuider = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"BasicGuider\"]() KSamplerSelect = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"KSamplerSelect\"]() BasicScheduler = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"BasicScheduler\"]() SamplerCustomAdvanced = nodes_custom_sampler.NODE_CLASS_MAPPINGS[\"SamplerCustomAdvanced\"]() VAELoader = NODE_CLASS_MAPPINGS[\"VAELoader\"]() VAEDecode = NODE_CLASS_MAPPINGS[\"VAEDecode\"]() EmptyLatentImage = NODE_CLASS_MAPPINGS[\"EmptyLatentImage\"]()  with torch.inference_mode():     clip = DualCLIPLoader.load_clip(\"t5xxl_fp8_e4m3fn.safetensors\", \"clip_l.safetensors\", \"flux\")[0]     unet = UNETLoader.load_unet(\"flux1-dev-fp8.safetensors\", \"fp8_e4m3fn\")[0]     vae = VAELoader.load_vae(\"ae.sft\")[0]  def closestNumber(n, m):     q = int(n \/ m)     n1 = m * q     if (n * m) &gt; 0:         n2 = m * (q + 1)     else:         n2 = m * (q - 1)     if abs(n - n1) &lt; abs(n - n2):         return n1     return n2<\/code><\/pre>\n<p>\u0416\u043c\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0417\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u0434\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u044d\u0442\u043e \u0437\u0430\u0439\u043c\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 5 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p><strong>\u0428\u0430\u0433 2<\/strong><\/p>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430.<\/p>\n<pre><code>sdelatraz = 1  while sdelatraz &lt; 88:   with torch.inference_mode():       positive_prompt = \"A brown bear carries a toilet bowl in his hands and smiles\"       width = 1024       height = 1024       seed = 0       steps = 20       sampler_name = \"euler\"       scheduler = \"simple\"        if seed == 0:           seed = random.randint(0, 18446744073709551615)       print(seed)        soseed = str(seed)       sdelatraz += 1        cond, pooled = clip.encode_from_tokens(clip.tokenize(positive_prompt), return_pooled=True)       cond = [[cond, {\"pooled_output\": pooled}]]       noise = RandomNoise.get_noise(seed)[0]       guider = BasicGuider.get_guider(unet, cond)[0]       sampler = KSamplerSelect.get_sampler(sampler_name)[0]       sigmas = BasicScheduler.get_sigmas(unet, scheduler, steps, 1.0)[0]       latent_image = EmptyLatentImage.generate(closestNumber(width, 16), closestNumber(height, 16))[0]       sample, sample_denoised = SamplerCustomAdvanced.sample(noise, guider, sampler, sigmas, latent_image)       model_management.soft_empty_cache()       decoded = VAEDecode.decode(vae, sample)[0].detach()       Image.fromarray(np.array(decoded*255, dtype=np.uint8)[0]).save(\"\/content\/\" + soseed + \"flux.png\")    Image.fromarray(np.array(decoded*255, dtype=np.uint8)[0]) print(\"\u0414\u0435\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e\")<\/code><\/pre>\n<p>\u0412 \u043f\u044f\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430 <strong>positive_prompt = &#171;\u0421\u044e\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u043c\u0442&#187; , <\/strong>\u0434\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430. \u041d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c seed, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043e\u0442\u0442\u0443\u0434\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0441\u0432\u043e\u0439 Google \u0414\u0438\u0441\u043a, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u0441\u044c \u0438 \u0431\u0435\u0437 \u043c\u0435\u043d\u044f \u044f \u0434\u0443\u043c\u0430\u044e.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 FLUX 1 Dev \u0432 Google Colab, \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043c\u043e\u0435\u0439 RTX 3060 12 gb \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0432\u0430\u043d\u0442\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 FLUX 1 Dev 8fp \u0432 ComfyUI \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432 4 \u0440\u0430\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0441\u0435\u043c\u043f\u043b\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0433\u0440\u0435\u0432 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0434\u043e 60 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 (\u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 60-70% \u043e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438). \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u043e \u0432 ComfyUI, \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c. <\/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\/895212\/\"> https:\/\/habr.com\/ru\/articles\/895212\/<\/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-453596","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/453596","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=453596"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/453596\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=453596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=453596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=453596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}