Skip to content

Commit

Permalink
Merge pull request #955 from Capsize-Games/devastator
Browse files Browse the repository at this point in the history
Devastator
  • Loading branch information
w4ffl35 authored Oct 24, 2024
2 parents b95c896 + 0bc5d51 commit 6aa38ab
Show file tree
Hide file tree
Showing 38 changed files with 219 additions and 223 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="airunner",
version="3.1.2",
version="3.1.3",
author="Capsize LLC",
description="A Stable Diffusion GUI",
long_description=open("README.md", "r", encoding="utf-8").read(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""Change image and mask columns to BLOB
Revision ID: 26a0d29a3af3
Revises: f403ff7468e8
Create Date: 2024-10-24 12:31:37.706170
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision: str = '26a0d29a3af3'
down_revision: Union[str, None] = 'f403ff7468e8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade():
try:
op.alter_column('controlnet_settings', 'image', type_=sa.LargeBinary, existing_type=sa.String, nullable=True)
op.alter_column('controlnet_settings', 'generated_image', type_=sa.LargeBinary, existing_type=sa.String, nullable=True)
except sa.exc.OperationalError:
pass

try:
op.alter_column('image_to_image_settings', 'image', type_=sa.LargeBinary, existing_type=sa.String, nullable=True)
except sa.exc.OperationalError:
pass

try:
op.alter_column('outpaint_settings', 'image', type_=sa.LargeBinary, existing_type=sa.String, nullable=True)
except sa.exc.OperationalError:
pass

try:
op.alter_column('drawing_pad_settings', 'image', type_=sa.LargeBinary, existing_type=sa.String, nullable=True)
op.alter_column('drawing_pad_settings', 'mask', type_=sa.LargeBinary, existing_type=sa.String, nullable=True)
except sa.exc.OperationalError:
pass


def downgrade():
try:
op.alter_column('controlnet_settings', 'image', type_=sa.String, existing_type=sa.LargeBinary, nullable=True)
op.alter_column('controlnet_settings', 'generated_image', type_=sa.String, existing_type=sa.LargeBinary, nullable=True)
except sa.exc.OperationalError:
pass

try:
op.alter_column('image_to_image_settings', 'image', type_=sa.String, existing_type=sa.LargeBinary, nullable=True)
except sa.exc.OperationalError:
pass

try:
op.alter_column('outpaint_settings', 'image', type_=sa.String, existing_type=sa.LargeBinary, nullable=True)
except sa.exc.OperationalError:
pass

try:
op.alter_column('drawing_pad_settings', 'image', type_=sa.String, existing_type=sa.LargeBinary, nullable=True)
op.alter_column('drawing_pad_settings', 'mask', type_=sa.String, existing_type=sa.LargeBinary, nullable=True)
except sa.exc.OperationalError:
pass
1 change: 0 additions & 1 deletion src/airunner/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(
to easily access the application settings dictionary.
"""
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)
super(App, self).__init__()

self.register(SignalCode.LOG_LOGGED_SIGNAL, self.on_log_logged_signal)
Expand Down
1 change: 0 additions & 1 deletion src/airunner/app_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(
to easily access the application settings dictionary.
"""
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)
super(AppInstaller, self).__init__()

self.start()
Expand Down
12 changes: 6 additions & 6 deletions src/airunner/data/models/settings_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class ActiveGridSettings(Base):
class ControlnetSettings(Base):
__tablename__ = 'controlnet_settings'
id = Column(Integer, primary_key=True, autoincrement=True)
image = Column(String, nullable=True)
generated_image = Column(String, nullable=True)
image = Column(LargeBinary, nullable=True)
generated_image = Column(LargeBinary, nullable=True)
enabled = Column(Boolean, default=False)
use_grid_image_as_input = Column(Boolean, default=False)
strength = Column(Integer, default=50)
Expand All @@ -97,7 +97,7 @@ class ControlnetSettings(Base):
class ImageToImageSettings(Base):
__tablename__ = 'image_to_image_settings'
id = Column(Integer, primary_key=True, autoincrement=True)
image = Column(String, nullable=True)
image = Column(LargeBinary, nullable=True)
enabled = Column(Boolean, default=False)
use_grid_image_as_input = Column(Boolean, default=False)
lock_input_image = Column(Boolean, default=False)
Expand All @@ -106,7 +106,7 @@ class ImageToImageSettings(Base):
class OutpaintSettings(Base):
__tablename__ = 'outpaint_settings'
id = Column(Integer, primary_key=True, autoincrement=True)
image = Column(String, nullable=True)
image = Column(LargeBinary, nullable=True)
enabled = Column(Boolean, default=True)
strength = Column(Integer, default=50)
mask_blur = Column(Integer, default=0)
Expand All @@ -115,8 +115,8 @@ class OutpaintSettings(Base):
class DrawingPadSettings(Base):
__tablename__ = 'drawing_pad_settings'
id = Column(Integer, primary_key=True, autoincrement=True)
image = Column(String, nullable=True)
mask = Column(String, nullable=True)
image = Column(LargeBinary, nullable=True)
mask = Column(LargeBinary, nullable=True)
enabled = Column(Boolean, default=True)
enable_automatic_drawing = Column(Boolean, default=False)
mask_layer_enabled = Column(Boolean, default=False)
Expand Down
5 changes: 2 additions & 3 deletions src/airunner/filters/base_filter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from PIL import ImageFilter

from airunner.handlers.logger import Logger
from airunner.windows.main.settings_mixin import SettingsMixin


class BaseFilter(ImageFilter.Filter):
class BaseFilter(ImageFilter.Filter, SettingsMixin):
def __init__(self, **kwargs):
super().__init__()
self.logger = Logger(prefix=self.__class__.__name__)
self.image = None
self.image_id = None

Expand Down
2 changes: 1 addition & 1 deletion src/airunner/handlers/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, *args, **kwargs):
self._model_status = {model_type: ModelStatus.UNLOADED for model_type in ModelType}
self.use_gpu = True
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)

