25 lines
1.9 KiB
Python
25 lines
1.9 KiB
Python
"""Import checksum-verified native Qwen public weights; never edits profiles/keys."""
|
|
import argparse,hashlib,json,shutil,time
|
|
from pathlib import Path
|
|
|
|
REPO='Serveurperso/Qwen3-TTS-GGUF'
|
|
REVISION='b7ee2e8c7459c3bea99da23e3d178125a7d1713c'
|
|
FILES=[('qwen-talker-0.6b-base-Q8_0.gguf','d54dbaf10591421fa764ed630d764efa717ae40cd959bd48c66d4eb1af226426'),('qwen-tokenizer-12hz-Q8_0.gguf','1883beeed99348fc35e23dd225e9082f93f6f8c109330a33d935baa8acdbfd94')]
|
|
Q4_FILE=('qwen-talker-0.6b-base-Q4_K_M.gguf','4b468ec7b1f62b90ef4ca316c0aa57deadfd54b2cf9651703ea753cedaf04226')
|
|
def digest(path):
|
|
with path.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
|
|
def main():
|
|
p=argparse.ArgumentParser();p.add_argument('--state',required=True,type=Path);p.add_argument('--cache',required=True,type=Path);p.add_argument('--quant',choices=['Q8','Q4'],default='Q8');a=p.parse_args();ids=[]
|
|
for name,expected in ([Q4_FILE,FILES[1]] if a.quant=='Q4' else FILES):
|
|
source=a.cache/('models--'+REPO.replace('/','--'))/'snapshots'/REVISION/name
|
|
if digest(source)!=expected:raise ValueError('Qwen-Datei hat unerwartete SHA256.')
|
|
ident=hashlib.sha256((REPO+REVISION+name).encode()).hexdigest();target=a.state/'models'/ident;target.mkdir(parents=True,exist_ok=True,mode=0o700)
|
|
dest=target/'model.gguf'
|
|
if not dest.exists():
|
|
temp=target/'import.tmp';shutil.copyfile(source,temp);temp.chmod(0o600);temp.replace(dest)
|
|
if digest(dest)!=expected:raise ValueError('Vorhandene Bibliotheksdatei weicht ab; nicht überschrieben.')
|
|
entry=dict(repo=REPO,revision=REVISION,file=name,size=dest.stat().st_size,sha256=expected,upstream_hash_verified=True,kind='audio',downloaded_at=time.time(),state='downloaded',runtime_ready=True)
|
|
temp=target/'entry.tmp';temp.write_text(json.dumps(entry));temp.chmod(0o600);temp.replace(target/'entry.json');ids.append(ident)
|
|
print(json.dumps(dict(model_id=ids[0],codec_id=ids[1])))
|
|
if __name__=='__main__':main()
|