Buckets:
| # Eski nesil adaptörler | |
| Bu yöntemler hâlâ desteklenmektedir, özellikle Stable Diffusion ailesi kontrol noktalarında. Yeni çalışmalar için [LoRA](../tutorials/using_peft_for_inference), [IP-Adapter](./ip_adapter) ve [ControlNet](./controlnet) tercih edilmelidir. | |
| ## T2I-Adapter | |
| [T2I-Adapter](https://huggingface.co/papers/2302.08453), kontrollü üretim için bir adaptördür. Bir kontrol sinyalinin (örneğin, derinlik haritası veya canny kenarları) önceden eğitilmiş bir modelin iç özelliklerine eşlenmesini öğrenir ve üretim sırasında bu yönlendirmeyi ekler. Rolü [ControlNet](./controlnet) ile benzerdir, ancak daha hafif bir tak-çalıştır adaptördür. | |
| Kontrol koşullu bir adaptör yükleyin, ardından [from_pretrained()](/docs/diffusers/main/tr/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained) ile hattı yükleyin ve `adapter=` ile geçirin. | |
| ```py | |
| import torch | |
| from diffusers import T2IAdapter, StableDiffusionXLAdapterPipeline, AutoencoderKL | |
| t2i_adapter = T2IAdapter.from_pretrained( | |
| "TencentARC/t2i-adapter-canny-sdxl-1.0", | |
| dtype=torch.float16, | |
| ) | |
| ``` | |
| [opencv-python](https://github.com/opencv/opencv-python) ile bir canny görüntüsü oluşturun. | |
| ```py | |
| import cv2 | |
| import numpy as np | |
| from PIL import Image | |
| from diffusers.utils import load_image | |
| original_image = load_image( | |
| "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-enhanced-prompt.png" | |
| ) | |
| image = np.array(original_image) | |
| low_threshold = 100 | |
| high_threshold = 200 | |
| image = cv2.Canny(image, low_threshold, high_threshold) | |
| image = image[:, :, None] | |
| image = np.concatenate([image, image, image], axis=2) | |
| canny_image = Image.fromarray(image) | |
| ``` | |
| Canny görüntüsünü bir görüntü üretmek için pipeline'a iletin. | |
| ```py | |
| vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16) | |
| pipeline = StableDiffusionXLAdapterPipeline.from_pretrained( | |
| "stabilityai/stable-diffusion-xl-base-1.0", | |
| adapter=t2i_adapter, | |
| vae=vae, | |
| dtype=torch.float16, | |
| ).to("cuda") # or "mps", "xpu", "cpu" | |
| prompt = """ | |
| A photorealistic overhead image of a cat reclining sideways in a flamingo pool floatie holding a margarita. | |
| The cat is floating leisurely in the pool and completely relaxed and happy. | |
| """ | |
| pipeline( | |
| prompt, | |
| image=canny_image, | |
| num_inference_steps=100, | |
| guidance_scale=10, | |
| ).images[0] | |
| ``` | |
| orijinal görüntü | |
| canny görüntü | |
| oluşturulan görsel | |
| Ayrıca bkz. [T2I-Adapter eğitimi](../training/t2i_adapters). | |
| ### MultiAdapter | |
| Birden çok kontrolü (örneğin canny ve depth) `MultiAdapter` ile birleştirin. `MultiAdapter`'a bir adaptör listesi iletin, ardından eşleşen kontrol görüntülerini bir liste olarak pipeline'a iletin. | |
| ```py | |
| import torch | |
| from diffusers.utils import load_image | |
| from diffusers import StableDiffusionXLAdapterPipeline, AutoencoderKL, MultiAdapter, T2IAdapter | |
| canny_image = load_image( | |
| "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/canny-cat.png" | |
| ) | |
| depth_image = load_image( | |
| "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl_depth_image.png" | |
| ) | |
| controls = [canny_image, depth_image] | |
| prompt = [""" | |
| a relaxed rabbit sitting on a striped towel next to a pool with a tropical drink nearby, | |
| bright sunny day, vacation scene, 35mm photograph, film, professional, 4k, highly detailed | |
| """] | |
| adapters = MultiAdapter( | |
| [ | |
| T2IAdapter.from_pretrained("TencentARC/t2i-adapter-canny-sdxl-1.0", dtype=torch.float16), | |
| T2IAdapter.from_pretrained("TencentARC/t2i-adapter-depth-midas-sdxl-1.0", dtype=torch.float16), | |
| ] | |
| ) | |
| ``` | |
| Adaptörleri, istemi ve kontrol görsellerini [StableDiffusionXLAdapterPipeline](/docs/diffusers/main/tr/api/pipelines/stable_diffusion/adapter#diffusers.StableDiffusionXLAdapterPipeline) bileşenine iletin. Her bir kontrole ne kadar ağırlık verileceğini belirlemek için `adapter_conditioning_scale` parametresini kullanın. | |
| ```py | |
| vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16) | |
| pipeline = StableDiffusionXLAdapterPipeline.from_pretrained( | |
| "stabilityai/stable-diffusion-xl-base-1.0", | |
| dtype=torch.float16, | |
| vae=vae, | |
| adapter=adapters, | |
| ).to("cuda") # or "mps", "xpu", "cpu" | |
| pipeline( | |
| prompt, | |
| image=controls, | |
| height=1024, | |
| width=1024, | |
| adapter_conditioning_scale=[0.7, 0.7] | |
| ).images[0] | |
| ``` | |
| canny görüntü | |
| derinlik haritası | |
| oluşturulan görsel | |
| ## Metinsel Tersine Çevirme | |
| [Textual Inversion](https://huggingface.co/papers/2208.01618), benzersiz bir jetona (`<sks>`) bağlanan kelme gömme vektörlerini ince ayarlayarak modeli 3-5 görselden bir kavrama kişiselleştirir. Ardından, o kavramı (örneğin, piksel sanatı) üretmek için istemcinizde bu jetonu kullanabilirsiniz. | |
| Textual Inversion ağırlıkları yalnızca kelime gömlemeleri olduğu için genellikle birkaç KB civarındadır. Bunları [from_pretrained()](/docs/diffusers/main/tr/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained) sonrasında [load_textual_inversion()](/docs/diffusers/main/tr/api/loaders/textual_inversion#diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion) ile yükleyin ve üretimi tetiklemek için benzersiz token'ı istem (prompt) içine ekleyin. | |
| ```py | |
| import torch | |
| from diffusers import AutoPipelineForText2Image | |
| pipeline = AutoPipelineForText2Image.from_pretrained( | |
| "stable-diffusion-v1-5/stable-diffusion-v1-5", | |
| dtype=torch.float16 | |
| ).to("cuda") # or "mps", "xpu", "cpu" | |
| ``` | |
| ```py | |
| pipeline.load_textual_inversion("sd-concepts-library/gta5-artwork") | |
| prompt = "A cute brown bear eating a slice of pizza, stunning color scheme, masterpiece, illustration, <gta5-artwork> style" | |
| pipeline(prompt).images[0] | |
| ``` | |
| Gömleleri eğitmek için [Metinsel ters çevirme eğitimi](../training/text_inversion) bölümüne bakın. | |
| Textual Inversion, "bulanık" veya "çirkin" gibi istenmeyen özelliklerden kaçınarak üretimi yönlendirmek için *negatif gömme* öğrenmeye de eğitilebilir; bu da onu görüntü kalitesini iyileştirmek için faydalı kılar. | |
| EasyNegative, çok sayıda öğrenilmiş negatif kavram içeren yaygın olarak kullanılan bir negatif gömmedir. Negatif gömmeleri yükleyin ve negatif gömmelerle ilişkili dosya adını ve belirteci belirtin. Etkinleştirmek için belirteci hattınızda `negative_prompt` parametresine iletin. | |
| ```py | |
| import torch | |
| from diffusers import AutoPipelineForText2Image | |
| pipeline = AutoPipelineForText2Image.from_pretrained( | |
| "stable-diffusion-v1-5/stable-diffusion-v1-5", | |
| dtype=torch.float16 | |
| ).to("cuda") # or "mps", "xpu", "cpu" | |
| pipeline.load_textual_inversion( | |
| "EvilEngine/easynegative", | |
| weight_name="easynegative.safetensors", | |
| token="easynegative" | |
| ) | |
| prompt = "A cute brown bear eating a slice of pizza, stunning color scheme, masterpiece, illustration" | |
| negative_prompt = "easynegative" | |
| pipeline(prompt, negative_prompt=negative_prompt).images[0] | |
| ``` | |
Xet Storage Details
- Size:
- 7.15 kB
- Xet hash:
- 8c227d5c0c0ca4916218735f78d7bcdd9f0db04a43084a05a01baf511a7a9af5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.