Spaces:
Running
on
Zero
Running
on
Zero
Lord-Raven
commited on
Commit
·
9231215
1
Parent(s):
df67acc
Experimenting with few-shot classification.
Browse files
app.py
CHANGED
@@ -62,8 +62,10 @@ def classify(data_string, request: gradio.Request):
|
|
62 |
if request.headers["origin"] not in ["https://statosphere-3704059fdd7e.c5v4v4jx6pq5.win", "https://crunchatize-77a78ffcc6a6.c5v4v4jx6pq5.win", "https://ravenok-statosphere-backend.hf.space"]:
|
63 |
return "{}"
|
64 |
data = json.loads(data_string)
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
def zero_shot_classification(data):
|
69 |
results = classifier(data['sequence'], candidate_labels=data['candidate_labels'], hypothesis_template=data['hypothesis_template'], multi_label=data['multi_label'])
|
|
|
62 |
if request.headers["origin"] not in ["https://statosphere-3704059fdd7e.c5v4v4jx6pq5.win", "https://crunchatize-77a78ffcc6a6.c5v4v4jx6pq5.win", "https://ravenok-statosphere-backend.hf.space"]:
|
63 |
return "{}"
|
64 |
data = json.loads(data_string)
|
65 |
+
if 'task' in data and data['task'] == 'few_shot_classification':
|
66 |
+
return few_shot_classification(data)
|
67 |
+
else:
|
68 |
+
return zero_shot_classification(data)
|
69 |
|
70 |
def zero_shot_classification(data):
|
71 |
results = classifier(data['sequence'], candidate_labels=data['candidate_labels'], hypothesis_template=data['hypothesis_template'], multi_label=data['multi_label'])
|