Spaces:
Running
on
Zero
Running
on
Zero
timofey
commited on
Commit
·
06ad2f7
1
Parent(s):
4f11796
fix gradio
Browse files
app.py
CHANGED
|
@@ -8,9 +8,9 @@ try:
|
|
| 8 |
router_pipeline = pipeline(
|
| 9 |
"text-classification",
|
| 10 |
model=MODEL_NAME,
|
| 11 |
-
return_all_scores=True
|
|
|
|
| 12 |
)
|
| 13 |
-
router_pipeline.to('cuda')
|
| 14 |
except Exception as e:
|
| 15 |
print(f"Error loading model: {e}")
|
| 16 |
router_pipeline = None
|
|
@@ -18,7 +18,7 @@ except Exception as e:
|
|
| 18 |
@spaces.GPU
|
| 19 |
def classify_query(query_text):
|
| 20 |
if not router_pipeline:
|
| 21 |
-
|
| 22 |
|
| 23 |
if not query_text or not query_text.strip():
|
| 24 |
return {"Vector Search": 0.0, "Lexical Search": 0.0}
|
|
@@ -44,9 +44,9 @@ Enter an e-commerce query to determine if it's better for **vector search** (con
|
|
| 44 |
examples = [
|
| 45 |
["father day gift"],
|
| 46 |
["16x16 pillow cover"],
|
| 47 |
-
["
|
| 48 |
-
["
|
| 49 |
-
["
|
| 50 |
]
|
| 51 |
|
| 52 |
app = gr.Interface(
|
|
@@ -69,3 +69,4 @@ app = gr.Interface(
|
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
app.launch()
|
|
|
|
|
|
| 8 |
router_pipeline = pipeline(
|
| 9 |
"text-classification",
|
| 10 |
model=MODEL_NAME,
|
| 11 |
+
return_all_scores=True,
|
| 12 |
+
device='cuda'
|
| 13 |
)
|
|
|
|
| 14 |
except Exception as e:
|
| 15 |
print(f"Error loading model: {e}")
|
| 16 |
router_pipeline = None
|
|
|
|
| 18 |
@spaces.GPU
|
| 19 |
def classify_query(query_text):
|
| 20 |
if not router_pipeline:
|
| 21 |
+
raise gr.Error("Model could not be loaded. Check Space logs for details.")
|
| 22 |
|
| 23 |
if not query_text or not query_text.strip():
|
| 24 |
return {"Vector Search": 0.0, "Lexical Search": 0.0}
|
|
|
|
| 44 |
examples = [
|
| 45 |
["father day gift"],
|
| 46 |
["16x16 pillow cover"],
|
| 47 |
+
["office chair"],
|
| 48 |
+
["prom dress"],
|
| 49 |
+
["sony wh1000xm4"],
|
| 50 |
]
|
| 51 |
|
| 52 |
app = gr.Interface(
|
|
|
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
app.launch()
|
| 72 |
+
|