Spaces:
Running on Zero
Running on Zero
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,9 @@ from torch import exp
|
|
| 4 |
from inflections_funcs import start_model, make_beams, get_beam_tokens, calculate_score_vectors
|
| 5 |
|
| 6 |
# Global model initialization
|
| 7 |
-
|
| 8 |
-
processor =
|
| 9 |
-
|
| 10 |
-
def initialize_model():
|
| 11 |
-
global model, processor
|
| 12 |
-
if model is None:
|
| 13 |
-
print("Loading model...")
|
| 14 |
-
model, processor = start_model()
|
| 15 |
-
print("Model loaded.")
|
| 16 |
-
return model, processor
|
| 17 |
|
| 18 |
def generate_beam_html(index, all_beams_data, dark_mode):
|
| 19 |
"""
|
|
@@ -70,9 +63,6 @@ def predict(prompt, dark_mode):
|
|
| 70 |
"""
|
| 71 |
Generates responses for 5 beams and returns the first beam's visualization and visibility for controls.
|
| 72 |
"""
|
| 73 |
-
# Ensure model is loaded within the GPU context to avoid ZeroGPU CUDA init errors
|
| 74 |
-
model, processor = initialize_model()
|
| 75 |
-
|
| 76 |
# Generate beams
|
| 77 |
generated_dicts, transcription = make_beams(model, processor, prompt)
|
| 78 |
|
|
|
|
| 4 |
from inflections_funcs import start_model, make_beams, get_beam_tokens, calculate_score_vectors
|
| 5 |
|
| 6 |
# Global model initialization
|
| 7 |
+
print("Loading model...")
|
| 8 |
+
model, processor = start_model()
|
| 9 |
+
print("Model loaded.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def generate_beam_html(index, all_beams_data, dark_mode):
|
| 12 |
"""
|
|
|
|
| 63 |
"""
|
| 64 |
Generates responses for 5 beams and returns the first beam's visualization and visibility for controls.
|
| 65 |
"""
|
|
|
|
|
|
|
|
|
|
| 66 |
# Generate beams
|
| 67 |
generated_dicts, transcription = make_beams(model, processor, prompt)
|
| 68 |
|