Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offloads heavy functions to threads, prevents application from freezi… #360

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/airunner/aihandler/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,17 +970,28 @@ def call_pipe(self, **kwargs):
try:
args.update({
"prompt_embeds": self.prompt_embeds,
"negative_prompt_embeds": self.negative_prompt_embeds,
})
except Exception as _e:
Logger.warning("Compel failed: " + str(_e))
args.update({
"prompt": self.prompt,
"negative_prompt": self.negative_prompt,
})
else:
args.update({
"prompt": self.prompt,
})
if self.use_compel:
try:
args.update({
"negative_prompt_embeds": self.negative_prompt_embeds,
})
except Exception as _e:
Logger.warning("Compel failed: " + str(_e))
args.update({
"negative_prompt": self.negative_prompt,
})
else:
args.update({
"negative_prompt": self.negative_prompt,
})
args["callback_steps"] = 1
Expand Down
12 changes: 6 additions & 6 deletions src/airunner/aihandler/settings_manager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from PyQt6.QtCore import QObject, pyqtSignal

from airunner.aihandler.qtvar import StringVar, IntVar, BooleanVar, FloatVar, DictVar
from airunner.data.db import session
from airunner.data.models import LLMGenerator, Settings, GeneratorSetting, AIModel, Pipeline, ControlnetModel, ImageFilter, Prompt, \
SavedPrompt, PromptCategory, PromptVariable, PromptVariableCategory, PromptVariableCategoryWeight, StandardImageWidgetSettings
from airunner.utils import save_session
from airunner.data.models import LLMGenerator, Settings, GeneratorSetting, AIModel, Pipeline, ControlnetModel, ImageFilter, \
SavedPrompt, StandardImageWidgetSettings
from airunner.utils import save_session, get_session
from airunner.aihandler.logger import Logger as logger
from airunner.data.models import Document

document = None
_app = None
Expand All @@ -17,6 +17,7 @@
"FLOAT": FloatVar,
"JSON": DictVar,
}
session = get_session()


class SettingsSignal(QObject):
Expand Down Expand Up @@ -236,8 +237,7 @@ def __init__(self, app=None, *args, **kwargs):
_app = app
document = _app.document
else:
from airunner.data.db import session
from airunner.data.models import Document
session = get_session()
document = session.query(Document).first()

super().__init__(*args, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion src/airunner/aihandler/transformer_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from airunner.aihandler.settings_manager import SettingsManager
from airunner.data.models import LLMGenerator
from airunner.data.db import session
from airunner.utils import get_session
from airunner.aihandler.logger import Logger


Expand Down Expand Up @@ -66,6 +66,7 @@ class TransformerRunner(QObject):
@property
def generator(self):
try:
session = get_session()
if not self._generator or self.current_generator_name != self.requested_generator_name:
self.current_generator_name = self.requested_generator_name
self._generator = session.query(LLMGenerator).filter_by(name=self.current_generator_name).first()
Expand Down
Loading