Skip to content

Commit

Permalink
quench torch 2.0.0 deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Lincoln Stein authored and hipsterusername committed May 17, 2023
1 parent 31a65b1 commit 060ea14
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
23 changes: 15 additions & 8 deletions ldm/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
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
Expand Down Expand Up @@ -979,13 +984,15 @@ def set_model(self, model_name):
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()))}'
)
Expand Down
1 change: 0 additions & 1 deletion ldm/invoke/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import Union

import click

from compel import PromptParser

if sys.platform == "darwin":
Expand Down
8 changes: 5 additions & 3 deletions ldm/modules/textual_inversion_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
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 get_hf_concepts_lib


@dataclass
class TextualInversion:
trigger_string: str
Expand Down

0 comments on commit 060ea14

Please sign in to comment.