国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁(yè) > news >正文

海淀區(qū)企業(yè)網(wǎng)站建設(shè)公司網(wǎng)站設(shè)計(jì)制作

海淀區(qū)企業(yè)網(wǎng)站建設(shè),公司網(wǎng)站設(shè)計(jì)制作,湖北網(wǎng)站建設(shè)軟件有哪些,做教育機(jī)構(gòu)的設(shè)計(jì)哪些網(wǎng)站好Hugging Face, EleutherAI, StabilityAI 用的多 介紹 文件形式 header,體現(xiàn)其特性。如果強(qiáng)行將pickle或者空軟連接 打開(kāi),會(huì)出現(xiàn)報(bào)錯(cuò)。解決詳見(jiàn):debug 連接到其他教程結(jié)構(gòu)和參數(shù) 安裝 with pip:Copied pip install safetensors with con…

Hugging Face, EleutherAI, StabilityAI 用的多

介紹

文件形式

  • header,體現(xiàn)其特性。如果強(qiáng)行將pickle或者空軟連接 打開(kāi),會(huì)出現(xiàn)報(bào)錯(cuò)。解決詳見(jiàn):debug 連接到其他教程
  • 結(jié)構(gòu)和參數(shù)
    數(shù)據(jù)結(jié)構(gòu)

安裝

with pip:Copied
pip install safetensors
with conda:Copied
conda install -c huggingface safetensors

Usage

文檔: https://huggingface.co/docs/safetensors/index
github: https://github.com/huggingface/safetensors

測(cè)試安裝

import torch
from safetensors import safe_open
from safetensors.torch import save_filetensors = {"weight1": torch.zeros((1024, 1024)),"weight2": torch.zeros((1024, 1024))
}
save_file(tensors, "model.safetensors")tensors = {}
with safe_open("model.safetensors", framework="pt", device="cpu") as f:for key in f.keys():tensors[key] = f.get_tensor(key)

加載

文檔 https://huggingface.co/docs/diffusers/using-diffusers/using_safetensors

from diffusers import StableDiffusionPipelinepipeline = StableDiffusionPipeline.from_single_file("https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
)

Load tensors


from safetensors import safe_opentensors = {}
with safe_open("model.safetensors", framework="pt", device=0) as f:for k in f.keys():tensors[k] = f.get_tensor(k)
# Loading only part of the tensors (interesting when running on multiple GPU)from safetensors import safe_opentensors = {}
with safe_open("model.safetensors", framework="pt", device=0) as f:tensor_slice = f.get_slice("embedding")vocab_size, hidden_dim = tensor_slice.get_shape()tensor = tensor_slice[:, :hidden_dim]

保存


import torch
from safetensors.torch import save_filetensors = {"embedding": torch.zeros((2, 2)),"attention": torch.zeros((2, 3))
}
save_file(tensors, "model.safetensors")

轉(zhuǎn)換到safetensor

  • 在線,利用hugging face

The easiest way to convert your model weights is to use the Convert Space, given your model weights are already stored on the Hub. The Convert Space downloads the pickled weights, converts them, and opens a Pull Request to upload the newly converted .safetensors file to your repository.

  • 本地 運(yùn)行
    see 轉(zhuǎn)換代碼 convert.py
# 主函數(shù)
def convert_file(pt_filename: str,sf_filename: str,
):loaded = torch.load(pt_filename, map_location="cpu")if "state_dict" in loaded:loaded = loaded["state_dict"]shared = shared_pointers(loaded)for shared_weights in shared:for name in shared_weights[1:]:loaded.pop(name)# For tensors to be contiguousloaded = {k: v.contiguous() for k, v in loaded.items()}dirname = os.path.dirname(sf_filename)os.makedirs(dirname, exist_ok=True)save_file(loaded, sf_filename, metadata={"format": "pt"})check_file_size(sf_filename, pt_filename)reloaded = load_file(sf_filename)for k in loaded:pt_tensor = loaded[k]sf_tensor = reloaded[k]if not torch.equal(pt_tensor, sf_tensor):raise RuntimeError(f"The output tensors do not match for key {k}")

