Files
Athena-Deck/deploy/import_qwen_native.py
T

24 lines
1.7 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')]
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);a=p.parse_args();ids=[]
for name,expected in 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()