This commit is contained in:
Karl 2025-09-23 14:32:14 +01:00
parent bf97ce7c22
commit 05dd1e2c51

View File

@ -21,7 +21,7 @@ except ImportError:
from lib.generate_xml import create_config_xml, append_to_config_xml from lib.generate_xml import create_config_xml, append_to_config_xml
from lib.resize_images import resize_images from lib.resize_images import resize_images
from lib.xml_reader import extract_from_values from lib.xml_reader import extract_from_values
from lib.general import list_profiles # Profile functions are now handled entirely by GUI
from lib.logging import LOGGING_CONFIG from lib.logging import LOGGING_CONFIG
# from simple_term_menu import TerminalMenu # from simple_term_menu import TerminalMenu
@ -41,21 +41,14 @@ user_config = configparser.ConfigParser()
try: try:
user_config.read("./user_config.cfg") user_config.read("./user_config.cfg")
# Check if we're running in GUI mode (look for GUI environment variable or check if GUI is importing us) # GUI mode: Use default profile or first available profile
running_in_gui = os.environ.get('FM_NEWGEN_GUI_MODE', 'false').lower() == 'true'
if running_in_gui:
# GUI mode: don't do CLI profile selection, let GUI handle it
# Use default profile or first available profile
profiles = [section.split(':', 1)[1] for section in user_config.sections() if section.startswith('profile:')] profiles = [section.split(':', 1)[1] for section in user_config.sections() if section.startswith('profile:')]
if profiles: if profiles:
selected_profile = profiles[0] # Use first available profile selected_profile = profiles[0] # Use first available profile
logging.debug(f"Using profile '{selected_profile}'")
else: else:
selected_profile = "NewGens" # Default fallback selected_profile = "NewGens" # Default fallback
logging.debug(f"GUI mode: using profile '{selected_profile}'") logging.debug(f"No profiles found, using default profile '{selected_profile}'")
else:
# CLI mode: do normal profile selection
selected_profile = choose_profile("./user_config.cfg")
selected_profile = f"profile:{selected_profile}" selected_profile = f"profile:{selected_profile}"
output_folder = user_config[selected_profile]["output_dir"] output_folder = user_config[selected_profile]["output_dir"]
@ -86,7 +79,7 @@ def generate_image(uid, comfy_prompt):
logging.warning(f"Model configuration not found, using default: {model_id}") logging.warning(f"Model configuration not found, using default: {model_id}")
# Check if CUDA is available and get detailed GPU info # Check if CUDA is available and get detailed GPU info
if torch.cuda.is_available(): if torch.cuda.is_available() and not force_cpu:
device = "cuda" device = "cuda"
gpu_count = torch.cuda.device_count() gpu_count = torch.cuda.device_count()
current_device = torch.cuda.current_device() current_device = torch.cuda.current_device()
@ -97,9 +90,7 @@ def generate_image(uid, comfy_prompt):
logging.info(f"GPU memory: {gpu_memory:.1f} GB") logging.info(f"GPU memory: {gpu_memory:.1f} GB")
logging.info(f"Available GPU devices: {gpu_count}") logging.info(f"Available GPU devices: {gpu_count}")
logging.info(f"Using device: {device} (GPU {current_device})") logging.info(f"Using device: {device} (GPU {current_device})")
else:
# Check if user wants to force CPU usage
force_cpu = os.environ.get('FM_NEWGEN_FORCE_CPU', 'false').lower() == 'true'
if force_cpu: if force_cpu:
device = "cpu" device = "cpu"
logging.info("Forcing CPU usage as requested") logging.info("Forcing CPU usage as requested")
@ -310,6 +301,9 @@ def main():
process_specific_player = os.environ.get('FM_NEWGEN_PROCESS_PLAYER', 'false').lower() == 'true' process_specific_player = os.environ.get('FM_NEWGEN_PROCESS_PLAYER', 'false').lower() == 'true'
specific_player_uid = os.environ.get('FM_NEWGEN_PLAYER_UID', '') specific_player_uid = os.environ.get('FM_NEWGEN_PLAYER_UID', '')
# Check if user wants to force CPU usage
force_cpu = os.environ.get('FM_NEWGEN_FORCE_CPU', 'false').lower() == 'true'
# Check for processed players # Check for processed players
try: try:
if update_mode: if update_mode: