Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
2a649154
Unverified
Commit
2a649154
authored
Dec 03, 2022
by
AUTOMATIC1111
Committed by
GitHub
Dec 03, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4956 from TiagoSantos81/offline_BLIP
[CLIP interrogator] use local file, if available
parents
0d21624c
a2ae5a65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
interrogate.py
modules/interrogate.py
+12
-1
No files found.
modules/interrogate.py
View file @
2a649154
...
@@ -14,6 +14,8 @@ import modules.shared as shared
...
@@ -14,6 +14,8 @@ import modules.shared as shared
from
modules
import
devices
,
paths
,
lowvram
from
modules
import
devices
,
paths
,
lowvram
blip_image_eval_size
=
384
blip_image_eval_size
=
384
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'
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'
clip_model_name
=
'ViT-L/14'
...
@@ -47,7 +49,16 @@ class InterrogateModels:
...
@@ -47,7 +49,16 @@ class InterrogateModels:
def
load_blip_model
(
self
):
def
load_blip_model
(
self
):
import
models.blip
import
models.blip
blip_model
=
models
.
blip
.
blip_decoder
(
pretrained
=
blip_model_url
,
image_size
=
blip_image_eval_size
,
vit
=
'base'
,
med_config
=
os
.
path
.
join
(
paths
.
paths
[
"BLIP"
],
"configs"
,
"med_config.json"
))
if
not
os
.
path
.
isfile
(
blip_local_file
):
if
not
os
.
path
.
isdir
(
blip_local_dir
):
os
.
mkdir
(
blip_local_dir
)
print
(
"Downloading BLIP..."
)
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_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
()
blip_model
.
eval
()
return
blip_model
return
blip_model
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment