From 1379642fc66ef74e7049dc687c50fc04211293a1 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 1 Nov 2022 14:34:23 -0400 Subject: [PATCH] fix library problems in preload_modules --- scripts/preload_models.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/preload_models.py b/scripts/preload_models.py index 3d42178b63..6909e05703 100644 --- a/scripts/preload_models.py +++ b/scripts/preload_models.py @@ -6,6 +6,7 @@ # # Coauthor: Kevin Turner http://github.com/keturn # +print('Loading Python libraries...\n') import argparse import sys import os @@ -17,6 +18,10 @@ from pathlib import Path import traceback import getpass import requests +import clip +import transformers +import torch +transformers.logging.set_verbosity_error() import warnings warnings.filterwarnings('ignore') @@ -26,12 +31,7 @@ warnings.filterwarnings('ignore') # deferred loading so that help message can be printed quickly def load_libs(): - print('Loading Python libraries...\n') - import clip - import transformers - import torch - import zipfile - transformers.logging.set_verbosity_error() + pass #--------------------------globals-- Model_dir = './models/ldm/stable-diffusion-v1/' @@ -489,12 +489,14 @@ def download_codeformer(): #--------------------------------------------- def download_clipseg(): print('Installing clipseg model for text-based masking...',end='') + import zipfile try: model_url = 'https://owncloud.gwdg.de/index.php/s/ioHbRzFx6th32hn/download' model_dest = 'src/clipseg/clipseg_weights.zip' weights_dir = 'src/clipseg/weights' if not os.path.exists(weights_dir): os.makedirs(os.path.dirname(model_dest), exist_ok=True) + if not os.path.exists('src/clipseg/weights/rd64-uni-refined.pth'): request.urlretrieve(model_url,model_dest) with zipfile.ZipFile(model_dest,'r') as zip: zip.extractall('src/clipseg')