mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
🔧 chore(ui): refactor imports and remove unused code in __init__.py and gradio_ui.py
🔥 chore(ui): remove unused launcher.py file
The imports in __init__.py and gradio_ui.py have been refactored to remove the unused import statements. The launcher.py file has been removed as it is no longer needed. This improves code cleanliness and reduces unnecessary clutter.
This commit is contained in:
@@ -1,2 +1 @@
|
|||||||
from .gradio_ui import GenerateUI
|
from .gradio_ui import GenerateUI, launch
|
||||||
from .launcher import launch
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import orjson
|
import orjson
|
||||||
import sys
|
import sys
|
||||||
@@ -6,12 +5,14 @@ import sys
|
|||||||
from src.engines import ENGINES, BaseEngine
|
from src.engines import ENGINES, BaseEngine
|
||||||
from src.chore import GenerationContext
|
from src.chore import GenerationContext
|
||||||
|
|
||||||
|
|
||||||
class GenerateUI:
|
class GenerateUI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.css = """.generate_button {
|
self.css = """.generate_button {
|
||||||
font-size: 5rem !important
|
font-size: 5rem !important
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_presets(self):
|
def get_presets(self):
|
||||||
with open("local/presets.json", "r") as f:
|
with open("local/presets.json", "r") as f:
|
||||||
return orjson.loads(f.read())
|
return orjson.loads(f.read())
|
||||||
@@ -35,8 +36,8 @@ class GenerateUI:
|
|||||||
return ui
|
return ui
|
||||||
|
|
||||||
def launch_ui(self):
|
def launch_ui(self):
|
||||||
self.ui = self.get_ui()
|
ui = self.get_ui()
|
||||||
self.ui.launch()
|
ui.launch()
|
||||||
|
|
||||||
def get_interfaces(self) -> tuple[list[gr.Blocks], list[str]]:
|
def get_interfaces(self) -> tuple[list[gr.Blocks], list[str]]:
|
||||||
"""
|
"""
|
||||||
@@ -53,9 +54,9 @@ class GenerateUI:
|
|||||||
def get_settings_interface(self) -> gr.Blocks:
|
def get_settings_interface(self) -> gr.Blocks:
|
||||||
with gr.Blocks() as interface:
|
with gr.Blocks() as interface:
|
||||||
reload_ui = gr.Button("Reload UI", variant="primary")
|
reload_ui = gr.Button("Reload UI", variant="primary")
|
||||||
|
|
||||||
def reload():
|
def reload():
|
||||||
self.ui.close()
|
gr.Warning("Please restart the server to apply changes.")
|
||||||
sys.exit("Reload")
|
|
||||||
|
|
||||||
reload_ui.click(reload)
|
reload_ui.click(reload)
|
||||||
for engine_type, engines in ENGINES.items():
|
for engine_type, engines in ENGINES.items():
|
||||||
@@ -202,3 +203,8 @@ class GenerateUI:
|
|||||||
# we don't care about this, it's not the selected engine, we throw it away
|
# we don't care about this, it's not the selected engine, we throw it away
|
||||||
args = args[engine.num_options :]
|
args = args[engine.num_options :]
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
def launch():
|
||||||
|
ui_generator = GenerateUI()
|
||||||
|
ui_generator.launch_ui()
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
from . import GenerateUI
|
|
||||||
|
|
||||||
|
|
||||||
def launch():
|
|
||||||
ui_generator = GenerateUI()
|
|
||||||
ui_generator.launch_ui()
|
|
||||||
Reference in New Issue
Block a user