Upload 10 files
Browse files- .gitattributes +31 -35
- README.md +14 -1
- config.json +39 -0
- handler.py +29 -0
- pytorch_model.bin +3 -0
- requirements.txt +1 -0
- special_tokens_map.json +1 -0
- test.py +19 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
.gitattributes
CHANGED
@@ -1,35 +1,31 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.
|
6 |
-
*.
|
7 |
-
*.
|
8 |
-
*.
|
9 |
-
*.
|
10 |
-
*.
|
11 |
-
*.
|
12 |
-
*.
|
13 |
-
*.
|
14 |
-
*.
|
15 |
-
*.
|
16 |
-
*.
|
17 |
-
*.
|
18 |
-
*.
|
19 |
-
*.
|
20 |
-
*.
|
21 |
-
*.
|
22 |
-
*.
|
23 |
-
|
24 |
-
*.
|
25 |
-
*.
|
26 |
-
|
27 |
-
*.
|
28 |
-
*.
|
29 |
-
*.
|
30 |
-
*.
|
31 |
-
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
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,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, List, Any
|
2 |
+
from transformers import pipeline
|
3 |
+
import holidays
|
4 |
+
|
5 |
+
class EndpointHandler():
|
6 |
+
def __init__(self, path=""):
|
7 |
+
self.pipeline = pipeline("text-classification",model=path)
|
8 |
+
self.holidays = holidays.US()
|
9 |
+
|
10 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
11 |
+
"""
|
12 |
+
data args:
|
13 |
+
inputs (:obj: `str`)
|
14 |
+
date (:obj: `str`)
|
15 |
+
Return:
|
16 |
+
A :obj:`list` | `dict`: will be serialized and returned
|
17 |
+
"""
|
18 |
+
# get inputs
|
19 |
+
inputs = data.pop("inputs",data)
|
20 |
+
date = data.pop("date", None)
|
21 |
+
|
22 |
+
# check if date exists and if it is a holiday
|
23 |
+
if date is not None and date in self.holidays:
|
24 |
+
return [{"label": "happy", "score": 1}]
|
25 |
+
|
26 |
+
|
27 |
+
# run normal prediction
|
28 |
+
prediction = self.pipeline(inputs)
|
29 |
+
return prediction
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5aa7398d830fcc94f95af88d7cc3013813668cfc58a07d75a8116cfd8af75c4d
|
3 |
+
size 267875479
|
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]"}
|
test.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from handler import EndpointHandler
|
2 |
+
|
3 |
+
# init handler
|
4 |
+
my_handler = EndpointHandler(path=".")
|
5 |
+
|
6 |
+
# prepare sample payload
|
7 |
+
non_holiday_payload = {"inputs": "I am quite excited how this will turn out", "date": "2022-08-08"}
|
8 |
+
holiday_payload = {"inputs": "Nobody can do it", "date": "2022-07-04"}
|
9 |
+
|
10 |
+
# test the handler
|
11 |
+
non_holiday_pred=my_handler(non_holiday_payload)
|
12 |
+
holiday_payload=my_handler(holiday_payload)
|
13 |
+
|
14 |
+
# show results
|
15 |
+
print("non_holiday_pred", non_holiday_pred)
|
16 |
+
print("holiday_payload", holiday_payload)
|
17 |
+
|
18 |
+
# non_holiday_pred [{'label': 'joy', 'score': 0.9985942244529724}]
|
19 |
+
# holiday_payload [{'label': 'happy', 'score': 1}]
|
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
|
|