Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,17 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|