Spaces:
Paused
Paused
add text mapping process
Browse files- .ipynb_checkpoints/app-checkpoint.py +0 -56
- .ipynb_checkpoints/eval_and_inference-checkpoint.ipynb +0 -279
- .ipynb_checkpoints/eval_and_inference_lite_v1-checkpoint.ipynb +0 -189
- .ipynb_checkpoints/text_label-checkpoint.json +0 -528
- .ipynb_checkpoints/text_mapping_example-checkpoint.ipynb +0 -90
- app.py +10 -3
- text_mapping_example.ipynb +1 -1
- utils/__init__.py +0 -0
- utils/postprocess.py +8 -0
.ipynb_checkpoints/app-checkpoint.py
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
# Gaepago model V1 (CPU Test)
|
2 |
-
|
3 |
-
# import package
|
4 |
-
from transformers import AutoModelForAudioClassification
|
5 |
-
from transformers import AutoFeatureExtractor
|
6 |
-
from transformers import pipeline
|
7 |
-
from datasets import Dataset, Audio
|
8 |
-
import gradio as gr
|
9 |
-
import torch
|
10 |
-
|
11 |
-
# Set model & Dataset NM
|
12 |
-
MODEL_NAME = "Gae8J/gaepago-20"
|
13 |
-
DATASET_NAME = "Gae8J/modeling_v1"
|
14 |
-
|
15 |
-
# Import Model & feature extractor
|
16 |
-
# model = AutoModelForAudioClassification.from_pretrained(MODEL_NAME)
|
17 |
-
from transformers import AutoConfig
|
18 |
-
config = AutoConfig.from_pretrained(MODEL_NAME)
|
19 |
-
model = torch.jit.load(f"./model/gaepago-20-lite/model_quant_int8.pt")
|
20 |
-
feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)
|
21 |
-
|
22 |
-
# ๋ชจ๋ธ cpu๋ก ๋ณ๊ฒฝํ์ฌ ์งํ
|
23 |
-
model.to("cpu")
|
24 |
-
|
25 |
-
# Gaepago Inference Model function
|
26 |
-
def gaepago_fn(tmp_audio_dir):
|
27 |
-
print(tmp_audio_dir)
|
28 |
-
audio_dataset = Dataset.from_dict({"audio": [tmp_audio_dir]}).cast_column("audio", Audio(sampling_rate=16000))
|
29 |
-
inputs = feature_extractor(audio_dataset[0]["audio"]["array"]
|
30 |
-
,sampling_rate=audio_dataset[0]["audio"]["sampling_rate"]
|
31 |
-
,return_tensors="pt")
|
32 |
-
with torch.no_grad():
|
33 |
-
# logits = model(**inputs).logits
|
34 |
-
logits = model(**inputs)["logits"]
|
35 |
-
# predicted_class_ids = torch.argmax(logits).item()
|
36 |
-
# predicted_label = model.config.id2label[predicted_class_ids]
|
37 |
-
predicted_class_ids = torch.argmax(logits).item()
|
38 |
-
predicted_label = config.id2label[predicted_class_ids]
|
39 |
-
|
40 |
-
return predicted_label
|
41 |
-
|
42 |
-
# Main
|
43 |
-
main_api = gr.Blocks()
|
44 |
-
|
45 |
-
with main_api:
|
46 |
-
gr.Markdown("## 8J Gaepago Demo(with CPU)")
|
47 |
-
with gr.Row():
|
48 |
-
audio = gr.Audio(source="microphone", type="filepath"
|
49 |
-
,label='๋
น์๋ฒํผ์ ๋๋ฌ ์ด์ฝ๊ฐ ํ๋ ๋ง์ ๋ค๋ ค์ฃผ์ธ์')
|
50 |
-
transcription = gr.Textbox(label='์ง๊ธ ์ด์ฝ๊ฐ ํ๋ ๋ง์...')
|
51 |
-
b1 = gr.Button("๊ฐ์์ง ์ธ์ด ๋ฒ์ญ!")
|
52 |
-
|
53 |
-
b1.click(gaepago_fn, inputs=audio, outputs=transcription)
|
54 |
-
# examples = gr.Examples(examples=example_list,
|
55 |
-
# inputs=[audio])
|
56 |
-
main_api.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.ipynb_checkpoints/eval_and_inference-checkpoint.ipynb
DELETED
@@ -1,279 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "markdown",
|
5 |
-
"id": "544a588c-68ff-440f-be5c-389f1f02a0b7",
|
6 |
-
"metadata": {},
|
7 |
-
"source": [
|
8 |
-
"# example"
|
9 |
-
]
|
10 |
-
},
|
11 |
-
{
|
12 |
-
"cell_type": "code",
|
13 |
-
"execution_count": 1,
|
14 |
-
"id": "7ef8c97c-cefd-4905-8d63-af303c412d1a",
|
15 |
-
"metadata": {},
|
16 |
-
"outputs": [],
|
17 |
-
"source": [
|
18 |
-
"MODEL_NAME = \"gaepago-20\"\n",
|
19 |
-
"DATASET_NAME = \"Gae8J/modeling_v1\""
|
20 |
-
]
|
21 |
-
},
|
22 |
-
{
|
23 |
-
"cell_type": "markdown",
|
24 |
-
"id": "044499ce-7821-4b59-9f4b-5971b6a24cce",
|
25 |
-
"metadata": {},
|
26 |
-
"source": [
|
27 |
-
"## load dataset (test data)"
|
28 |
-
]
|
29 |
-
},
|
30 |
-
{
|
31 |
-
"cell_type": "code",
|
32 |
-
"execution_count": 2,
|
33 |
-
"id": "e827e3bb-820d-46b3-b2e8-fdb97787bde1",
|
34 |
-
"metadata": {},
|
35 |
-
"outputs": [
|
36 |
-
{
|
37 |
-
"name": "stderr",
|
38 |
-
"output_type": "stream",
|
39 |
-
"text": [
|
40 |
-
"Found cached dataset parquet (/home/jovyan/.cache/huggingface/datasets/Gae8J___parquet/Gae8J--modeling_v1-b480c78c61a26816/0.0.0/2a3b91fbd88a2c90d1dbbb32b460cf621d31bd5b05b934492fdef7d8d6f236ec)\n"
|
41 |
-
]
|
42 |
-
},
|
43 |
-
{
|
44 |
-
"data": {
|
45 |
-
"application/vnd.jupyter.widget-view+json": {
|
46 |
-
"model_id": "f078fd108d2044b48a961bee6ed49747",
|
47 |
-
"version_major": 2,
|
48 |
-
"version_minor": 0
|
49 |
-
},
|
50 |
-
"text/plain": [
|
51 |
-
" 0%| | 0/3 [00:00<?, ?it/s]"
|
52 |
-
]
|
53 |
-
},
|
54 |
-
"metadata": {},
|
55 |
-
"output_type": "display_data"
|
56 |
-
}
|
57 |
-
],
|
58 |
-
"source": [
|
59 |
-
"from datasets import load_dataset, Audio\n",
|
60 |
-
"\n",
|
61 |
-
"dataset = load_dataset(DATASET_NAME)\n",
|
62 |
-
"dataset = dataset.cast_column(\"audio\", Audio(sampling_rate=16000))\n",
|
63 |
-
"test_data = dataset['test']\n",
|
64 |
-
"sampling_rate = test_data.features[\"audio\"].sampling_rate"
|
65 |
-
]
|
66 |
-
},
|
67 |
-
{
|
68 |
-
"cell_type": "markdown",
|
69 |
-
"id": "d0c16b3d-32dd-4e61-86bd-e21232840e98",
|
70 |
-
"metadata": {},
|
71 |
-
"source": [
|
72 |
-
"## run"
|
73 |
-
]
|
74 |
-
},
|
75 |
-
{
|
76 |
-
"cell_type": "code",
|
77 |
-
"execution_count": 5,
|
78 |
-
"id": "d504778d-4ba3-43d3-b22b-76ce838a5edf",
|
79 |
-
"metadata": {},
|
80 |
-
"outputs": [],
|
81 |
-
"source": [
|
82 |
-
"from transformers import AutoModelForAudioClassification\n",
|
83 |
-
"from transformers import AutoFeatureExtractor\n",
|
84 |
-
"import torch\n",
|
85 |
-
"\n",
|
86 |
-
"model = AutoModelForAudioClassification.from_pretrained(MODEL_NAME)\n",
|
87 |
-
"feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)\n",
|
88 |
-
"\n",
|
89 |
-
"preds = []\n",
|
90 |
-
"gts = []\n",
|
91 |
-
"for i in range(len(test_data)):\n",
|
92 |
-
" inputs = feature_extractor(test_data[i][\"audio\"][\"array\"], sampling_rate=sampling_rate, return_tensors=\"pt\")\n",
|
93 |
-
" with torch.no_grad():\n",
|
94 |
-
" logits = model(**inputs).logits\n",
|
95 |
-
" predicted_class_ids = torch.argmax(logits).item()\n",
|
96 |
-
" predicted_label = model.config.id2label[predicted_class_ids]\n",
|
97 |
-
" preds.append(predicted_label)\n",
|
98 |
-
" gts.append(model.config.id2label[test_data[i]['label']])"
|
99 |
-
]
|
100 |
-
},
|
101 |
-
{
|
102 |
-
"cell_type": "markdown",
|
103 |
-
"id": "f200bec5-c2d9-4549-8bb8-1400c484f499",
|
104 |
-
"metadata": {},
|
105 |
-
"source": [
|
106 |
-
"## performance"
|
107 |
-
]
|
108 |
-
},
|
109 |
-
{
|
110 |
-
"cell_type": "code",
|
111 |
-
"execution_count": 6,
|
112 |
-
"id": "be97683d-da60-4d23-abc9-0be9b86cd636",
|
113 |
-
"metadata": {},
|
114 |
-
"outputs": [
|
115 |
-
{
|
116 |
-
"name": "stdout",
|
117 |
-
"output_type": "stream",
|
118 |
-
"text": [
|
119 |
-
" precision recall f1-score support\n",
|
120 |
-
"\n",
|
121 |
-
" bark 0.56 0.62 0.59 8\n",
|
122 |
-
" growling 1.00 0.83 0.91 6\n",
|
123 |
-
" howl 0.75 0.86 0.80 7\n",
|
124 |
-
" panting 1.00 0.80 0.89 10\n",
|
125 |
-
" whimper 0.38 0.43 0.40 7\n",
|
126 |
-
"\n",
|
127 |
-
" accuracy 0.71 38\n",
|
128 |
-
" macro avg 0.74 0.71 0.72 38\n",
|
129 |
-
"weighted avg 0.75 0.71 0.72 38\n",
|
130 |
-
"\n"
|
131 |
-
]
|
132 |
-
}
|
133 |
-
],
|
134 |
-
"source": [
|
135 |
-
"from sklearn.metrics import classification_report\n",
|
136 |
-
"test_performance = classification_report(gts, preds)\n",
|
137 |
-
"print(test_performance)"
|
138 |
-
]
|
139 |
-
},
|
140 |
-
{
|
141 |
-
"cell_type": "markdown",
|
142 |
-
"id": "ea3ee48d-19c7-4f9d-9c2c-4b03d4748acb",
|
143 |
-
"metadata": {},
|
144 |
-
"source": [
|
145 |
-
"## load dataset (validation data)"
|
146 |
-
]
|
147 |
-
},
|
148 |
-
{
|
149 |
-
"cell_type": "code",
|
150 |
-
"execution_count": 7,
|
151 |
-
"id": "33e5051e-75a2-4523-905c-fe1dbc81eda2",
|
152 |
-
"metadata": {},
|
153 |
-
"outputs": [
|
154 |
-
{
|
155 |
-
"name": "stderr",
|
156 |
-
"output_type": "stream",
|
157 |
-
"text": [
|
158 |
-
"WARNING:datasets.builder:Found cached dataset parquet (/home/jovyan/.cache/huggingface/datasets/Gae8J___parquet/Gae8J--modeling_v1-b480c78c61a26816/0.0.0/2a3b91fbd88a2c90d1dbbb32b460cf621d31bd5b05b934492fdef7d8d6f236ec)\n"
|
159 |
-
]
|
160 |
-
},
|
161 |
-
{
|
162 |
-
"data": {
|
163 |
-
"application/vnd.jupyter.widget-view+json": {
|
164 |
-
"model_id": "cf5cfe439c174b8284b4668419af6dca",
|
165 |
-
"version_major": 2,
|
166 |
-
"version_minor": 0
|
167 |
-
},
|
168 |
-
"text/plain": [
|
169 |
-
" 0%| | 0/3 [00:00<?, ?it/s]"
|
170 |
-
]
|
171 |
-
},
|
172 |
-
"metadata": {},
|
173 |
-
"output_type": "display_data"
|
174 |
-
}
|
175 |
-
],
|
176 |
-
"source": [
|
177 |
-
"from datasets import load_dataset, Audio\n",
|
178 |
-
"\n",
|
179 |
-
"dataset = load_dataset(DATASET_NAME)\n",
|
180 |
-
"dataset = dataset.cast_column(\"audio\", Audio(sampling_rate=16000))\n",
|
181 |
-
"test_data = dataset['validation']\n",
|
182 |
-
"sampling_rate = test_data.features[\"audio\"].sampling_rate"
|
183 |
-
]
|
184 |
-
},
|
185 |
-
{
|
186 |
-
"cell_type": "markdown",
|
187 |
-
"id": "36bee3b3-e66f-46dc-8030-cef3cb62ff97",
|
188 |
-
"metadata": {},
|
189 |
-
"source": [
|
190 |
-
"## run"
|
191 |
-
]
|
192 |
-
},
|
193 |
-
{
|
194 |
-
"cell_type": "code",
|
195 |
-
"execution_count": 9,
|
196 |
-
"id": "914a471c-5d76-482b-a4f3-3c5eeebdd697",
|
197 |
-
"metadata": {},
|
198 |
-
"outputs": [],
|
199 |
-
"source": [
|
200 |
-
"from transformers import AutoModelForAudioClassification\n",
|
201 |
-
"import torch\n",
|
202 |
-
"\n",
|
203 |
-
"model = AutoModelForAudioClassification.from_pretrained(MODEL_NAME)\n",
|
204 |
-
"feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)\n",
|
205 |
-
"\n",
|
206 |
-
"preds = []\n",
|
207 |
-
"gts = []\n",
|
208 |
-
"for i in range(len(test_data)):\n",
|
209 |
-
" inputs = feature_extractor(test_data[i][\"audio\"][\"array\"], sampling_rate=sampling_rate, return_tensors=\"pt\")\n",
|
210 |
-
" with torch.no_grad():\n",
|
211 |
-
" logits = model(**inputs).logits\n",
|
212 |
-
" predicted_class_ids = torch.argmax(logits).item()\n",
|
213 |
-
" predicted_label = model.config.id2label[predicted_class_ids]\n",
|
214 |
-
" preds.append(predicted_label)\n",
|
215 |
-
" gts.append(model.config.id2label[test_data[i]['label']])"
|
216 |
-
]
|
217 |
-
},
|
218 |
-
{
|
219 |
-
"cell_type": "markdown",
|
220 |
-
"id": "4f1d5bab-4f88-4628-918e-d14b29c2143b",
|
221 |
-
"metadata": {},
|
222 |
-
"source": [
|
223 |
-
"## performance"
|
224 |
-
]
|
225 |
-
},
|
226 |
-
{
|
227 |
-
"cell_type": "code",
|
228 |
-
"execution_count": 10,
|
229 |
-
"id": "26e0c704-b5b6-4bf0-8b58-1e3615b76cb7",
|
230 |
-
"metadata": {},
|
231 |
-
"outputs": [
|
232 |
-
{
|
233 |
-
"name": "stdout",
|
234 |
-
"output_type": "stream",
|
235 |
-
"text": [
|
236 |
-
" precision recall f1-score support\n",
|
237 |
-
"\n",
|
238 |
-
" bark 0.75 0.67 0.71 9\n",
|
239 |
-
" growling 1.00 0.71 0.83 7\n",
|
240 |
-
" howl 0.86 0.86 0.86 7\n",
|
241 |
-
" panting 1.00 0.70 0.82 10\n",
|
242 |
-
" whimper 0.54 1.00 0.70 7\n",
|
243 |
-
"\n",
|
244 |
-
" accuracy 0.78 40\n",
|
245 |
-
" macro avg 0.83 0.79 0.78 40\n",
|
246 |
-
"weighted avg 0.84 0.78 0.78 40\n",
|
247 |
-
"\n"
|
248 |
-
]
|
249 |
-
}
|
250 |
-
],
|
251 |
-
"source": [
|
252 |
-
"from sklearn.metrics import classification_report\n",
|
253 |
-
"valid_performance = classification_report(gts, preds)\n",
|
254 |
-
"print(valid_performance)"
|
255 |
-
]
|
256 |
-
}
|
257 |
-
],
|
258 |
-
"metadata": {
|
259 |
-
"kernelspec": {
|
260 |
-
"display_name": "g3p8",
|
261 |
-
"language": "python",
|
262 |
-
"name": "g3p8"
|
263 |
-
},
|
264 |
-
"language_info": {
|
265 |
-
"codemirror_mode": {
|
266 |
-
"name": "ipython",
|
267 |
-
"version": 3
|
268 |
-
},
|
269 |
-
"file_extension": ".py",
|
270 |
-
"mimetype": "text/x-python",
|
271 |
-
"name": "python",
|
272 |
-
"nbconvert_exporter": "python",
|
273 |
-
"pygments_lexer": "ipython3",
|
274 |
-
"version": "3.7.9"
|
275 |
-
}
|
276 |
-
},
|
277 |
-
"nbformat": 4,
|
278 |
-
"nbformat_minor": 5
|
279 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.ipynb_checkpoints/eval_and_inference_lite_v1-checkpoint.ipynb
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "markdown",
|
5 |
-
"id": "544a588c-68ff-440f-be5c-389f1f02a0b7",
|
6 |
-
"metadata": {},
|
7 |
-
"source": [
|
8 |
-
"# example"
|
9 |
-
]
|
10 |
-
},
|
11 |
-
{
|
12 |
-
"cell_type": "code",
|
13 |
-
"execution_count": 1,
|
14 |
-
"id": "7ef8c97c-cefd-4905-8d63-af303c412d1a",
|
15 |
-
"metadata": {},
|
16 |
-
"outputs": [],
|
17 |
-
"source": [
|
18 |
-
"MODEL_NAME = \"gaepago-20-lite\"\n",
|
19 |
-
"DATASET_NAME = \"Gae8J/modeling_v1\""
|
20 |
-
]
|
21 |
-
},
|
22 |
-
{
|
23 |
-
"cell_type": "markdown",
|
24 |
-
"id": "044499ce-7821-4b59-9f4b-5971b6a24cce",
|
25 |
-
"metadata": {},
|
26 |
-
"source": [
|
27 |
-
"## load dataset (test data)"
|
28 |
-
]
|
29 |
-
},
|
30 |
-
{
|
31 |
-
"cell_type": "code",
|
32 |
-
"execution_count": 2,
|
33 |
-
"id": "e827e3bb-820d-46b3-b2e8-fdb97787bde1",
|
34 |
-
"metadata": {},
|
35 |
-
"outputs": [
|
36 |
-
{
|
37 |
-
"name": "stderr",
|
38 |
-
"output_type": "stream",
|
39 |
-
"text": [
|
40 |
-
"WARNING:datasets.builder:Found cached dataset parquet (/home/jovyan/.cache/huggingface/datasets/Gae8J___parquet/Gae8J--modeling_v1-b480c78c61a26816/0.0.0/2a3b91fbd88a2c90d1dbbb32b460cf621d31bd5b05b934492fdef7d8d6f236ec)\n"
|
41 |
-
]
|
42 |
-
},
|
43 |
-
{
|
44 |
-
"data": {
|
45 |
-
"application/vnd.jupyter.widget-view+json": {
|
46 |
-
"model_id": "4438f0b33464423b92fecc698c1935e5",
|
47 |
-
"version_major": 2,
|
48 |
-
"version_minor": 0
|
49 |
-
},
|
50 |
-
"text/plain": [
|
51 |
-
" 0%| | 0/3 [00:00<?, ?it/s]"
|
52 |
-
]
|
53 |
-
},
|
54 |
-
"metadata": {},
|
55 |
-
"output_type": "display_data"
|
56 |
-
}
|
57 |
-
],
|
58 |
-
"source": [
|
59 |
-
"from datasets import load_dataset, Audio\n",
|
60 |
-
"from transformers import AutoFeatureExtractor\n",
|
61 |
-
"dataset = load_dataset(DATASET_NAME)\n",
|
62 |
-
"dataset = dataset.cast_column(\"audio\", Audio(sampling_rate=16000))\n",
|
63 |
-
"test_data = dataset['test']\n",
|
64 |
-
"sampling_rate = test_data.features[\"audio\"].sampling_rate\n",
|
65 |
-
"feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)"
|
66 |
-
]
|
67 |
-
},
|
68 |
-
{
|
69 |
-
"cell_type": "code",
|
70 |
-
"execution_count": 7,
|
71 |
-
"id": "779c547a-7e27-4481-8a66-fd9900e41964",
|
72 |
-
"metadata": {},
|
73 |
-
"outputs": [],
|
74 |
-
"source": [
|
75 |
-
"from transformers import AutoConfig\n",
|
76 |
-
"config = AutoConfig.from_pretrained(MODEL_NAME)"
|
77 |
-
]
|
78 |
-
},
|
79 |
-
{
|
80 |
-
"cell_type": "code",
|
81 |
-
"execution_count": 3,
|
82 |
-
"id": "03659af7-3d90-4431-a4ea-a8d99e93602f",
|
83 |
-
"metadata": {},
|
84 |
-
"outputs": [],
|
85 |
-
"source": [
|
86 |
-
"import torch"
|
87 |
-
]
|
88 |
-
},
|
89 |
-
{
|
90 |
-
"cell_type": "code",
|
91 |
-
"execution_count": 4,
|
92 |
-
"id": "0f58cfcf-ba2d-45e4-b4e9-87df88e9dbad",
|
93 |
-
"metadata": {},
|
94 |
-
"outputs": [],
|
95 |
-
"source": [
|
96 |
-
"loaded_quantized_model = torch.jit.load(\"gaepago-20-lite/model_quant_int8.pt\")"
|
97 |
-
]
|
98 |
-
},
|
99 |
-
{
|
100 |
-
"cell_type": "markdown",
|
101 |
-
"id": "52212656-a3e9-4bd2-ac2d-427acb5795c6",
|
102 |
-
"metadata": {},
|
103 |
-
"source": [
|
104 |
-
"## ๋ชจ๋ธ๊ฒฐ๊ณผ"
|
105 |
-
]
|
106 |
-
},
|
107 |
-
{
|
108 |
-
"cell_type": "code",
|
109 |
-
"execution_count": 9,
|
110 |
-
"id": "3d4f5365-d6f1-4163-9c47-ce8c89e13884",
|
111 |
-
"metadata": {},
|
112 |
-
"outputs": [],
|
113 |
-
"source": [
|
114 |
-
"preds = []\n",
|
115 |
-
"gts = []\n",
|
116 |
-
"# quant_logits_list = []\n",
|
117 |
-
"for i in range(len(test_data)):\n",
|
118 |
-
" inputs = feature_extractor(test_data[i][\"audio\"][\"array\"], sampling_rate=sampling_rate, return_tensors=\"pt\")\n",
|
119 |
-
" with torch.no_grad():\n",
|
120 |
-
" logits = loaded_quantized_model(**inputs)['logits']\n",
|
121 |
-
"# quant_logits_list.append(logits)\n",
|
122 |
-
" predicted_class_ids = torch.argmax(logits).item()\n",
|
123 |
-
" predicted_label = config.id2label[predicted_class_ids]\n",
|
124 |
-
" preds.append(predicted_label)\n",
|
125 |
-
" gts.append(config.id2label[test_data[i]['label']])"
|
126 |
-
]
|
127 |
-
},
|
128 |
-
{
|
129 |
-
"cell_type": "code",
|
130 |
-
"execution_count": 10,
|
131 |
-
"id": "93b3c424-bab6-4774-915e-9e9f534f762d",
|
132 |
-
"metadata": {},
|
133 |
-
"outputs": [
|
134 |
-
{
|
135 |
-
"name": "stdout",
|
136 |
-
"output_type": "stream",
|
137 |
-
"text": [
|
138 |
-
" precision recall f1-score support\n",
|
139 |
-
"\n",
|
140 |
-
" bark 0.5556 0.6250 0.5882 8\n",
|
141 |
-
" growling 1.0000 0.8333 0.9091 6\n",
|
142 |
-
" howl 0.7500 0.8571 0.8000 7\n",
|
143 |
-
" panting 1.0000 0.8000 0.8889 10\n",
|
144 |
-
" whimper 0.3750 0.4286 0.4000 7\n",
|
145 |
-
"\n",
|
146 |
-
" accuracy 0.7105 38\n",
|
147 |
-
" macro avg 0.7361 0.7088 0.7172 38\n",
|
148 |
-
"weighted avg 0.7452 0.7105 0.7224 38\n",
|
149 |
-
"\n"
|
150 |
-
]
|
151 |
-
}
|
152 |
-
],
|
153 |
-
"source": [
|
154 |
-
"from sklearn.metrics import classification_report\n",
|
155 |
-
"test_performance = classification_report(gts, preds,digits=4)\n",
|
156 |
-
"print(test_performance)"
|
157 |
-
]
|
158 |
-
},
|
159 |
-
{
|
160 |
-
"cell_type": "code",
|
161 |
-
"execution_count": null,
|
162 |
-
"id": "99a3ea38-54c8-4aed-9bbf-12f98bf09dc5",
|
163 |
-
"metadata": {},
|
164 |
-
"outputs": [],
|
165 |
-
"source": []
|
166 |
-
}
|
167 |
-
],
|
168 |
-
"metadata": {
|
169 |
-
"kernelspec": {
|
170 |
-
"display_name": "g3p8",
|
171 |
-
"language": "python",
|
172 |
-
"name": "g3p8"
|
173 |
-
},
|
174 |
-
"language_info": {
|
175 |
-
"codemirror_mode": {
|
176 |
-
"name": "ipython",
|
177 |
-
"version": 3
|
178 |
-
},
|
179 |
-
"file_extension": ".py",
|
180 |
-
"mimetype": "text/x-python",
|
181 |
-
"name": "python",
|
182 |
-
"nbconvert_exporter": "python",
|
183 |
-
"pygments_lexer": "ipython3",
|
184 |
-
"version": "3.7.9"
|
185 |
-
}
|
186 |
-
},
|
187 |
-
"nbformat": 4,
|
188 |
-
"nbformat_minor": 5
|
189 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.ipynb_checkpoints/text_label-checkpoint.json
DELETED
@@ -1,528 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"bark": [
|
3 |
-
[
|
4 |
-
"๋๋ฌด ์ ๋์ ์ด์ฉ์ง?",
|
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 |
-
"์ฃผ๋ชฉํด์ค! ๋์!",
|
33 |
-
"๊ธ์ "
|
34 |
-
],
|
35 |
-
[
|
36 |
-
"๋์ด ์๊ฐ์ด์ผ, ๊ฐ์ด ๋์!",
|
37 |
-
"๊ธ์ "
|
38 |
-
],
|
39 |
-
[
|
40 |
-
"๋ค๊ฐ์ค์ง๋ง!",
|
41 |
-
"๋ถ์ "
|
42 |
-
],
|
43 |
-
[
|
44 |
-
"๋ญ๊ฐ ์ด์ํ ์๋ฆฌ ๋ค๋ ค!",
|
45 |
-
"๋ถ์ "
|
46 |
-
],
|
47 |
-
[
|
48 |
-
"๊ฒฝ๊ณํด, ๊ฒฝ๊ณํด!",
|
49 |
-
"๋ถ์ "
|
50 |
-
],
|
51 |
-
[
|
52 |
-
"์๋์ผ, ์๋์ผ!",
|
53 |
-
"๋ถ์ "
|
54 |
-
],
|
55 |
-
[
|
56 |
-
"๊ฑด๋ค์ง๋ง!!!!",
|
57 |
-
"๋ถ์ "
|
58 |
-
],
|
59 |
-
[
|
60 |
-
"๋ญ๊ฐ ๋ถ์ํด, ๋์์ค!",
|
61 |
-
"๋ถ์ "
|
62 |
-
],
|
63 |
-
[
|
64 |
-
"์ฃผ์ธ~ ๋ญํด~?",
|
65 |
-
"์ค๋ฆฝ"
|
66 |
-
],
|
67 |
-
[
|
68 |
-
"๋ฐ์ ๋ญ๊ฐ ์๋ ๊ฑฐ ๊ฐ์!",
|
69 |
-
"์ค๋ฆฝ"
|
70 |
-
],
|
71 |
-
[
|
72 |
-
"์ด๋ฆฌ ์๋ด!",
|
73 |
-
"์ค๋ฆฝ"
|
74 |
-
],
|
75 |
-
[
|
76 |
-
"๋ ๋ณด๊ณ ์์ด?",
|
77 |
-
"์ค๋ฆฝ"
|
78 |
-
],
|
79 |
-
[
|
80 |
-
"๋ฐ์ ๋ญ ์์ด?",
|
81 |
-
"์ค๋ฆฝ"
|
82 |
-
],
|
83 |
-
[
|
84 |
-
"์ด๊ฑฐ ๋ด๊บผ์ผ!",
|
85 |
-
"์ค๋ฆฝ"
|
86 |
-
],
|
87 |
-
[
|
88 |
-
"๋ฌผ ๋ง์ค๋, ๋ง์ค ๊ฒ ์ข ์ค.",
|
89 |
-
"์ค๋ฆฝ"
|
90 |
-
],
|
91 |
-
[
|
92 |
-
"๋ชฉ์ด ๋ง๋ผ, ๋ฌผ ์ข ์ค๋?",
|
93 |
-
"์ค๋ฆฝ"
|
94 |
-
]
|
95 |
-
],
|
96 |
-
"growling": [
|
97 |
-
[
|
98 |
-
"๋ ์ข ๋ด๋ฒ๋ ค ๋ฌ!",
|
99 |
-
"๋ถ์ "
|
100 |
-
],
|
101 |
-
[
|
102 |
-
"๋ ์ด์ ๋ค๊ฐ์ค์ง๋ง!",
|
103 |
-
"๋ถ์ "
|
104 |
-
],
|
105 |
-
[
|
106 |
-
"๋๋ฌด ๊น๋ค๋ก์!",
|
107 |
-
"๋ถ์ "
|
108 |
-
],
|
109 |
-
[
|
110 |
-
"๋ด๊ฐ ๊ฒฝ๊ณํ๊ณ ์์ด!",
|
111 |
-
"๋ถ์ "
|
112 |
-
],
|
113 |
-
[
|
114 |
-
"๋นจ๋ฆฌ ์ด๋ฆฌ ์!",
|
115 |
-
"๋ถ์ "
|
116 |
-
],
|
117 |
-
[
|
118 |
-
"๋ ๋๋ฌด ํ๋!",
|
119 |
-
"๋ถ์ "
|
120 |
-
],
|
121 |
-
[
|
122 |
-
"๋ ์ธ์ธ ์ค๋น๋์ด!",
|
123 |
-
"๋ถ์ "
|
124 |
-
],
|
125 |
-
[
|
126 |
-
"๊ทธ๋ง ์ข ํด!",
|
127 |
-
"๋ถ์ "
|
128 |
-
],
|
129 |
-
[
|
130 |
-
"๋ด๊ฒ ์ฅ๋์น์ง๋ง!",
|
131 |
-
"๋ถ์ "
|
132 |
-
],
|
133 |
-
[
|
134 |
-
"๋ ์ง๊ธ ๋๋ฌด ์ง์ฆ๋!",
|
135 |
-
"๋ถ์ "
|
136 |
-
],
|
137 |
-
[
|
138 |
-
"๋ ์ง๊ธ ์ ์ข์!",
|
139 |
-
"๋ถ์ "
|
140 |
-
],
|
141 |
-
[
|
142 |
-
"๋ค๊ฐ์ค์ง๋ง!",
|
143 |
-
"๋ถ์ "
|
144 |
-
],
|
145 |
-
[
|
146 |
-
"๋์๊ฒ ํ๋ ๊ฑฐ์ผ!",
|
147 |
-
"๋ถ์ "
|
148 |
-
],
|
149 |
-
[
|
150 |
-
"์ข ๋ฉ๋ฆฌ ๊ฐ!",
|
151 |
-
"๋ถ์ "
|
152 |
-
],
|
153 |
-
[
|
154 |
-
"๋ ์ธ์ฐ๋ ค๊ณ ์ค๋น๋์ด!",
|
155 |
-
"๋ถ์ "
|
156 |
-
],
|
157 |
-
[
|
158 |
-
"ํ๋ฒ ๋ ๊ฑด๋๋ฆฌ๋ฉด ๋ฌผ์ด๋ฒ๋ฆด๊ฑฐ์ผ!!!",
|
159 |
-
"๋ถ์ "
|
160 |
-
],
|
161 |
-
[
|
162 |
-
"๋ํํ
์ด๋ ๊ฒ ์ํ์ ์ผ๋ก ๋ค๊ฐ์ค์ง๋ง!",
|
163 |
-
"๋ถ์ "
|
164 |
-
],
|
165 |
-
[
|
166 |
-
"๋์ ์์ญ์ ์นจ๋ฒํ๋ฉด ์๋ผ! ์ดํดํด์ค!",
|
167 |
-
"๋ถ์ "
|
168 |
-
],
|
169 |
-
[
|
170 |
-
"๊ทธ๋ง ์ข ๊ท์ฐฎ๊ฒ ํด! ๋ด๊ฐ ๋ถ๋ช
ํ ๊ฒฝ๊ณ ํ์์!",
|
171 |
-
"๋ถ์ "
|
172 |
-
],
|
173 |
-
[
|
174 |
-
"๋ถํธํด, ๋ฌผ๋ฌ์์ค.",
|
175 |
-
"๋ถ์ "
|
176 |
-
],
|
177 |
-
[
|
178 |
-
"๊ฒฝ๊ณ ํ๋ ๊ฑฐ์ผ, ๊ฐ๊น์ด ์ค์ง ๋ง.",
|
179 |
-
"๋ถ์ "
|
180 |
-
],
|
181 |
-
[
|
182 |
-
"์ข ๋๋ฌด ๊ฐ๊น์, ๊ฑฐ๋ฆฌ ์ข ๋ฌ.",
|
183 |
-
"๋ถ์ "
|
184 |
-
],
|
185 |
-
[
|
186 |
-
"๋๋ฅผ ๋ฐฉํดํ์ง ๋ง, ์ ๊ฒฝ ์จ์ค.",
|
187 |
-
"๋ถ์ "
|
188 |
-
],
|
189 |
-
[
|
190 |
-
"๋ด๊ฐ ๋ถํธํด, ๊ฑฐ๋ฆฌ ์ข ๋๊ณ ์์ด.",
|
191 |
-
"๋ถ์ "
|
192 |
-
],
|
193 |
-
[
|
194 |
-
"๊ฐ๊น์ด ์ค์ง ๋ง.",
|
195 |
-
"๋ถ์ "
|
196 |
-
],
|
197 |
-
[
|
198 |
-
"๋๋ฅผ ๋ฐฉํดํ์ง ๋ง, ์กด์คํด์ค. Respect Me!!",
|
199 |
-
"๋ถ์ "
|
200 |
-
]
|
201 |
-
],
|
202 |
-
"howl": [
|
203 |
-
[
|
204 |
-
"๋ ์ฌ๊ธฐ์์ด, ๋ด์ค!",
|
205 |
-
"์ค๋ฆฝ"
|
206 |
-
],
|
207 |
-
[
|
208 |
-
"๋ ์ด๋ ๊ฐ์ด?!",
|
209 |
-
"์ค๋ฆฝ"
|
210 |
-
],
|
211 |
-
[
|
212 |
-
"๋ ๋๋ฌด ์ธ๋ก์!",
|
213 |
-
"์ค๋ฆฝ"
|
214 |
-
],
|
215 |
-
[
|
216 |
-
"์ด๋ฆฌ ์๋ด, ๋ ์๋ ๊ณณ์ผ๋ก!",
|
217 |
-
"์ค๋ฆฝ"
|
218 |
-
],
|
219 |
-
[
|
220 |
-
"๋ ์์ผ๋ฉด ๋๋ฌด ์ฌ์ฌํด!",
|
221 |
-
"์ค๋ฆฝ"
|
222 |
-
],
|
223 |
-
[
|
224 |
-
"๋๋ ๊ฐ์ด ๊ฐ๊ณ ์ถ์ด!",
|
225 |
-
"์ค๋ฆฝ"
|
226 |
-
],
|
227 |
-
[
|
228 |
-
"๋ ์ฌ์ฌํด",
|
229 |
-
"์ค๋ฆฝ"
|
230 |
-
],
|
231 |
-
[
|
232 |
-
"์ด๋์ผ? ๋ ์ฐพ์๋ด!",
|
233 |
-
"์ค๋ฆฝ"
|
234 |
-
],
|
235 |
-
[
|
236 |
-
"์ธ์ ์ค๋ ค๊ณ ๊ทธ๋?",
|
237 |
-
"์ค๋ฆฝ"
|
238 |
-
],
|
239 |
-
[
|
240 |
-
"๋๋ ์ฌ๊ธฐ ์๋๋ฐ!",
|
241 |
-
"์ค๋ฆฝ"
|
242 |
-
],
|
243 |
-
[
|
244 |
-
"๋นจ๋ฆฌ ๋์์์ค!",
|
245 |
-
"์ค๋ฆฝ"
|
246 |
-
],
|
247 |
-
[
|
248 |
-
"๋ ํผ์ ๋จ๊ฒจ๋์ง ๋ง!",
|
249 |
-
"์ค๋ฆฝ"
|
250 |
-
],
|
251 |
-
[
|
252 |
-
"๋ ์ฌ๊ธฐ์์ด!! ๋์ข ๋ด์ค!!!",
|
253 |
-
"์ค๋ฆฝ"
|
254 |
-
],
|
255 |
-
[
|
256 |
-
"๋ ์ ๋ณด๊ณ ์์ด? ๋ ๊ด์ฐฎ์?",
|
257 |
-
"์ค๋ฆฝ"
|
258 |
-
],
|
259 |
-
[
|
260 |
-
"์ฃผ์ธ, ๋ ์ข ์์์ค ์ ์์๊น?",
|
261 |
-
"์ค๋ฆฝ"
|
262 |
-
],
|
263 |
-
[
|
264 |
-
"์ธ๋ก์, ๋ณด๊ณ ์ถ์ด.",
|
265 |
-
"์ค๋ฆฝ"
|
266 |
-
],
|
267 |
-
[
|
268 |
-
"๋ค๋ฅธ ๊ฐ์์ง์ 'ํฉ์ฐฝ'ํ๊ณ ์ถ์ด.",
|
269 |
-
"์ค๋ฆฝ"
|
270 |
-
],
|
271 |
-
[
|
272 |
-
"๋๋ฅผ ๋ณด๊ณ ์ถ์ด, ์ธ์ ์?",
|
273 |
-
"์ค๋ฆฝ"
|
274 |
-
],
|
275 |
-
[
|
276 |
-
"๋ฌด์ธ๊ฐ ์๋ ค๊ณ ํ๋ ์ค์ด์ผ.",
|
277 |
-
"์ค๋ฆฝ"
|
278 |
-
],
|
279 |
-
[
|
280 |
-
"๋ค๋ฅธ ๊ฐ์์ง๋ค์ด๋ ๋
ธ๋ํ๊ณ ์ถ์ด.",
|
281 |
-
"๊ธ์ "
|
282 |
-
]
|
283 |
-
],
|
284 |
-
"panting": [
|
285 |
-
[
|
286 |
-
"๋์~ ์์ด์ปจ ์ผ์ค.",
|
287 |
-
"๋ถ์ "
|
288 |
-
],
|
289 |
-
[
|
290 |
-
"์ด๋ ํ ํด์ ์ค์ด์ผ.",
|
291 |
-
"์ค๋ฆฝ"
|
292 |
-
],
|
293 |
-
[
|
294 |
-
"์จ์ด ์ฐจ, ์ข ๋์์ค.",
|
295 |
-
"๋ถ์ "
|
296 |
-
],
|
297 |
-
[
|
298 |
-
"ํด์์ด ํ์ํด, ์ข ์ฌ์.",
|
299 |
-
"๋ถ์ "
|
300 |
-
],
|
301 |
-
[
|
302 |
-
"๋๋ฌด ๋์, ๋ฌผ ์ข ์ค๋?",
|
303 |
-
"๋ถ์ "
|
304 |
-
],
|
305 |
-
[
|
306 |
-
"๋๋ฌด ๋์, ๋ฐ๋ ์ข ์ฌ์.",
|
307 |
-
"๋ถ์ "
|
308 |
-
],
|
309 |
-
[
|
310 |
-
"ํ๋ค๊ฒ ์ด๋ํ์ด, ํด์ ์ข!",
|
311 |
-
"๋ถ์ "
|
312 |
-
],
|
313 |
-
[
|
314 |
-
"์จ์ด ์ฐจ, ์ฌ๋ ์๊ฐ์ด ํ์ํด.",
|
315 |
-
"๋ถ์ "
|
316 |
-
],
|
317 |
-
[
|
318 |
-
"ํด์์ด ํ์ํด, ์กฐ์ฉํ ์ข...",
|
319 |
-
"๋ถ์ "
|
320 |
-
],
|
321 |
-
[
|
322 |
-
"๋ฌผ ์ข ๋ง์๊ณ ์ถ์ด, ์ค๋?",
|
323 |
-
"์ค๋ฆฝ"
|
324 |
-
],
|
325 |
-
[
|
326 |
-
"๋ง์ด ๋ฐ์ด์ ํ๋ค์ด, ํด์์ด ํ์ํด.",
|
327 |
-
"๋ถ์ "
|
328 |
-
],
|
329 |
-
[
|
330 |
-
"ํด์์ด ํ์ํด, ์ข ๋ ์ฌ์.",
|
331 |
-
"์ค๋ฆฝ"
|
332 |
-
],
|
333 |
-
[
|
334 |
-
"๋๋ฌด ๋์์ ๋ฌผ ์ข ๋ง์๊ณ ์ถ์ด.",
|
335 |
-
"์ค๋ฆฝ"
|
336 |
-
],
|
337 |
-
[
|
338 |
-
"์ข ๋์ด ๏ฟฝ๏ฟฝ ๊ฐ์, ๋ฐ๋ ์ข ์ฌ๊ณ ์ถ์ด.",
|
339 |
-
"์ค๋ฆฝ"
|
340 |
-
],
|
341 |
-
[
|
342 |
-
"์ง๊ธ ์ข ์ด ์๊ฐ์ด ํ์ํด, ์ ์๋ง ๊ธฐ๋ค๋ ค.",
|
343 |
-
"์ค๋ฆฝ"
|
344 |
-
],
|
345 |
-
[
|
346 |
-
"์ง๊ธ ์ง์ ํ ์๊ฐ์ด ํ์ํด!!!",
|
347 |
-
"์ค๋ฆฝ"
|
348 |
-
],
|
349 |
-
[
|
350 |
-
"๋ ์ง๊ธ ๋๋ฌด ์ ๋",
|
351 |
-
"๊ธ์ "
|
352 |
-
],
|
353 |
-
[
|
354 |
-
"๋๋ ๋๋ฉด ๋ ์ฌ๋ฐ์ ๊ฒ ๊ฐ์",
|
355 |
-
"๊ธ์ "
|
356 |
-
],
|
357 |
-
[
|
358 |
-
"๋๋ ๋์ง ์์๋?",
|
359 |
-
"๊ธ์ "
|
360 |
-
],
|
361 |
-
[
|
362 |
-
"๋ฐ์ ๋๊ฐ๋ฉด ์ฌ๋ฏธ๋ ์ผ์ด ์์ ๊ฒ ๊ฐ์!",
|
363 |
-
"๊ธ์ "
|
364 |
-
],
|
365 |
-
[
|
366 |
-
"์ค๋์ ๋ฌด์จ ์ผ์ด ์์๊น? ์ข์ ์ผ์ด ์๊ธธ ๊ฒ ๊ฐ์!",
|
367 |
-
"๊ธ์ "
|
368 |
-
],
|
369 |
-
[
|
370 |
-
"์ธ์ ๋ชจ๋ ๊ฒ๋ค์ด ๋ฐ๊ฐ์~",
|
371 |
-
"๊ธ์ "
|
372 |
-
],
|
373 |
-
[
|
374 |
-
"๋๋ ์นํด์ง๊ณ ์ถ์ด~",
|
375 |
-
"๊ธ์ "
|
376 |
-
],
|
377 |
-
[
|
378 |
-
"์ค๋ ๊ธฐ๋ถ ์์ฃผ ๋์ด์ค~",
|
379 |
-
"๊ธ์ "
|
380 |
-
],
|
381 |
-
[
|
382 |
-
"์ธ์์์ ์ ์ผ ์ข์!!",
|
383 |
-
"๊ธ์ "
|
384 |
-
],
|
385 |
-
[
|
386 |
-
"๋ ์ง๊ธ ๊ธฐ๋ถ์ด๊ฐ ์ข์~",
|
387 |
-
"๊ธ์ "
|
388 |
-
],
|
389 |
-
[
|
390 |
-
"๋๋ ๋๊ณ ์ถ์ด~",
|
391 |
-
"๊ธ์ "
|
392 |
-
],
|
393 |
-
[
|
394 |
-
"์ค๋ ๋๊ฒ ํ๋ณตํ ํ๋ฃจ๋ค~",
|
395 |
-
"๊ธ์ "
|
396 |
-
],
|
397 |
-
[
|
398 |
-
"์ค๋ ๋ด ์์ผ์ธ๊ฐ? ๋๋ฌด ํ๋ณตํด><",
|
399 |
-
"๊ธ์ "
|
400 |
-
],
|
401 |
-
[
|
402 |
-
"๋ง๋์ ๋ฐ๊ฐ์",
|
403 |
-
"๊ธ์ "
|
404 |
-
],
|
405 |
-
[
|
406 |
-
"๋๋ ์ด๋ฆ์ด ๋ญ๋?",
|
407 |
-
"๊ธ์ "
|
408 |
-
],
|
409 |
-
[
|
410 |
-
"๋ ๋๊ฐ ์ข์!!",
|
411 |
-
"๊ธ์ "
|
412 |
-
],
|
413 |
-
[
|
414 |
-
"๋ ๋งค์ฐ ์ฌ๋ฐ์ด",
|
415 |
-
"๊ธ์ "
|
416 |
-
],
|
417 |
-
[
|
418 |
-
"๋๋ ๊ฐ์ด ๋๋ฌ ๋๊ฐ์",
|
419 |
-
"๊ธ์ "
|
420 |
-
]
|
421 |
-
],
|
422 |
-
"whimper": [
|
423 |
-
[
|
424 |
-
"๋ ๋๋ฌด ๋๋ ค์",
|
425 |
-
"๋ถ์ "
|
426 |
-
],
|
427 |
-
[
|
428 |
-
"๋ ์ง๊ธ ๋๋ฌด ์ธ๋ก์",
|
429 |
-
"๋ถ์ "
|
430 |
-
],
|
431 |
-
[
|
432 |
-
"๋ ๋๋ฌด ์ฌํผ",
|
433 |
-
"๋ถ์ "
|
434 |
-
],
|
435 |
-
[
|
436 |
-
"๋ ์ข ์์์ค",
|
437 |
-
"๋ถ์ "
|
438 |
-
],
|
439 |
-
[
|
440 |
-
"๋ ์ง๊ธ ๋๋ฌด ๋ถํธํด",
|
441 |
-
"๋ถ์ "
|
442 |
-
],
|
443 |
-
[
|
444 |
-
"๋ ๋๋ฌด ํผ๊ณคํด",
|
445 |
-
"๋ถ์ "
|
446 |
-
],
|
447 |
-
[
|
448 |
-
"์กฐ๊ธ๋ง ๋ ์์์ค",
|
449 |
-
"๋ถ์ "
|
450 |
-
],
|
451 |
-
[
|
452 |
-
"๋ ์ข ์๋กํด์ค",
|
453 |
-
"๋ถ์ "
|
454 |
-
],
|
455 |
-
[
|
456 |
-
"๋ ๊ธฐ๋ค๋ฆฌ๋ ์ค",
|
457 |
-
"๋ถ์ "
|
458 |
-
],
|
459 |
-
[
|
460 |
-
"์ธ๋ก์์ ๋๋ฌผ์ด ๋",
|
461 |
-
"๋ถ์ "
|
462 |
-
],
|
463 |
-
[
|
464 |
-
"๋ ์์ฒ๋ฐ์์ด, ๋๋ฌด ๋๋ ค์...ใ
ใ
กใ
",
|
465 |
-
"๋ถ์ "
|
466 |
-
],
|
467 |
-
[
|
468 |
-
"๋ ๋๋์ชใ
ใ
กใ
ํ๊ตฌํ๊ตฌ..",
|
469 |
-
"๋ถ์ "
|
470 |
-
],
|
471 |
-
[
|
472 |
-
"๋ฌด์
์... ์์์ฃ ~~~",
|
473 |
-
"๋ถ์ "
|
474 |
-
],
|
475 |
-
[
|
476 |
-
"๋๋ฌด ์ฌํผ์ ๋ง์ด ์ํ... ์์์ค...",
|
477 |
-
"๋ถ์ "
|
478 |
-
],
|
479 |
-
[
|
480 |
-
"๋ ๊ธฐ๋ถ์ด ๋๋ฌด ์ ์ข์... ์ด๋ป๊ฒ ํด์ค๋?",
|
481 |
-
"๋ถ์ "
|
482 |
-
],
|
483 |
-
[
|
484 |
-
"ํ...๋ฏธ์ํด...",
|
485 |
-
"๋ถ์ "
|
486 |
-
],
|
487 |
-
[
|
488 |
-
"๋ถ์ํด, ๊ณ์ ์์ด์ค.",
|
489 |
-
"๋ถ์ "
|
490 |
-
],
|
491 |
-
[
|
492 |
-
"๋ฐ์ผ๋ก ๋๊ฐ๊ณ ์ถ์ด.",
|
493 |
-
"์ค๋ฆฝ"
|
494 |
-
],
|
495 |
-
[
|
496 |
-
"๋ฏธ์ํด, ์ค์ํ์ด.",
|
497 |
-
"๋ถ์ "
|
498 |
-
],
|
499 |
-
[
|
500 |
-
"๋๋ฌด ์ฌํผ, ์๋ก ์ข ํด์ค.",
|
501 |
-
"๋ถ์ "
|
502 |
-
],
|
503 |
-
[
|
504 |
-
"์คํธ๋ ์ค ๋ฐ์์ด, ๋์์ค.",
|
505 |
-
"๋ถ์ "
|
506 |
-
],
|
507 |
-
[
|
508 |
-
"๋ด๊ฐ ๋ถ์ํด, ๋ถ์ด์์ด์ค.",
|
509 |
-
"๋ถ์ "
|
510 |
-
],
|
511 |
-
[
|
512 |
-
"๋๋ฌด ์ธ๋ก์, ์ ์ ์ ๋ณด์ฌ์ค.",
|
513 |
-
"๋ถ์ "
|
514 |
-
],
|
515 |
-
[
|
516 |
-
"์ฐ์ฑ
์ข ๊ฐ๊ณ ์ถ์ด.",
|
517 |
-
"์ค๋ฆฝ"
|
518 |
-
],
|
519 |
-
[
|
520 |
-
"์ ๋ง ์ฌํผ, ์์์ค.",
|
521 |
-
"๋ถ์ "
|
522 |
-
],
|
523 |
-
[
|
524 |
-
"์คํธ๋ ์ค๊ฐ ๋๋ฌด ๋ง์, ์์์ค.",
|
525 |
-
"๋ถ์ "
|
526 |
-
]
|
527 |
-
]
|
528 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.ipynb_checkpoints/text_mapping_example-checkpoint.ipynb
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 13,
|
6 |
-
"id": "8f925fb7-86ba-487f-ab85-88754d777860",
|
7 |
-
"metadata": {
|
8 |
-
"tags": []
|
9 |
-
},
|
10 |
-
"outputs": [],
|
11 |
-
"source": [
|
12 |
-
"import json\n",
|
13 |
-
"with open(\"text/text_label.json\",\"r\",encoding='utf-8') as f:\n",
|
14 |
-
" text_label = json.load(f)"
|
15 |
-
]
|
16 |
-
},
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"execution_count": 14,
|
20 |
-
"id": "d2c0a048-1db7-4236-9f26-539ed31d3d27",
|
21 |
-
"metadata": {
|
22 |
-
"tags": []
|
23 |
-
},
|
24 |
-
"outputs": [],
|
25 |
-
"source": [
|
26 |
-
"import random\n",
|
27 |
-
"random.seed(0)\n",
|
28 |
-
"def post_process(model_output,text_label):\n",
|
29 |
-
" text_list = text_label[model_output]\n",
|
30 |
-
" text,sent = random.sample(text_list,1)[0]\n",
|
31 |
-
" return {'label' : model_output,\n",
|
32 |
-
" 'text' : text,\n",
|
33 |
-
" 'sentiment' : sent}"
|
34 |
-
]
|
35 |
-
},
|
36 |
-
{
|
37 |
-
"cell_type": "code",
|
38 |
-
"execution_count": 15,
|
39 |
-
"id": "f8ca0ad8-bc0c-4766-8e13-fe093c5290df",
|
40 |
-
"metadata": {
|
41 |
-
"tags": []
|
42 |
-
},
|
43 |
-
"outputs": [
|
44 |
-
{
|
45 |
-
"data": {
|
46 |
-
"text/plain": [
|
47 |
-
"{'label': 'bark', 'text': '์๋์ผ, ์๋์ผ!', 'sentiment': '๋ถ์ '}"
|
48 |
-
]
|
49 |
-
},
|
50 |
-
"execution_count": 15,
|
51 |
-
"metadata": {},
|
52 |
-
"output_type": "execute_result"
|
53 |
-
}
|
54 |
-
],
|
55 |
-
"source": [
|
56 |
-
"model_output = 'bark'\n",
|
57 |
-
"post_process(model_output,text_label)"
|
58 |
-
]
|
59 |
-
},
|
60 |
-
{
|
61 |
-
"cell_type": "code",
|
62 |
-
"execution_count": null,
|
63 |
-
"id": "da690a64-4dea-4b2a-89c1-23ea8bad955c",
|
64 |
-
"metadata": {},
|
65 |
-
"outputs": [],
|
66 |
-
"source": []
|
67 |
-
}
|
68 |
-
],
|
69 |
-
"metadata": {
|
70 |
-
"kernelspec": {
|
71 |
-
"display_name": "Python 3 (ipykernel)",
|
72 |
-
"language": "python",
|
73 |
-
"name": "python3"
|
74 |
-
},
|
75 |
-
"language_info": {
|
76 |
-
"codemirror_mode": {
|
77 |
-
"name": "ipython",
|
78 |
-
"version": 3
|
79 |
-
},
|
80 |
-
"file_extension": ".py",
|
81 |
-
"mimetype": "text/x-python",
|
82 |
-
"name": "python",
|
83 |
-
"nbconvert_exporter": "python",
|
84 |
-
"pygments_lexer": "ipython3",
|
85 |
-
"version": "3.10.8"
|
86 |
-
}
|
87 |
-
},
|
88 |
-
"nbformat": 4,
|
89 |
-
"nbformat_minor": 5
|
90 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -7,11 +7,12 @@ from transformers import pipeline
|
|
7 |
from datasets import Dataset, Audio
|
8 |
import gradio as gr
|
9 |
import torch
|
10 |
-
|
|
|
11 |
# Set model & Dataset NM
|
12 |
MODEL_NAME = "Gae8J/gaepago-20"
|
13 |
DATASET_NAME = "Gae8J/modeling_v1"
|
14 |
-
|
15 |
# Import Model & feature extractor
|
16 |
# model = AutoModelForAudioClassification.from_pretrained(MODEL_NAME)
|
17 |
from transformers import AutoConfig
|
@@ -21,6 +22,9 @@ feature_extractor = AutoFeatureExtractor.from_pretrained(MODEL_NAME)
|
|
21 |
|
22 |
# ๋ชจ๋ธ cpu๋ก ๋ณ๊ฒฝํ์ฌ ์งํ
|
23 |
model.to("cpu")
|
|
|
|
|
|
|
24 |
|
25 |
# Gaepago Inference Model function
|
26 |
def gaepago_fn(tmp_audio_dir):
|
@@ -37,7 +41,10 @@ def gaepago_fn(tmp_audio_dir):
|
|
37 |
predicted_class_ids = torch.argmax(logits).item()
|
38 |
predicted_label = config.id2label[predicted_class_ids]
|
39 |
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
# Main
|
43 |
example_list = ["./sample/bark_sample.wav"
|
|
|
7 |
from datasets import Dataset, Audio
|
8 |
import gradio as gr
|
9 |
import torch
|
10 |
+
from utils.postprocess import text_mapping
|
11 |
+
import json
|
12 |
# Set model & Dataset NM
|
13 |
MODEL_NAME = "Gae8J/gaepago-20"
|
14 |
DATASET_NAME = "Gae8J/modeling_v1"
|
15 |
+
TEXT_LABEL = "text_label.json"
|
16 |
# Import Model & feature extractor
|
17 |
# model = AutoModelForAudioClassification.from_pretrained(MODEL_NAME)
|
18 |
from transformers import AutoConfig
|
|
|
22 |
|
23 |
# ๋ชจ๋ธ cpu๋ก ๋ณ๊ฒฝํ์ฌ ์งํ
|
24 |
model.to("cpu")
|
25 |
+
# TEXT LABEL ๋ถ๋ฌ์ค๊ธฐ
|
26 |
+
with open(TEXT_LABEL,"r",encoding='utf-8') as f:
|
27 |
+
text_label = json.load(f)
|
28 |
|
29 |
# Gaepago Inference Model function
|
30 |
def gaepago_fn(tmp_audio_dir):
|
|
|
41 |
predicted_class_ids = torch.argmax(logits).item()
|
42 |
predicted_label = config.id2label[predicted_class_ids]
|
43 |
|
44 |
+
# add postprocessing
|
45 |
+
## 1. text mapping
|
46 |
+
output = text_mapping(predicted_label,text_label)
|
47 |
+
return output
|
48 |
|
49 |
# Main
|
50 |
example_list = ["./sample/bark_sample.wav"
|
text_mapping_example.ipynb
CHANGED
@@ -82,7 +82,7 @@
|
|
82 |
"name": "python",
|
83 |
"nbconvert_exporter": "python",
|
84 |
"pygments_lexer": "ipython3",
|
85 |
-
"version": "3.8
|
86 |
}
|
87 |
},
|
88 |
"nbformat": 4,
|
|
|
82 |
"name": "python",
|
83 |
"nbconvert_exporter": "python",
|
84 |
"pygments_lexer": "ipython3",
|
85 |
+
"version": "3.10.8"
|
86 |
}
|
87 |
},
|
88 |
"nbformat": 4,
|
utils/__init__.py
ADDED
File without changes
|
utils/postprocess.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
|
3 |
+
def text_mapping(model_output,text_label):
|
4 |
+
text_list = text_label[model_output]
|
5 |
+
text,sent = random.sample(text_list,1)[0]
|
6 |
+
return {'label' : model_output,
|
7 |
+
'text' : text,
|
8 |
+
'sentiment' : sent}
|