国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors

這篇具有很好參考價值的文章主要介紹了diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

先自我介紹一下,小編浙江大學畢業(yè),去過華為、字節(jié)跳動等大廠,目前阿里P7

深知大多數(shù)程序員,想要提升技能,往往是自己摸索成長,但自己不成體系的自學效果低效又漫長,而且極易碰到天花板技術停滯不前!

因此收集整理了一份《2024年最新大數(shù)據(jù)全套學習資料》,初衷也很簡單,就是希望能夠幫助到想自學提升又不知道該從何學起的朋友。
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言

既有適合小白學習的零基礎資料,也有適合3年以上經(jīng)驗的小伙伴深入學習提升的進階課程,涵蓋了95%以上大數(shù)據(jù)知識點,真正體系化!

由于文件比較多,這里只是將部分目錄截圖出來,全套包含大廠面經(jīng)、學習筆記、源碼講義、實戰(zhàn)項目、大綱路線、講解視頻,并且后續(xù)會持續(xù)更新

如果你需要這些資料,可以添加V獲?。簐ip204888 (備注大數(shù)據(jù))
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言

正文


也可以使用特定的pipeline



from diffusers import StableDiffusionPipeline

repo_id = “runwayml/stable-diffusion-v1-5”
pipe = StableDiffusionPipeline.from_pretrained(repo_id, use_safetensors=True)


Community pipelines是原始實現(xiàn)不同于DiffusionPipeline,例如StableDiffusionControlNetPipeline.


**1.1 local pipeline**



from diffusers import DiffusionPipeline

repo_id = “./stable-diffusion-v1-5” # local path
stable_diffusion = DiffusionPipeline.from_pretrained(repo_id, use_safetensors=True)


from\_pretrained()方法在檢測到本地路徑時不會下載。


**1.2 swap components in a pipeline**


可以使用另一個兼容的組件來自定義任何流程的默認組件。定制非常重要,因為:


1. 更改調(diào)度器對于探索生成速度和質(zhì)量之間的權衡是重要的。
2. 模型的不同組件通常是獨立訓練的,您可以用性能更好的組件替換掉現(xiàn)有組件。
3. 在微調(diào)過程中,通常只有一些組件(如UNet或文本編碼器)進行訓練。



from diffusers import DiffusionPipeline

repo_id = “runwayml/stable-diffusion-v1-5”
stable_diffusion = DiffusionPipeline.from_pretrained(repo_id, use_safetensors=True)
stable_diffusion.scheduler.compatibles



from diffusers import DiffusionPipeline, EulerDiscreteScheduler, DPMSolverMultistepScheduler

repo_id = “runwayml/stable-diffusion-v1-5”
scheduler = EulerDiscreteScheduler.from_pretrained(repo_id, subfolder=“scheduler”)
stable_diffusion = DiffusionPipeline.from_pretrained(repo_id, scheduler=scheduler, use_safetensors=True)


可以將PNDMScheduler更換為EulerDiscreteScheduler,在回傳到DiffusionPipeline中。


**1.3 safety checker**


safety checker可以根據(jù)已知的NSFW內(nèi)容檢查生成的輸出,?



from diffusers import DiffusionPipeline

repo_id = “runwayml/stable-diffusion-v1-5”
stable_diffusion = DiffusionPipeline.from_pretrained(repo_id, safety_checker=None, use_safetensors=True)


**1.4 reuse components across pipelines**


可以在多個pipeline中可以重復使用相同的組件,以避免將權重加載到RAM中2次



from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline

model_id = “runwayml/stable-diffusion-v1-5”
stable_diffusion_txt2img = StableDiffusionPipeline.from_pretrained(model_id, use_safetensors=True)

components = stable_diffusion_txt2img.components


可以將components傳遞到另一個pipeline中,無需將權重重新加載到RAM中:



stable_diffusion_img2img = StableDiffusionImg2ImgPipeline(**components)


下面的方式更加靈活:



from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline

model_id = “runwayml/stable-diffusion-v1-5”
stable_diffusion_txt2img = StableDiffusionPipeline.from_pretrained(model_id, use_safetensors=True)
stable_diffusion_img2img = StableDiffusionImg2ImgPipeline(
vae=stable_diffusion_txt2img.vae,
text_encoder=stable_diffusion_txt2img.text_encoder,
tokenizer=stable_diffusion_txt2img.tokenizer,
unet=stable_diffusion_txt2img.unet,
scheduler=stable_diffusion_txt2img.scheduler,
safety_checker=None,
feature_extractor=None,
requires_safety_checker=False,
)


**1.5 checkpoint variants**


以torch.float16保存,節(jié)省一半的內(nèi)存,但是無法訓練,EMA不用于推理,用于微調(diào)模型。


**2. models**



from diffusers import UNet2DConditionModel

repo_id = “runwayml/stable-diffusion-v1-5”
model = UNet2DConditionModel.from_pretrained(repo_id, subfolder=“unet”, use_safetensors=True)


