Compare commits

...

11 Commits

Author SHA1 Message Date
Lincoln Stein
53f5dfbce1 quench fp16 revision not found error 2023-05-16 23:45:14 -04:00
Lincoln Stein
060ea144a1 quench torch 2.0.0 deprecation warning 2023-05-16 23:45:14 -04:00
Lincoln Stein
31a65b1e5d bump compel version 2023-05-16 23:45:14 -04:00
Lincoln Stein
bdc75be33f 1. update installer torch version
2. bump version to 2.3.5.post1
2023-05-16 23:45:14 -04:00
Lincoln Stein
628d307c69 1. Update the following dependencies
- torch 2.0.0
- xformers 0.0.19
- compel 1.1.3

2. Fix LoRA documentation so that it shows up in mkdocs.
2023-05-16 23:45:14 -04:00
Lincoln Stein
18f0cbd9a7 Turn the HuggingFaceConceptsLib into a singleton to prevent redundant connections (#3337)
This is a partial fix for #3330 . It prevents the concepts library from
hitting HuggingFace to download concept library terms every time a model
is changed.

It does not address the issue that the web interface downloads the
concepts even if it is not going to use them.
2023-05-10 00:00:04 -04:00
Lincoln Stein
d83d69ccc1 Merge branch 'v2.3' into lstein/bugfix/concept-lib-singleton 2023-05-09 23:38:41 -04:00
Lincoln Stein
332ac72e0e [Bugfix] Update check failing because process disappears (#3334)
Fixes #3228, where the check to see if invokeai is running fails because
a process no longer exists.
2023-05-04 20:32:51 -04:00
Lincoln Stein
fa886ee9e0 turn the HuggingFaceConceptsLib into a singleton to prevent redundant downloads 2023-05-03 15:12:34 -04:00
Dan Nguyen
03bbb308c9 [Bugfix] Update check failing because process disappears
Fixes #3228, where the check to see if invokeai is running fails because
a process no longer exists.
2023-05-03 10:54:43 -05:00
Lincoln Stein
1dcac3929b Release v2.3.5 (#3309)
# Version 2.3.5
This will be the 2.3.5 release once it is merged into the `v2.3` branch.
Changes on the RC branch are:

- Bump version number
- Fix bug in LoRA path determination (do it at runtime, not at module
load time, or root will get confused); closes #3293.
- Remove dangling debug statement.
2023-05-01 12:40:47 -04:00
17 changed files with 69 additions and 33 deletions

View File

@@ -41,6 +41,16 @@ Windows systems). If the `loras` folder does not already exist, just
create it. The vast majority of LoRA models use the Kohya file format,
which is a type of `.safetensors` file.
!!! warning "LoRA Naming Restrictions"
InvokeAI will only recognize LoRA files that contain the
characters a-z, A-Z, 0-9 and the underscore character
_. Other characters, including the hyphen, will cause the
LoRA file not to load. These naming restrictions may be
relaxed in the future, but for now you will need to rename
files that contain hyphens, commas, brackets, and other
non-word characters.
You may change where InvokeAI looks for the `loras` folder by passing the
`--lora_directory` option to the `invoke.sh`/`invoke.bat` launcher, or
by placing the option in `invokeai.init`. For example:

View File

@@ -33,6 +33,11 @@ title: Overview
Restore mangled faces and make images larger with upscaling. Also see
the [Embiggen Upscaling Guide](EMBIGGEN.md).
- The [Using LoRA Models](LORAS.md)
Add custom subjects and styles using HuggingFace's repository of
embeddings.
- The [Concepts Library](CONCEPTS.md)
Add custom subjects and styles using HuggingFace's repository of

View File

@@ -79,7 +79,7 @@ title: Manual Installation, Linux
and obtaining an access token for downloading. It will then download and
install the weights files for you.
Please look [here](../INSTALL_MANUAL.md) for a manual process for doing
Please look [here](../020_INSTALL_MANUAL.md) for a manual process for doing
the same thing.
7. Start generating images!

View File

@@ -75,7 +75,7 @@ Note that you will need NVIDIA drivers, Python 3.10, and Git installed beforehan
obtaining an access token for downloading. It will then download and install the
weights files for you.
Please look [here](../INSTALL_MANUAL.md) for a manual process for doing the
Please look [here](../020_INSTALL_MANUAL.md) for a manual process for doing the
same thing.
8. Start generating images!

View File

@@ -0,0 +1,5 @@
mkdocs
mkdocs-material>=8, <9
mkdocs-git-revision-date-localized-plugin
mkdocs-redirects==1.2.0

View File

@@ -243,16 +243,15 @@ class InvokeAiInstance:
# Note that we're installing pinned versions of torch and
# torchvision here, which *should* correspond to what is
# in pyproject.toml. This is to prevent torch 2.0 from
# being installed and immediately uninstalled and replaced with 1.13
# in pyproject.toml.
pip = local[self.pip]
(
pip[
"install",
"--require-virtualenv",
"torch~=1.13.1",
"torchvision~=0.14.1",
"torch~=2.0.0",
"torchvision>=0.14.1",
"--force-reinstall",
"--find-links" if find_links is not None else None,
find_links,

View File

@@ -25,7 +25,7 @@ from invokeai.backend.modules.parameters import parameters_to_command
import invokeai.frontend.dist as frontend
from ldm.generate import Generate
from ldm.invoke.args import Args, APP_ID, APP_VERSION, calculate_init_img_hash
from ldm.invoke.concepts_lib import HuggingFaceConceptsLibrary
from ldm.invoke.concepts_lib import get_hf_concepts_lib
from ldm.invoke.conditioning import (
get_tokens_for_prompt_object,
get_prompt_structure,
@@ -538,7 +538,7 @@ class InvokeAIWebServer:
try:
local_triggers = self.generate.model.textual_inversion_manager.get_all_trigger_strings()
locals = [{'name': x} for x in sorted(local_triggers, key=str.casefold)]
concepts = HuggingFaceConceptsLibrary().list_concepts(minimum_likes=5)
concepts = get_hf_concepts_lib().list_concepts(minimum_likes=5)
concepts = [{'name': f'<{x}>'} for x in sorted(concepts, key=str.casefold) if f'<{x}>' not in local_triggers]
socketio.emit("foundTextualInversionTriggers", {'local_triggers': locals, 'huggingface_concepts': concepts})
except Exception as e:

View File

@@ -13,11 +13,16 @@ import time
import traceback
from typing import List
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
import torch
import cv2
import diffusers
import numpy as np
import skimage
import torch
import transformers
from diffusers.pipeline_utils import DiffusionPipeline
from diffusers.utils.import_utils import is_xformers_available
@@ -979,13 +984,15 @@ class Generate:
seed_everything(random.randrange(0, np.iinfo(np.uint32).max))
if self.embedding_path and not model_data.get("ti_embeddings_loaded"):
print(f'>> Loading embeddings from {self.embedding_path}')
for root, _, files in os.walk(self.embedding_path):
for name in files:
ti_path = os.path.join(root, name)
self.model.textual_inversion_manager.load_textual_inversion(
ti_path, defer_injecting_tokens=True
)
model_data["ti_embeddings_loaded"] = True
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
for root, _, files in os.walk(self.embedding_path):
for name in files:
ti_path = os.path.join(root, name)
self.model.textual_inversion_manager.load_textual_inversion(
ti_path, defer_injecting_tokens=True
)
model_data["ti_embeddings_loaded"] = True
print(
f'>> Textual inversion triggers: {", ".join(sorted(self.model.textual_inversion_manager.get_all_trigger_strings()))}'
)

View File

@@ -9,7 +9,6 @@ from pathlib import Path
from typing import Union
import click
from compel import PromptParser
if sys.platform == "darwin":

View File

@@ -1 +1,2 @@
__version__='2.3.5'
__version__='2.3.5.post1'

View File

@@ -12,6 +12,14 @@ from urllib import request, error as ul_error
from huggingface_hub import HfFolder, hf_hub_url, ModelSearchArguments, ModelFilter, HfApi
from ldm.invoke.globals import Globals
singleton = None
def get_hf_concepts_lib():
global singleton
if singleton is None:
singleton = HuggingFaceConceptsLibrary()
return singleton
class HuggingFaceConceptsLibrary(object):
def __init__(self, root=None):
'''

View File

@@ -39,7 +39,7 @@ def invokeai_is_running()->bool:
if matches:
print(f':exclamation: [bold red]An InvokeAI instance appears to be running as process {p.pid}[/red bold]')
return True
except psutil.AccessDenied:
except (psutil.AccessDenied,psutil.NoSuchProcess):
continue
return False

View File

@@ -433,7 +433,7 @@ class ModelManager(object):
**fp_args,
)
except OSError as e:
if str(e).startswith("fp16 is not a valid"):
if 'Revision Not Found' in str(e):
pass
else:
print(

View File

@@ -13,7 +13,7 @@ import re
import atexit
from typing import List
from ldm.invoke.args import Args
from ldm.invoke.concepts_lib import HuggingFaceConceptsLibrary
from ldm.invoke.concepts_lib import get_hf_concepts_lib
from ldm.invoke.globals import Globals
from ldm.modules.lora_manager import LoraManager
@@ -287,7 +287,7 @@ class Completer(object):
def _concept_completions(self, text, state):
if self.concepts is None:
# cache Concepts() instance so we can check for updates in concepts_list during runtime.
self.concepts = HuggingFaceConceptsLibrary()
self.concepts = get_hf_concepts_lib()
self.embedding_terms.update(set(self.concepts.list_concepts()))
else:
self.embedding_terms.update(set(self.concepts.list_concepts()))

View File

@@ -6,7 +6,7 @@ from torch import nn
import sys
from ldm.invoke.concepts_lib import HuggingFaceConceptsLibrary
from ldm.invoke.concepts_lib import get_hf_concepts_lib
from ldm.data.personalized import per_img_token_list
from transformers import CLIPTokenizer
from functools import partial
@@ -39,7 +39,7 @@ class EmbeddingManager(nn.Module):
super().__init__()
self.embedder = embedder
self.concepts_library=HuggingFaceConceptsLibrary()
self.concepts_library=get_hf_concepts_lib()
self.string_to_token_dict = {}
self.string_to_param_dict = nn.ParameterDict()

View File

@@ -3,14 +3,16 @@ from dataclasses import dataclass
from pathlib import Path
from typing import Optional, Union
import safetensors.torch
import torch
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
import safetensors.torch
import torch
from picklescan.scanner import scan_file_path
from transformers import CLIPTextModel, CLIPTokenizer
from compel.embeddings_provider import BaseTextualInversionManager
from ldm.invoke.concepts_lib import HuggingFaceConceptsLibrary
from ldm.invoke.concepts_lib import get_hf_concepts_lib
@dataclass
class TextualInversion:
@@ -34,7 +36,7 @@ class TextualInversionManager(BaseTextualInversionManager):
self.tokenizer = tokenizer
self.text_encoder = text_encoder
self.full_precision = full_precision
self.hf_concepts_library = HuggingFaceConceptsLibrary()
self.hf_concepts_library = get_hf_concepts_lib()
self.trigger_to_sourcefile = dict()
default_textual_inversions: list[TextualInversion] = []
self.textual_inversions = default_textual_inversions

View File

@@ -32,9 +32,9 @@ dependencies = [
"albumentations",
"click",
"clip_anytorch",
"compel~=1.1.0",
"compel~=1.1.5",
"datasets",
"diffusers[torch]~=0.15.0",
"diffusers[torch]~=0.16.1",
"dnspython==2.2.1",
"einops",
"eventlet",
@@ -76,7 +76,7 @@ dependencies = [
"taming-transformers-rom1504",
"test-tube>=0.7.5",
"torch-fidelity",
"torch~=1.13.1",
"torch~=2.0.0",
"torchmetrics",
"torchvision>=0.14.1",
"transformers~=4.26",
@@ -108,7 +108,7 @@ requires-python = ">=3.9, <3.11"
"test" = ["pytest-cov", "pytest>6.0.0"]
"xformers" = [
"triton; sys_platform=='linux'",
"xformers~=0.0.16; sys_platform!='darwin'",
"xformers~=0.0.19; sys_platform!='darwin'",
]
[project.scripts]