import argparse import datetime import os import shutil import sys from urllib import request as ulreq from bs4 import BeautifulSoup import requests from huggingface_hub import HfApi from PIL import ImageFile parser = argparse.ArgumentParser() parser.add_argument('out_file', nargs='?', help='file to save to', default='stable-diffusion-textual-inversion-models.html') args = parser.parse_args() print('Will save to file:', args.out_file) # Init some stuff before saving the time api = HfApi() models_list = [] # Save the time now before we do the hard work dt = datetime.datetime.now() tz = dt.astimezone().tzname() # Get list of models under the sd-concepts-library organization for model in api.list_models(author="sd-concepts-library"): models_list.append(model.modelId.replace('sd-concepts-library/', '')) models_list.sort() html_struct = f"""
Page updates automatically daily. Last updated {datetime.datetime.now().strftime("%A %B %d, %Y")}.
Browser for the HuggingFace textual inversion library. There are currently {len(models_list)} textual inversion models in sd-concepts-library.
Models are downloaded straight from the HuggingFace repositories. The images displayed are the inputs, not the outputs. Want to quickly test concepts? Try the Stable Diffusion Conceptualizer on HuggingFace.More info on textual inversion.
{model_name} is restricted and you must share your contact information to view this repository. View Repository
""" else: html_struct = html_struct + f"""