例子

解析

import requests # pip install requests
import structdef parse_single_file(url):# Fetch the first 8 bytes of the fileheaders = {'Range': 'bytes=0-7'}response = requests.get(url, headers=headers)# Interpret the bytes as a little-endian unsigned 64-bit integerlength_of_header = struct.unpack('<Q', response.content)[0]# Fetch length_of_header bytes starting from the 9th byteheaders = {'Range': f'bytes=8-{7 + length_of_header}'}response = requests.get(url, headers=headers)# Interpret the response as a JSON objectheader = response.json()return headerurl = "https://huggingface.co/gpt2/resolve/main/model.safetensors"
header = parse_single_file(url)print(header)
http://aloenet.com.cn/news/46726.html

相關(guān)文章:

  • 北京 順義 網(wǎng)站制作培訓(xùn)網(wǎng)站制作
  • 自制圖片肇慶網(wǎng)站快速排名優(yōu)化
  • wordpress映射新余seo
  • 視頻解析接口網(wǎng)站怎么做百度提交網(wǎng)站
  • 怎么自己做三個(gè)一網(wǎng)站一份完整的營(yíng)銷(xiāo)策劃書(shū)
  • 做農(nóng)產(chǎn)品的網(wǎng)站北京優(yōu)化seo排名優(yōu)化
  • 國(guó)外銷(xiāo)售網(wǎng)站怎樣建設(shè)免費(fèi)長(zhǎng)尾詞挖掘工具
  • 麗水專(zhuān)業(yè)網(wǎng)站建設(shè)哪家好抖音seo優(yōu)化
  • wordpress.conf網(wǎng)站seo優(yōu)化免費(fèi)
  • 有沒(méi)有給做淘寶網(wǎng)站的中國(guó)十大網(wǎng)站有哪些
  • 做網(wǎng)站需要什么部門(mén)批準(zhǔn)重慶seo優(yōu)化效果好
  • 濟(jì)寧做企業(yè)網(wǎng)站濟(jì)南網(wǎng)站優(yōu)化排名推廣
  • 在哪里做網(wǎng)站比較好十大廣告投放平臺(tái)
  • 做平臺(tái)和獨(dú)立建網(wǎng)站綜合型b2b電子商務(wù)平臺(tái)網(wǎng)站
  • 免費(fèi)的素材網(wǎng)站網(wǎng)站如何做關(guān)鍵詞優(yōu)化
  • 個(gè)人網(wǎng)站發(fā)布怎么做優(yōu)化大師官網(wǎng)入口
  • 網(wǎng)站建設(shè)總體方案設(shè)計(jì)下載優(yōu)化大師app
  • web前端工程師職業(yè)規(guī)劃seo推廣優(yōu)化的方法
  • 公司網(wǎng)站建設(shè)有什么好處2345網(wǎng)址導(dǎo)航下載
  • 網(wǎng)站建設(shè)的公司在哪找企業(yè)推廣策略
  • 做網(wǎng)站犯法嗎小廣告圖片
  • 類(lèi)似網(wǎng)站的建設(shè)西安seo網(wǎng)絡(luò)優(yōu)化公司
  • 網(wǎng)站建設(shè)個(gè)人網(wǎng)站佛山網(wǎng)絡(luò)推廣哪里好
  • 網(wǎng)站備案信息傳網(wǎng)店推廣聯(lián)盟
  • wordpress 小工具 調(diào)用seo是什么崗位
  • 山東日照建設(shè)網(wǎng)站微信小程序怎么開(kāi)通
  • 做藥材生意的網(wǎng)站免費(fèi)下載百度app最新版本
  • 濟(jì)南網(wǎng)絡(luò)廣播電視臺(tái)北京關(guān)鍵詞優(yōu)化報(bào)價(jià)
  • 域名服務(wù)器的四種類(lèi)型營(yíng)口seo
  • 網(wǎng)站建設(shè)需要哪些方面愛(ài)站網(wǎng)權(quán)重查詢(xún)