super().__init__(*args, **kwargs)
self._requested_action:ModelAction = ModelAction.NONE

Expand Down
2 changes: 1 addition & 1 deletion src/airunner/handlers/llm/agent/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BaseAgent(
):
def __init__(self, *args, **kwargs):
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)

self.model = kwargs.pop("model", None)
self.__documents = None
self.__document_reader: SimpleDirectoryReader = None
Expand Down
9 changes: 5 additions & 4 deletions src/airunner/handlers/llm/huggingface_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
StoppingCriteriaList,
)

from airunner.windows.main.settings_mixin import SettingsMixin

DEFAULT_HUGGINGFACE_MODEL = "StabilityAI/stablelm-tuned-alpha-3b"

logger = logging.getLogger(__name__)

class HuggingFaceLLM(CustomLLM):
class HuggingFaceLLM(CustomLLM, SettingsMixin):
r"""HuggingFace LLM.
Examples:
Expand Down Expand Up @@ -217,7 +218,7 @@ def __init__(
config_dict.get("max_position_embeddings", context_window)
)
if model_context_window and model_context_window < context_window:
logger.warning(
self.logger.warning(
f"Supplied context_window {context_window} is greater "
f"than the model's max input size {model_context_window}. "
"Disable this warning by setting a lower context_window."
Expand All @@ -231,7 +232,7 @@ def __init__(
)

if tokenizer.name_or_path != model_name:
logger.warning(
self.logger.warning(
f"The model `{model_name}` and tokenizer `{tokenizer.name_or_path}` "
f"are different, please ensure that they are compatible."
)
Expand Down
78 changes: 0 additions & 78 deletions src/airunner/handlers/logger.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
import time
import requests
from PySide6.QtCore import QObject, Signal
from airunner.handlers.logger import Logger
from airunner.enums import SignalCode
from airunner.mediator_mixin import MediatorMixin
from airunner.windows.main.settings_mixin import SettingsMixin

logger = Logger(prefix="DownloadWorker")


class CivitAIDownloadWorker(
QObject,
Expand All @@ -25,7 +22,7 @@ class CivitAIDownloadWorker(

def __init__(self, *args, **kwargs):
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)

super(CivitAIDownloadWorker, self).__init__(*args, **kwargs)

def add_to_queue(self, data: tuple):
Expand Down
8 changes: 3 additions & 5 deletions src/airunner/handlers/stablediffusion/download_civitai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
import requests
from json.decoder import JSONDecodeError
from PySide6.QtCore import QThread
from airunner.handlers.logger import Logger
from airunner.handlers.stablediffusion.civit_ai_download_worker import CivitAIDownloadWorker
from airunner.enums import SignalCode
from airunner.mediator_mixin import MediatorMixin
from airunner.windows.main.settings_mixin import SettingsMixin

logger = Logger(prefix="DownloadCivitAI")

class DownloadCivitAI(
MediatorMixin,
SettingsMixin
):
def __init__(self):
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)

super().__init__()
self.thread = None
self.worker = None
Expand All @@ -31,7 +29,7 @@ def get_json(self, model_id: str):
"Content-Type": "application/json",
#"Authorization": f"Bearer {api_token}"
}
logger.debug(f"Getting model data from CivitAI {url}")
print(f"Getting model data from CivitAI {url}")
response = requests.get(url, headers=headers, allow_redirects=True)
json = None
try:
Expand All @@ -54,7 +52,7 @@ def download_model(self, url, file_name, size_kb, callback):
self.worker.finished.connect(lambda: self.emit_signal(SignalCode.DOWNLOAD_COMPLETE))
self.worker.finished.connect(self.thread.quit)
self.worker.progress.connect(lambda current, total: callback(current, total))
logger.debug(f"Starting model download thread")
print(f"Starting model download thread")
self.worker.finished.connect(self.worker.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
self.thread.started.connect(self.worker.download)
Expand Down
3 changes: 0 additions & 3 deletions src/airunner/handlers/stablediffusion/download_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import time
import requests
from PySide6.QtCore import QObject, Signal
from airunner.handlers.logger import Logger
from airunner.enums import SignalCode
from airunner.mediator_mixin import MediatorMixin
from facehuggershield.huggingface.settings import DEFAULT_HF_ENDPOINT
from airunner.windows.main.settings_mixin import SettingsMixin

logger = Logger(prefix="DownloadWorker")


class DownloadWorker(
Expand All @@ -26,7 +24,6 @@ class DownloadWorker(

def __init__(self, *args, **kwargs):
MediatorMixin.__init__(self)
SettingsMixin.__init__(self)
super(DownloadWorker, self).__init__(*args, **kwargs)

def add_to_queue(self, data: tuple):
Expand Down
Loading

0 comments on commit 6aa38ab

Please sign in to comment.