Добавлено окно негативных промптов с категориями и автоматическим переводом
This commit is contained in:
1 parent
657d8b5ec1
commit
ec5b85573c
3 files changed
+372
-17
No files matched your search
@@ -17,6 +17,7 @@ from modules.console_window import ConsoleWindow
|
||||
from modules.model_manager import ModelManager
|
||||
from modules.sampler_manager import SamplerManager
|
||||
from modules.prompt_window import PromptWindow
|
||||
from modules.negative_prompt_window import NegativePromptWindow
|
||||
|
||||
class GenerationThread(QThread):
|
||||
progress_updated = pyqtSignal(float, str)
|
||||
@@ -64,6 +65,7 @@ class MainWindow(QMainWindow):
|
||||
self.api_url = "http://localhost:7860" # URL по умолчанию
|
||||
self.console_window = None
|
||||
self.prompt_window = None
|
||||
self.negative_prompt_window = None
|
||||
self.progress_timer = None
|
||||
self.init_ui()
|
||||
|
||||
@@ -164,29 +166,32 @@ class MainWindow(QMainWindow):
|
||||
settings_layout.addLayout(api_layout)
|
||||
|
||||
# Промпт
|
||||
prompt_label = QLabel("Промпт:")
|
||||
self.prompt_input = QTextEdit()
|
||||
self.prompt_input.setPlaceholderText("Введите описание изображения...")
|
||||
prompt_layout = QVBoxLayout()
|
||||
prompt_header = QHBoxLayout()
|
||||
prompt_header.addWidget(prompt_label)
|
||||
|
||||
# Добавляем кнопку промптов рядом с полем промпта
|
||||
prompt_label = QLabel("Промпт:")
|
||||
self.prompt_input = QTextEdit()
|
||||
self.prompt_input.setMinimumHeight(100)
|
||||
prompt_buttons = QHBoxLayout()
|
||||
self.prompt_button = QPushButton("Готовые промпты")
|
||||
self.prompt_button.clicked.connect(self.toggle_prompt_window)
|
||||
prompt_header.addWidget(self.prompt_button)
|
||||
prompt_header.addStretch()
|
||||
|
||||
self.negative_prompt_button = QPushButton("Негативные промпты")
|
||||
self.negative_prompt_button.clicked.connect(self.toggle_negative_prompt_window)
|
||||
prompt_buttons.addWidget(self.prompt_button)
|
||||
prompt_buttons.addWidget(self.negative_prompt_button)
|
||||
prompt_header.addWidget(prompt_label)
|
||||
prompt_header.addLayout(prompt_buttons)
|
||||
prompt_layout.addLayout(prompt_header)
|
||||
prompt_layout.addWidget(self.prompt_input)
|
||||
settings_layout.addLayout(prompt_layout)
|
||||
|
||||
# Негативный промпт
|
||||
neg_prompt_label = QLabel("Негативный промпт:")
|
||||
self.neg_prompt_input = QTextEdit()
|
||||
self.neg_prompt_input.setPlaceholderText("Введите нежелательные элементы...")
|
||||
settings_layout.addWidget(neg_prompt_label)
|
||||
settings_layout.addWidget(self.neg_prompt_input)
|
||||
negative_prompt_layout = QVBoxLayout()
|
||||
negative_prompt_label = QLabel("Негативный промпт:")
|
||||
self.negative_prompt_input = QTextEdit()
|
||||
self.negative_prompt_input.setMinimumHeight(100)
|
||||
negative_prompt_layout.addWidget(negative_prompt_label)
|
||||
negative_prompt_layout.addWidget(self.negative_prompt_input)
|
||||
settings_layout.addLayout(negative_prompt_layout)
|
||||
|
||||
# Добавляем менеджер моделей
|
||||
self.model_manager = ModelManager(self.api_url)
|
||||
@@ -316,12 +321,28 @@ class MainWindow(QMainWindow):
|
||||
else:
|
||||
self.prompt_window.close()
|
||||
|
||||
def add_prompt(self, prompt):
|
||||
def toggle_negative_prompt_window(self):
|
||||
"""Открыть/закрыть окно с негативными промптами"""
|
||||
if self.negative_prompt_window is None:
|
||||
self.negative_prompt_window = NegativePromptWindow(parent=self)
|
||||
self.negative_prompt_window.prompt_selected.connect(self.add_negative_prompt)
|
||||
self.negative_prompt_window.show()
|
||||
else:
|
||||
self.negative_prompt_window.close()
|
||||
|
||||
def add_prompt(self, text):
|
||||
"""Добавить промпт в поле ввода"""
|
||||
current_text = self.prompt_input.toPlainText()
|
||||
if current_text:
|
||||
current_text += ", "
|
||||
self.prompt_input.setText(current_text + prompt)
|
||||
self.prompt_input.setText(current_text + text)
|
||||
|
||||
def add_negative_prompt(self, text):
|
||||
"""Добавить негативный промпт в поле ввода"""
|
||||
current_text = self.negative_prompt_input.toPlainText()
|
||||
if current_text:
|
||||
current_text += ", "
|
||||
self.negative_prompt_input.setText(current_text + text)
|
||||
|
||||
def start_generation(self):
|
||||
self.generate_button.setEnabled(False)
|
||||
@@ -329,7 +350,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
params = {
|
||||
"prompt": self.prompt_input.toPlainText(),
|
||||
"negative_prompt": self.neg_prompt_input.toPlainText(),
|
||||
"negative_prompt": self.negative_prompt_input.toPlainText(),
|
||||
"width": self.width_input.value(),
|
||||
"height": self.height_input.value(),
|
||||
"seed": self.seed_input.value(),
|
||||
|
||||
Reference in new issue
Block a user