2022-08-21 23:57:48 +00:00
|
|
|
#!/usr/bin/env python3
|
2022-08-24 13:22:04 +00:00
|
|
|
# Copyright (c) 2022 Lincoln D. Stein (https://github.com/lstein)
|
2022-08-17 16:00:00 +00:00
|
|
|
# Before running stable-diffusion on an internet-isolated machine,
|
|
|
|
# run this script from one with internet connectivity. The
|
|
|
|
# two machines must share a common .cache directory.
|
2022-08-22 19:33:27 +00:00
|
|
|
import sys
|
|
|
|
import transformers
|
|
|
|
|
|
|
|
transformers.logging.set_verbosity_error()
|
2022-08-17 16:00:00 +00:00
|
|
|
|
|
|
|
# this will preload the Bert tokenizer fles
|
2022-08-17 22:06:30 +00:00
|
|
|
print("preloading bert tokenizer...")
|
2022-08-17 16:00:00 +00:00
|
|
|
from transformers import BertTokenizerFast
|
|
|
|
tokenizer = BertTokenizerFast.from_pretrained("bert-base-uncased")
|
|
|
|
print("...success")
|
|
|
|
|
|
|
|
# this will download requirements for Kornia
|
2022-08-22 19:33:27 +00:00
|
|
|
print("preloading Kornia requirements (ignore the warnings)...")
|
2022-08-17 16:00:00 +00:00
|
|
|
import kornia
|
|
|
|
print("...success")
|
|
|
|
|
2022-08-22 19:33:27 +00:00
|
|
|
# doesn't work - probably wrong logger
|
|
|
|
# logging.getLogger('transformers.tokenization_utils').setLevel(logging.ERROR)
|
|
|
|
version='openai/clip-vit-large-patch14'
|
|
|
|
|
|
|
|
print('preloading CLIP model (Ignore the warnings)...')
|
|
|
|
sys.stdout.flush()
|
|
|
|
import clip
|
|
|
|
from transformers import CLIPTokenizer, CLIPTextModel
|
|
|
|
tokenizer =CLIPTokenizer.from_pretrained(version)
|
|
|
|
transformer=CLIPTextModel.from_pretrained(version)
|
|
|
|
print('\n\n...success')
|
|
|
|
|
2022-08-24 13:22:04 +00:00
|
|
|
|