-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from Integration-Automation/dev
Update dev and stable version
- Loading branch information
Showing
19 changed files
with
135 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
frontengine/show/image_generation/image_generation_show.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from PySide6.QtGui import QPixmap | ||
from PySide6.QtWidgets import QWidget, QLabel, QGridLayout | ||
|
||
|
||
class ImageGenerateShow(QWidget): | ||
|
||
def __init__(self, pixmap: QPixmap): | ||
super().__init__() | ||
self.label = QLabel() | ||
self.label.setPixmap(pixmap) | ||
self.grid_layout = QGridLayout(self) | ||
self.grid_layout.setContentsMargins(0, 0, 0, 0) | ||
self.grid_layout.addWidget(self.label) | ||
self.setLayout(self.grid_layout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
32 changes: 32 additions & 0 deletions
32
frontengine/ui/setting/image_generation/generation_image_thread.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import asyncio | ||
from queue import Queue | ||
from threading import Thread | ||
from re_edge_gpt import ImageGenAsync | ||
|
||
|
||
class ImageGenThread(Thread): | ||
|
||
def __init__(self, image_keyword: str): | ||
super().__init__() | ||
auth_cooker = open("bing_cookies.txt", "r+").read() | ||
self.async_gen = ImageGenAsync(auth_cookie=auth_cooker) | ||
self.image_keyword = image_keyword | ||
|
||
def run(self) -> None: | ||
try: | ||
image_list = list() | ||
|
||
async def send_chat_async(): | ||
nonlocal image_list | ||
image_list = await self.async_gen.get_images(self.image_keyword) | ||
|
||
asyncio.run(send_chat_async()) | ||
for image in image_list: | ||
IMAGE_QUEUE.put_nowait(image) | ||
except Exception as error: | ||
EXCEPTION_QUEUE.put_nowait(repr(error)) | ||
raise error | ||
|
||
|
||
IMAGE_QUEUE = Queue() | ||
EXCEPTION_QUEUE = Queue() |
62 changes: 62 additions & 0 deletions
62
frontengine/ui/setting/image_generation/image_generation_input.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from typing import List | ||
|
||
import requests | ||
from PySide6.QtCore import QTimer | ||
from PySide6.QtGui import QPixmap | ||
from PySide6.QtWidgets import QWidget, QPushButton, QLineEdit, QGridLayout, QMessageBox, QPlainTextEdit | ||
|
||
from frontengine.show.image_generation.image_generation_show import ImageGenerateShow | ||
from frontengine.ui.setting.image_generation.generation_image_thread import ImageGenThread, IMAGE_QUEUE | ||
from frontengine.utils.multi_language.language_wrapper import language_wrapper | ||
|
||
|
||
class ImageGenerationUI(QWidget): | ||
def __init__(self): | ||
super().__init__() | ||
# UI | ||
self.image_keyword_input = QLineEdit() | ||
self.send_text_button = QPushButton() | ||
self.send_text_button.setText(language_wrapper.language_word_dict.get("start_generate_image")) | ||
self.image_panel = QPlainTextEdit() | ||
self.image_panel.setReadOnly(True) | ||
self.send_text_button.clicked.connect(self.generate_image) | ||
# Layout | ||
self.grid_layout = QGridLayout(self) | ||
self.grid_layout.setContentsMargins(0, 0, 0, 0) | ||
self.grid_layout.addWidget(self.image_keyword_input, 0, 0) | ||
self.grid_layout.addWidget(self.send_text_button, 0, 1) | ||
self.grid_layout.addWidget(self.image_panel, 1, 0, -1, -1) | ||
# Pull image timer | ||
self.pull_image_timer = QTimer() | ||
self.pull_image_timer.setInterval(1000) | ||
self.pull_image_timer.timeout.connect(self.get_image) | ||
self.pull_image_timer.start() | ||
# Manage show | ||
self.show_list: List[QWidget] = list() | ||
|
||
def generate_image(self): | ||
if self.image_keyword_input.text() == "" or self.image_keyword_input.text().isspace(): | ||
input_error_message = QMessageBox(self) | ||
input_error_message.setText(language_wrapper.language_word_dict.get("input_error")) | ||
input_error_message.show() | ||
else: | ||
image_thread = ImageGenThread(self.image_keyword_input.text()) | ||
image_thread.daemon = True | ||
image_thread.start() | ||
|
||
def get_image(self): | ||
if not IMAGE_QUEUE.empty(): | ||
image_link = IMAGE_QUEUE.get_nowait() | ||
image_response = requests.get(image_link) | ||
image = QPixmap() | ||
image.loadFromData(image_response.content) | ||
image_show = ImageGenerateShow(image) | ||
self.show_list.append(image_show) | ||
image_show.show() | ||
self.image_panel.appendPlainText(image_link) | ||
|
||
def close(self) -> bool: | ||
for widget in self.show_list: | ||
widget.close() | ||
return super().close() | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters