Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
-
import torch
|
| 4 |
-
|
| 5 |
-
try:
|
| 6 |
-
router = pipeline(
|
| 7 |
-
"text-classification",
|
| 8 |
-
model="AmirMohseni/reasoning-router-0.6b",
|
| 9 |
-
device_map="auto",
|
| 10 |
-
torch_dtype=torch.bfloat16
|
| 11 |
-
)
|
| 12 |
-
except Exception as e:
|
| 13 |
-
print(f"Error loading model: {e}")
|
| 14 |
-
# Fallback to CPU if specific GPU setup fails
|
| 15 |
-
router = pipeline(
|
| 16 |
-
"text-classification",
|
| 17 |
-
model="AmirMohseni/reasoning-router-0.6b",
|
| 18 |
-
)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# --- 2. Define the classification function ---
|
| 22 |
def classify_prompt(prompt: str) -> dict:
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
router = pipeline(
|
| 5 |
+
"text-classification",
|
| 6 |
+
model="AmirMohseni/reasoning-router-0.6b",
|
| 7 |
+
device_map="auto",
|
| 8 |
+
)
|
| 9 |
|
| 10 |
# --- 2. Define the classification function ---
|
| 11 |
def classify_prompt(prompt: str) -> dict:
|