所有的權重都存儲在一個safetensors中, 可以用.from\_single\_file()來加載模型。safetensors安全且加載速度快。


**2.1 load different stable diffusion formats**


.ckpt也可以用from\_single\_file(),但最好轉成hf格式,可以使用diffusers官方提供的服務轉:[https://huggingface.co/spaces/diffusers/sd-to-diffusers]( )


也可以使用腳本轉:[https://github.com/huggingface/diffusers/blob/main/scripts/convert\_original\_stable\_diffusion\_to\_diffusers.py]( )



python …/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py --checkpoint_path temporalnetv3.ckpt --original_config_file cldm_v15.yaml --dump_path ./ --controlnet


?A1111 Lora文件,diffusers可以使用[load\_lora\_weights()]( )")加載lora模型:



from diffusers import DiffusionPipeline, UniPCMultistepScheduler
import torch

pipeline = DiffusionPipeline.from_pretrained(
“andite/anything-v4.0”, torch_dtype=torch.float16, safety_checker=None
).to(“cuda”)
pipeline.scheduler = UniPCMultistepScheduler.from_config(pipeline.scheduler.config)

uncomment to download the safetensor weights

#!wget https://civitai.com/api/download/models/19998 -O howls_moving_castle.safetensors

pipeline.load_lora_weights(“.”, weight_name=“howls_moving_castle.safetensors”)

prompt = “masterpiece, illustration, ultra-detailed, cityscape, san francisco, golden gate bridge, california, bay area, in the snow, beautiful detailed starry sky”
negative_prompt = “l(fā)owres, cropped, worst quality, low quality, normal quality, artifacts, signature, watermark, username, blurry, more than one bridge, bad architecture”

images = pipeline(
prompt=prompt,
negative_prompt=negative_prompt,
width=512,
height=512,
num_inference_steps=25,
num_images_per_prompt=4,
generator=torch.manual_seed(0),
).images

from diffusers.utils import make_image_grid

make_image_grid(images, 2, 2)


**3.scheduler**


scheduler沒有參數(shù)化或訓練;由配置文件定義。加載scheduler不會消耗大的內(nèi)存,并且相同的配置文件可以用于各種不同的scheduler,比如下面的scheduler均可與StableDiffusionPipline兼容。


Diffusion流程本質(zhì)上是由擴散模型和scheduler組成的集合,它們在一定程度上彼此獨立。這意味著可以替換流程的某些部分,其中最好的例子就是scheduler。擴散模型通常只定義從噪聲到較少噪聲樣本的前向傳遞過程,而調(diào)度器定義了整個去噪過程,包括:


去噪步驟是多少?隨機的還是確定性的?用什么算法找到去噪樣本? 調(diào)度器可以非常復雜,并且經(jīng)常在去噪速度和去噪質(zhì)量之間進行權衡。



from diffusers import StableDiffusionPipeline
from diffusers import (
DDPMScheduler,
DDIMScheduler,
PNDMScheduler,

網(wǎng)上學習資料一大堆,但如果學到的知識不成體系,遇到問題時只是淺嘗輒止,不再深入研究,那么很難做到真正的技術提升。

需要這份系統(tǒng)化的資料的朋友,可以添加V獲?。簐ip204888 (備注大數(shù)據(jù))
diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors,2024年程序員學習,java,開發(fā)語言

一個人可以走的很快,但一群人才能走的更遠!不論你是正從事IT行業(yè)的老鳥或是對IT行業(yè)感興趣的新人,都歡迎加入我們的的圈子(技術交流、學習資源、職場吐槽、大廠內(nèi)推、面試輔導),讓我們一起學習成長!文章來源地址http://www.zghlxwxcb.cn/news/detail-859917.html

知識不成體系,遇到問題時只是淺嘗輒止,不再深入研究,那么很難做到真正的技術提升。**

需要這份系統(tǒng)化的資料的朋友,可以添加V獲?。簐ip204888 (備注大數(shù)據(jù))
[外鏈圖片轉存中…(img-P82PmwJ4-1713279392977)]

一個人可以走的很快,但一群人才能走的更遠!不論你是正從事IT行業(yè)的老鳥或是對IT行業(yè)感興趣的新人,都歡迎加入我們的的圈子(技術交流、學習資源、職場吐槽、大廠內(nèi)推、面試輔導),讓我們一起學習成長!

到了這里,關于diffusers-Load pipelines,models,and schedulers_diffusers 加載safetensors的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 運行StableDiffusionInpaintPipeline的Example時報錯:OSError: Cannot load model runwayml/stable-diffusion-...

    項目地址: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/inpaint https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/inpaint 在云服務器端運行下面給出的Example的時候出現(xiàn)報錯: 原因是:國內(nèi)無法服務器無法直接連接上huggingface。 解決辦法是:開代理把模型下載到本地再

    2024年03月09日
    瀏覽(24)
  • 2 Data Streaming Pipelines With Flink and Kafka

    作者:禪與計算機程序設計藝術 數(shù)據(jù)流是一個連續(xù)不斷的、產(chǎn)生、存儲和處理數(shù)據(jù)的過程。傳統(tǒng)上,數(shù)據(jù)流編程都是基于特定平臺(比如:消息隊列,數(shù)據(jù)倉庫,事件溯源)的SDK或者API進行開發(fā),但隨著云計算和容器技術的發(fā)展,越來越多的企業(yè)選擇使用開源工具實現(xiàn)自己的

    2024年02月08日
    瀏覽(47)
  • Streamlining Your Data Pipeline with Databricks and Apache Flink

    大數(shù)據(jù)技術在過去的幾年里發(fā)展迅速,成為了企業(yè)和組織中不可或缺的一部分。隨著數(shù)據(jù)的規(guī)模和復雜性的增加,傳統(tǒng)的數(shù)據(jù)處理技術已經(jīng)無法滿足需求。為了解決這個問題,我們需要一種更高效、可擴展的數(shù)據(jù)處理框架。 Databricks 和 Apache Flink 是兩個非常受歡迎的開源項目

    2024年02月22日
    瀏覽(19)
  • Stable Diffusion with  Diffusers 學習筆記: 原理+完整pipeline代碼

    Stable Diffusion with Diffusers 學習筆記: 原理+完整pipeline代碼

    參考鏈接: https://huggingface.co/blog/stable_diffusion#how-does-stable-diffusion-work 在這篇文章中,我們想展示如何使用Stable Diffusion with the ?? Diffusers library,,解釋模型是如何工作的,最后深入探討擴散器是如何允許自定義圖像生成pipeline的。 如果你對擴散模型完全陌生,我們建議你閱讀

    2024年02月05日
    瀏覽(50)
  • 擴散模型Diffusers Pipeline API使用介紹

    大部分擴散模型包含多個獨立訓練的子模型和組件模塊組合而成,例如StableDiffusion 有: 3個獨立訓練的子模型:Autoencoder、 Conditional Unet、CLIP text encoder 調(diào)度器組件scheduler, CLIPImageProcessor, safety checker. 為了讓開發(fā)者以最簡單的方式使用最新最先進的擴散模型, diffusers 開發(fā)了

    2024年02月08日
    瀏覽(20)
  • Hugging Face使用Stable diffusion Diffusers Transformers Accelerate Pipelines VAE

    Hugging Face使用Stable diffusion Diffusers Transformers Accelerate Pipelines VAE

    A library that offers an implementation of various diffusion models, including text-to-image models. 提供不同擴散模型的實現(xiàn)的庫,代碼上最簡潔,國內(nèi)的問題是?huggingface 需要翻墻。 A Hugging Face library that provides pre-trained deep learning models for natural language processing tasks. 提供了預訓練深度學習模型,

    2024年02月07日
    瀏覽(49)
  • docker load and build過程的一些步驟理解

    “docker load” command, the following steps are followed to load an image from a specified tar file to the local image repository: Parsing the tar file: Docker first parses the tar file to check its integrity and verify the format. Extracting the files: If the parsing is successful, Docker will extract the layers of the image and its metadata to a local t

    2024年02月07日
    瀏覽(21)
  • 論文筆記:RAG VS FINE-TUNING: PIPELINES, TRADEOFFS, AND A CASESTUDY ON AGRICULTURE

    論文筆記:RAG VS FINE-TUNING: PIPELINES, TRADEOFFS, AND A CASESTUDY ON AGRICULTURE

    微軟24年1月的paper AI在如農(nóng)業(yè)等特定領域的應用仍然有限,這是由于缺乏專門的訓練數(shù)據(jù) 雖然AI已被用來從農(nóng)業(yè)的衛(wèi)星圖像和傳感器數(shù)據(jù)中派生見解,但技術在農(nóng)民中的采用仍然緩慢 盡管GPT-4和Bing是尋找信息的強大工具,但它們可能不會為有關其作物和家畜的非常具體問題的

    2024年04月09日
    瀏覽(21)
  • ModuleNotFoundError: No module named ‘models‘解決torch.load問題【天坑】

    ModuleNotFoundError: No module named ‘models‘解決torch.load問題【天坑】

    當使用torch.load時,報錯No module named ‘models’ 在網(wǎng)上查了很多資料說目錄結構得和保存時一模一樣,話雖如此,但一直沒理解要如何一樣 最后調(diào)試發(fā)現(xiàn),No module named \\\'models’報錯說沒有models,確實是因為沒有. 比如下面: 我訓練的用torch.save(model, checkpoint_path)保存的模型文件,那

    2024年02月14日
    瀏覽(23)
  • ARM匯編【3】:LOAD/STORE MULTIPLE PUSH AND POP

    ? ? ? 有時一次加載(或存儲)多個值更有效。為此,我們使用LDM(加載多個)和STM(存儲多個)。這些指令有一些變化,基本上只在訪問初始地址的方式上有所不同。這是我們將在本節(jié)中使用的代碼。我們將一步一步地研究每一條指令。 ? ? ? ? 在開始之前,請記住.字指

    2024年02月11日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包