Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
|
|
|
|
3 |
|
4 |
-
#
|
|
|
|
|
|
|
5 |
model = gr.load("models/mann-e/Mann-E_Dreams")
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
# Create a Gradio interface with the loaded model
|
15 |
-
interface = gr.Interface(fn=interact, inputs="text", outputs="image")
|
16 |
-
# Handle the interactions with Gradio
|
17 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import threading
|
3 |
+
import numpy as np # Import NumPy for memory-efficient data structures
|
4 |
+
import gc # Import garbage collector for explicit memory management
|
5 |
|
6 |
+
# Increase thread stack size
|
7 |
+
threading.stack_size(2**33)
|
8 |
+
|
9 |
+
# Load the model
|
10 |
model = gr.load("models/mann-e/Mann-E_Dreams")
|
11 |
|
12 |
+
# Preload large datasets or pre-trained weights (if applicable)
|
13 |
+
# ...
|
14 |
+
|
15 |
+
# Launch the model in a thread
|
16 |
+
thread = threading.Thread(target=model.launch)
|
17 |
+
|
18 |
+
# Start the thread
|
19 |
+
thread.start()
|
20 |
+
|
21 |
+
# Explicitly trigger garbage collection to free up memory
|
22 |
+
gc.collect()
|
23 |
|
24 |
+
# Continue with other tasks or image generation code
|
25 |
+
# ...
|
|
|
|
|
|
|
|