diff options
author | Tiago F. Santos <tiagofsantos81@sapo.pt> | 2022-11-24 13:04:45 +0000 |
---|---|---|
committer | Tiago F. Santos <tiagofsantos81@sapo.pt> | 2022-11-24 13:04:45 +0000 |
commit | a2ae5a655518b150a34b95d7afecc87a43280406 (patch) | |
tree | 1e8fb2d16c26c09ddd974133e0afd84a9b0dfb82 /modules | |
parent | 745f1e8f8008ea4906b0f5eb8b8f71d205fedf9e (diff) | |
download | stable-diffusion-webui-gfx803-a2ae5a655518b150a34b95d7afecc87a43280406.tar.gz stable-diffusion-webui-gfx803-a2ae5a655518b150a34b95d7afecc87a43280406.tar.bz2 stable-diffusion-webui-gfx803-a2ae5a655518b150a34b95d7afecc87a43280406.zip |
[interrogator] mkdir check
Diffstat (limited to 'modules')
-rw-r--r-- | modules/interrogate.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules/interrogate.py b/modules/interrogate.py index 1a9c758e..f177a5a8 100644 --- a/modules/interrogate.py +++ b/modules/interrogate.py @@ -14,7 +14,8 @@ import modules.shared as shared from modules import devices, paths, lowvram
blip_image_eval_size = 384
-blip_model_local = os.path.join('models', 'Interrogator', 'BLIP_model.pth')
+blip_local_dir = os.path.join('models', 'Interrogator')
+blip_local_file = os.path.join(blip_local_dir, 'model_base_caption_capfilt_large.pth')
blip_model_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_base_caption_capfilt_large.pth'
clip_model_name = 'ViT-L/14'
@@ -48,13 +49,16 @@ class InterrogateModels: def load_blip_model(self):
import models.blip
- if not os.path.isfile(blip_model_local):
+ if not os.path.isfile(blip_local_file):
+ if not os.path.isdir(blip_local_dir):
+ os.mkdir(blip_local_dir)
+
print("Downloading BLIP...")
- import requests as req
- open(blip_model_local, 'wb').write(req.get(blip_model_url, allow_redirects=True).content)
- print("BLIP downloaded to", blip_model_local + '.')
+ from requests import get as reqget
+ open(blip_local_file, 'wb').write(reqget(blip_model_url, allow_redirects=True).content)
+ print("BLIP downloaded to", blip_local_file + '.')
- blip_model = models.blip.blip_decoder(pretrained=blip_model_local, image_size=blip_image_eval_size, vit='base', med_config=os.path.join(paths.paths["BLIP"], "configs", "med_config.json"))
+ blip_model = models.blip.blip_decoder(pretrained=blip_local_file, image_size=blip_image_eval_size, vit='base', med_config=os.path.join(paths.paths["BLIP"], "configs", "med_config.json"))
blip_model.eval()
return blip_model
|