import gradio as gr
import threading
import numpy as np  # Import NumPy for memory-efficient data structures
import gc  # Import garbage collector for explicit memory management

# Increase thread stack size
threading.stack_size(2**33)

# Load the model
model = gr.load("models/enhanceaiteam/Flux-uncensored")

# Preload large datasets or pre-trained weights (if applicable)
# ...

# Launch the model in a thread
thread = threading.Thread(target=model.launch)

# Start the thread
thread.start()

# Explicitly trigger garbage collection to free up memory
gc.collect()

# Continue with other tasks or image generation code
# ...