Skip to content

Commit

Permalink
refactor: update model and code organization
Browse files Browse the repository at this point in the history
- Update Fluxlyptus model to newer version
- Reorganize imports in multiple files
- Remove unnecessary blank lines
- Improve code formatting and consistency
  • Loading branch information
rtuszik committed Aug 23, 2024
1 parent fcf166d commit 008510d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
QVBoxLayout,
QWidget,
)

from utils import ImageGeneratorThread, ImageLoader, TokenCounter


Expand Down
6 changes: 4 additions & 2 deletions src/image_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

load_dotenv()


class ImageGenerator:
def __init__(self):
self.model = "rtuszik/fluxlyptus:4e304b52ad6745623fb29f3250d89df23ac38b42734887d9e0a4b3a31c648472"
self.model = "rtuszik/fluxlyptus:b23b9b488de7af95eba09786ef3156d345d979024712f54b3e5a32d61f14e568"

def generate_images(self, params):
try:
Expand All @@ -14,5 +15,6 @@ def generate_images(self, params):
except Exception as e:
raise ImageGenerationError(f"Error generating images: {str(e)}")


class ImageGenerationError(Exception):
pass
pass
3 changes: 1 addition & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from PyQt6.QtWidgets import QApplication

from gui import ImageGeneratorGUI
from image_generator import ImageGenerator
from PyQt6.QtWidgets import QApplication


def main():
Expand Down
10 changes: 8 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
from PyQt6.QtCore import QRunnable, QThread, pyqtSignal, QObject
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel

from PyQt6.QtCore import QObject, QRunnable, QThread, pyqtSignal
from PyQt6.QtWidgets import QLabel, QVBoxLayout, QWidget


class ImageLoaderSignals(QObject):
finished = pyqtSignal(list)


class ImageLoader(QRunnable):
def __init__(self, folder_path):
super().__init__()
Expand All @@ -21,6 +24,7 @@ def run(self):
images.sort(key=lambda x: x[1], reverse=True)
self.signals.finished.emit([img[0] for img in images])


class ImageGeneratorThread(QThread):
finished = pyqtSignal(list)
error = pyqtSignal(str)
Expand All @@ -37,6 +41,7 @@ def run(self):
except Exception as e:
self.error.emit(str(e))


class TokenCount:
def __init__(self, model_name):
self.model_name = model_name
Expand All @@ -45,6 +50,7 @@ def num_tokens_from_string(self, string: str) -> int:
# This is a simplified implementation. You might want to use a proper tokenizer here.
return len(string.split())


class TokenCounter(QWidget):
def __init__(self, text_edit, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit 008510d

Please sign in to comment.