Spaces:
Running
on
Zero
Running
on
Zero
added zerogpu to predict
Browse files
app.py
CHANGED
|
@@ -108,13 +108,13 @@ def no_op_decorator(func):
|
|
| 108 |
# Decide which decorator to use based on environment
|
| 109 |
decorator_to_use = spaces.GPU() if is_running_in_hf_space() else no_op_decorator
|
| 110 |
#duration=120
|
| 111 |
-
|
|
|
|
| 112 |
def create_embeddings(texts_to_embedd):
|
| 113 |
"""Create embeddings for the input texts using the loaded model."""
|
| 114 |
return model.encode(texts_to_embedd, show_progress_bar=True, batch_size=192)
|
| 115 |
|
| 116 |
|
| 117 |
-
@decorator_to_use
|
| 118 |
def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduction_method,
|
| 119 |
plot_time_checkbox, locally_approximate_publication_date_checkbox,
|
| 120 |
download_csv_checkbox, download_png_checkbox,citation_graph_checkbox, progress=gr.Progress()):
|
|
@@ -450,6 +450,8 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduc
|
|
| 450 |
]
|
| 451 |
|
| 452 |
|
|
|
|
|
|
|
| 453 |
theme = gr.themes.Monochrome(
|
| 454 |
font=[gr.themes.GoogleFont("Roboto Condensed"), "ui-sans-serif", "system-ui", "sans-serif"],
|
| 455 |
text_size="lg",
|
|
|
|
| 108 |
# Decide which decorator to use based on environment
|
| 109 |
decorator_to_use = spaces.GPU() if is_running_in_hf_space() else no_op_decorator
|
| 110 |
#duration=120
|
| 111 |
+
|
| 112 |
+
@decorator_to_use
|
| 113 |
def create_embeddings(texts_to_embedd):
|
| 114 |
"""Create embeddings for the input texts using the loaded model."""
|
| 115 |
return model.encode(texts_to_embedd, show_progress_bar=True, batch_size=192)
|
| 116 |
|
| 117 |
|
|
|
|
| 118 |
def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduction_method,
|
| 119 |
plot_time_checkbox, locally_approximate_publication_date_checkbox,
|
| 120 |
download_csv_checkbox, download_png_checkbox,citation_graph_checkbox, progress=gr.Progress()):
|
|
|
|
| 450 |
]
|
| 451 |
|
| 452 |
|
| 453 |
+
predict.zerogpu = True
|
| 454 |
+
|
| 455 |
theme = gr.themes.Monochrome(
|
| 456 |
font=[gr.themes.GoogleFont("Roboto Condensed"), "ui-sans-serif", "system-ui", "sans-serif"],
|
| 457 |
text_size="lg",
|