aexyb commited on
Commit
ff581b9
·
verified ·
1 Parent(s): 685ace5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -34
app.py CHANGED
@@ -1,34 +1,17 @@
1
- import gradio as gr
2
-
3
- import threading
4
-
5
- # Load model directly
6
-
7
-
8
- from transformers import AutoModel
9
-
10
- import numpy as np # Import NumPy for memory-efficient data structures
11
-
12
- import gc # Import garbage collector for explicit memory management
13
-
14
- # Increase thread stack size
15
-
16
- threading.stack_size(2**33)
17
-
18
- # Load the model
19
- model = gr.load("huggingface/Liquid1/llama-3-8b-liquid-coding-agent")
20
-
21
- # Preload large datasets or pre-trained weights (if applicable)
22
- # ...
23
-
24
- # Launch the model in a thread
25
- thread = threading.Thread(target=model.launch)
26
-
27
- # Start the thread
28
- thread.start()
29
-
30
- # Explicitly trigger garbage collection to free up memory
31
- gc.collect()
32
-
33
- # Continue with other tasks or image generation code
34
- # ...
 
1
+ import gradio as gr
2
+ import concurrent.futures
3
+
4
+ # Load the model into RAM
5
+ model = gr.load("models/TheBloke/SOLAR-10.7B-Instruct-v1.0-uncensored-GGUF")
6
+
7
+ def interact(input):
8
+ # Define the function for user interaction
9
+ response = model(input)
10
+ return response
11
+
12
+ # Use ThreadPoolExecutor to manage the threads
13
+ with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
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()