mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
further improvements to ability to find location of data files
- implement the following pattern for finding data files under both regular and editable install conditions: import invokeai.foo.bar as bar path = bar.__path__[0] - this *seems* to work reliably with Python 3.9. Testing on 3.10 needs to be performed.
This commit is contained in:
parent
ec1e83e912
commit
1c377b7995
@ -17,12 +17,13 @@ import cv2 as cv
|
|||||||
from einops import rearrange, repeat
|
from einops import rearrange, repeat
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pytorch_lightning import seed_everything
|
from pytorch_lightning import seed_everything
|
||||||
from invokeai import assets
|
import invokeai.assets.web as web_assets
|
||||||
from ldm.invoke.devices import choose_autocast
|
from ldm.invoke.devices import choose_autocast
|
||||||
from ldm.models.diffusion.cross_attention_map_saving import AttentionMapSaver
|
from ldm.models.diffusion.cross_attention_map_saving import AttentionMapSaver
|
||||||
from ldm.util import rand_perlin_2d
|
from ldm.util import rand_perlin_2d
|
||||||
|
|
||||||
downsampling = 8
|
downsampling = 8
|
||||||
|
CAUTION_IMG = 'caution.png'
|
||||||
|
|
||||||
class CkptGenerator():
|
class CkptGenerator():
|
||||||
def __init__(self, model, precision):
|
def __init__(self, model, precision):
|
||||||
@ -315,16 +316,7 @@ class CkptGenerator():
|
|||||||
path = None
|
path = None
|
||||||
if self.caution_img:
|
if self.caution_img:
|
||||||
return self.caution_img
|
return self.caution_img
|
||||||
path = None
|
path = Path(web_assets.__path__[0]) / CAUTION_IMG
|
||||||
for candidate in [
|
|
||||||
*assets.__path__,
|
|
||||||
Path(__file__).parent / '..' / '..' / '..' / 'invokeai' / 'assets'
|
|
||||||
]:
|
|
||||||
if Path(candidate,CAUTION_IMG).exists():
|
|
||||||
path = Path(candidate,CAUTION_IMG)
|
|
||||||
break
|
|
||||||
if not path:
|
|
||||||
return
|
|
||||||
caution = Image.open(path)
|
caution = Image.open(path)
|
||||||
self.caution_img = caution.resize((caution.width // 2, caution.height //2))
|
self.caution_img = caution.resize((caution.width // 2, caution.height //2))
|
||||||
return self.caution_img
|
return self.caution_img
|
||||||
|
@ -22,7 +22,7 @@ from urllib import request
|
|||||||
import requests
|
import requests
|
||||||
import transformers
|
import transformers
|
||||||
from diffusers import StableDiffusionPipeline, AutoencoderKL
|
from diffusers import StableDiffusionPipeline, AutoencoderKL
|
||||||
from invokeai import configs
|
import invokeai.configs as configs
|
||||||
from ldm.invoke.generator.diffusers_pipeline import StableDiffusionGeneratorPipeline
|
from ldm.invoke.generator.diffusers_pipeline import StableDiffusionGeneratorPipeline
|
||||||
from ldm.invoke.devices import choose_precision, choose_torch_device
|
from ldm.invoke.devices import choose_precision, choose_torch_device
|
||||||
from getpass_asterisk import getpass_asterisk
|
from getpass_asterisk import getpass_asterisk
|
||||||
@ -52,7 +52,7 @@ Model_dir = 'models'
|
|||||||
Weights_dir = 'ldm/stable-diffusion-v1/'
|
Weights_dir = 'ldm/stable-diffusion-v1/'
|
||||||
|
|
||||||
# the initial "configs" dir is now bundled in the `invokeai.configs` package
|
# the initial "configs" dir is now bundled in the `invokeai.configs` package
|
||||||
Dataset_path = Path(configs.__path__[-1]) / 'INITIAL_MODELS.yaml'
|
Dataset_path = Path(configs.__path__[0]) / 'INITIAL_MODELS.yaml'
|
||||||
|
|
||||||
Default_config_file = Path (global_config_dir()) / 'models.yaml'
|
Default_config_file = Path (global_config_dir()) / 'models.yaml'
|
||||||
SD_Configs = Path (global_config_dir()) / 'stable-diffusion'
|
SD_Configs = Path (global_config_dir()) / 'stable-diffusion'
|
||||||
|
@ -13,6 +13,7 @@ from contextlib import nullcontext
|
|||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from PIL import Image, ImageFilter, ImageChops
|
from PIL import Image, ImageFilter, ImageChops
|
||||||
from diffusers import DiffusionPipeline
|
from diffusers import DiffusionPipeline
|
||||||
from einops import rearrange
|
from einops import rearrange
|
||||||
@ -20,12 +21,12 @@ from pathlib import Path
|
|||||||
from pytorch_lightning import seed_everything
|
from pytorch_lightning import seed_everything
|
||||||
from tqdm import trange
|
from tqdm import trange
|
||||||
|
|
||||||
from invokeai import assets
|
import invokeai.assets.web as web_assets
|
||||||
from ldm.models.diffusion.ddpm import DiffusionWrapper
|
from ldm.models.diffusion.ddpm import DiffusionWrapper
|
||||||
from ldm.util import rand_perlin_2d
|
from ldm.util import rand_perlin_2d
|
||||||
|
|
||||||
downsampling = 8
|
downsampling = 8
|
||||||
CAUTION_IMG = 'web/caution.png'
|
CAUTION_IMG = 'caution.png'
|
||||||
|
|
||||||
class Generator:
|
class Generator:
|
||||||
downsampling_factor: int
|
downsampling_factor: int
|
||||||
@ -321,16 +322,8 @@ class Generator:
|
|||||||
path = None
|
path = None
|
||||||
if self.caution_img:
|
if self.caution_img:
|
||||||
return self.caution_img
|
return self.caution_img
|
||||||
path = None
|
path = Path(web_assets.__path__[0]) / CAUTION_IMG
|
||||||
for candidate in [
|
print(f'DEBUG: path to caution = {path}')
|
||||||
*assets.__path__,
|
|
||||||
Path(__file__).parent / '..' / '..' / '..' / 'invokeai' / 'assets'
|
|
||||||
]:
|
|
||||||
if Path(candidate,CAUTION_IMG).exists():
|
|
||||||
path = Path(candidate,CAUTION_IMG)
|
|
||||||
break
|
|
||||||
if not path:
|
|
||||||
return
|
|
||||||
caution = Image.open(path)
|
caution = Image.open(path)
|
||||||
self.caution_img = caution.resize((caution.width // 2, caution.height //2))
|
self.caution_img = caution.resize((caution.width // 2, caution.height //2))
|
||||||
return self.caution_img
|
return self.caution_img
|
||||||
|
Loading…
x
Reference in New Issue
Block a user