Spaces:
Running on Zero
Running on Zero
Upload 3 files
Browse files- app.py +21 -3
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -24,6 +24,7 @@ from sentence_transformers import SentenceTransformer
|
|
| 24 |
import plotly.graph_objects as go
|
| 25 |
from sklearn.cluster import KMeans
|
| 26 |
from sklearn.decomposition import PCA
|
|
|
|
| 27 |
|
| 28 |
try:
|
| 29 |
import umap
|
|
@@ -587,7 +588,25 @@ def on_csv_file_upload(file_obj):
|
|
| 587 |
except Exception as e:
|
| 588 |
return gr.update(choices=[], value=None, visible=False), f"<div class='error-tag'>CSV Error: {html.escape(str(e))}</div>"
|
| 589 |
|
| 590 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 591 |
def process_corpus(
|
| 592 |
source_type: str,
|
| 593 |
raw_text: str,
|
|
@@ -1207,6 +1226,5 @@ with gr.Blocks(theme=theme, css=CUSTOM_CSS, title="Multilingual Semantic Embeddi
|
|
| 1207 |
]
|
| 1208 |
)
|
| 1209 |
|
| 1210 |
-
# To this:
|
| 1211 |
if __name__ == "__main__":
|
| 1212 |
-
demo.queue().launch(
|
|
|
|
| 24 |
import plotly.graph_objects as go
|
| 25 |
from sklearn.cluster import KMeans
|
| 26 |
from sklearn.decomposition import PCA
|
| 27 |
+
import spaces # <-- Import spaces
|
| 28 |
|
| 29 |
try:
|
| 30 |
import umap
|
|
|
|
| 588 |
except Exception as e:
|
| 589 |
return gr.update(choices=[], value=None, visible=False), f"<div class='error-tag'>CSV Error: {html.escape(str(e))}</div>"
|
| 590 |
|
| 591 |
+
@spaces.GPU
|
| 592 |
+
def process_corpus(
|
| 593 |
+
source_type: str,
|
| 594 |
+
raw_text: str,
|
| 595 |
+
pdf_file,
|
| 596 |
+
csv_file,
|
| 597 |
+
csv_col: str,
|
| 598 |
+
chunk_size: int,
|
| 599 |
+
chunk_overlap: int,
|
| 600 |
+
projection_method: str,
|
| 601 |
+
k_clusters: int,
|
| 602 |
+
progress=gr.Progress(track_tqdm=True)
|
| 603 |
+
):
|
| 604 |
+
"""
|
| 605 |
+
Main ingestion and vector pipeline:
|
| 606 |
+
...
|
| 607 |
+
"""
|
| 608 |
+
# ... rest of your existing function code remains unchanged
|
| 609 |
+
|
| 610 |
def process_corpus(
|
| 611 |
source_type: str,
|
| 612 |
raw_text: str,
|
|
|
|
| 1226 |
]
|
| 1227 |
)
|
| 1228 |
|
|
|
|
| 1229 |
if __name__ == "__main__":
|
| 1230 |
+
demo.queue().launch()
|
requirements.txt
CHANGED
|
@@ -8,3 +8,4 @@ scikit-learn>=1.3.0
|
|
| 8 |
umap-learn>=0.5.5
|
| 9 |
plotly>=5.18.0
|
| 10 |
numpy>=1.24.0
|
|
|
|
|
|
| 8 |
umap-learn>=0.5.5
|
| 9 |
plotly>=5.18.0
|
| 10 |
numpy>=1.24.0
|
| 11 |
+
spaces
|