Update Script

#1
by minefarts - opened

This model works so well for me that I made this python script to automatically download the latest version. I thought I should share it in case anyone else wants to use it.

#----------------------------------------------------------
# CONFIGURATION:
output = 'image.safetensors' # Path for model to download to
temp_dir = 'C:/temp' # Path for temporary files
token = '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' # huggingface.co api token
#----------------------------------------------------------

from urllib.request import urlretrieve
from huggingface_hub import HfFileSystem, login
from pathlib import Path

print("Logging in to 'huggingface.co'")

login(token)

print('Scanning files in repository')

files = []
for file in HfFileSystem().ls("cyberdelia/CyberRealisticPony"):
    if file['name'].startswith('cyberdelia/CyberRealisticPony/CyberRealisticPony_V'):
        files.append(file['name'].split('/')[-1])

url = f'https://huggingface.co/cyberdelia/CyberRealisticPony/resolve/main/{sorted(files)[-1]}?download=true'

print(f'Downloading model to "{Path(output).absolute().as_posix()}"')

urlretrieve(url, output)

print('Download Complete')

Sign up or log in to comment