update spaces
Browse files- .gitattributes +1 -0
- README.md +9 -0
- pipeline.py +1 -1
- requirements.txt +4 -1
- tests/test_api.ipynb +21 -10
.gitattributes
CHANGED
@@ -38,3 +38,4 @@ model/190703-214543/loss.log filter=lfs diff=lfs merge=lfs -text
|
|
38 |
model/190703-214543/model_95.ckpt.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
39 |
model/190703-214543/model_95.ckpt.index filter=lfs diff=lfs merge=lfs -text
|
40 |
model/190703-214543/model_95.ckpt.meta filter=lfs diff=lfs merge=lfs -text
|
|
|
|
38 |
model/190703-214543/model_95.ckpt.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
39 |
model/190703-214543/model_95.ckpt.index filter=lfs diff=lfs merge=lfs -text
|
40 |
model/190703-214543/model_95.ckpt.meta filter=lfs diff=lfs merge=lfs -text
|
41 |
+
tests/test.mseed filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
tags:
|
3 |
- text-classification
|
4 |
library_name: generic
|
|
|
1 |
---
|
2 |
+
title: Test Model
|
3 |
+
emoji: 🐨
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.15.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
tags:
|
12 |
- text-classification
|
13 |
library_name: generic
|
pipeline.py
CHANGED
@@ -32,7 +32,7 @@ class PreTrainedPipeline():
|
|
32 |
self.sess = sess
|
33 |
self.model = model
|
34 |
|
35 |
-
def __call__(self, inputs: str) -> List[List[Dict[str, float]]]:
|
36 |
"""
|
37 |
Args:
|
38 |
inputs (:obj:`str`):
|
|
|
32 |
self.sess = sess
|
33 |
self.model = model
|
34 |
|
35 |
+
def __call__(self, inputs: str, **kwargs) -> List[List[Dict[str, float]]]:
|
36 |
"""
|
37 |
Args:
|
38 |
inputs (:obj:`str`):
|
requirements.txt
CHANGED
@@ -1 +1,4 @@
|
|
1 |
-
tensorflow
|
|
|
|
|
|
|
|
1 |
+
tensorflow
|
2 |
+
numpy
|
3 |
+
obspy
|
4 |
+
pandas
|
tests/test_api.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
@@ -12,7 +12,7 @@
|
|
12 |
},
|
13 |
{
|
14 |
"cell_type": "code",
|
15 |
-
"execution_count":
|
16 |
"metadata": {},
|
17 |
"outputs": [
|
18 |
{
|
@@ -31,14 +31,23 @@
|
|
31 |
},
|
32 |
{
|
33 |
"cell_type": "code",
|
34 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
"metadata": {},
|
36 |
"outputs": [
|
37 |
{
|
38 |
"name": "stdout",
|
39 |
"output_type": "stream",
|
40 |
"text": [
|
41 |
-
"[[{'
|
42 |
]
|
43 |
}
|
44 |
],
|
@@ -47,8 +56,8 @@
|
|
47 |
"import numpy as np\n",
|
48 |
"import json\n",
|
49 |
"\n",
|
50 |
-
"API_URL = \"https://api-inference.huggingface.co/models/zhuwq/PhaseNet\"\n",
|
51 |
-
"
|
52 |
"headers = {\"Authorization\": \"Bearer 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\"}\n",
|
53 |
"\n",
|
54 |
"def query(payload):\n",
|
@@ -57,11 +66,13 @@
|
|
57 |
" # return json.loads(response.content.decode(\"utf-8\"))\n",
|
58 |
"\n",
|
59 |
"# array = np.random.rand(10, 3).tolist()\n",
|
60 |
-
"inputs = json.dumps(array.tolist())\n",
|
61 |
"data = {\n",
|
62 |
-
"\t
|
63 |
-
" \"
|
64 |
-
" \"
|
|
|
|
|
65 |
"}\n",
|
66 |
"\n",
|
67 |
"output = query(data)\n",
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 12,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
12 |
},
|
13 |
{
|
14 |
"cell_type": "code",
|
15 |
+
"execution_count": 13,
|
16 |
"metadata": {},
|
17 |
"outputs": [
|
18 |
{
|
|
|
31 |
},
|
32 |
{
|
33 |
"cell_type": "code",
|
34 |
+
"execution_count": 15,
|
35 |
+
"metadata": {},
|
36 |
+
"outputs": [],
|
37 |
+
"source": [
|
38 |
+
"waveform.write(\"test.mseed\", format=\"MSEED\")"
|
39 |
+
]
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"cell_type": "code",
|
43 |
+
"execution_count": 9,
|
44 |
"metadata": {},
|
45 |
"outputs": [
|
46 |
{
|
47 |
"name": "stdout",
|
48 |
"output_type": "stream",
|
49 |
"text": [
|
50 |
+
"[[{'label': 'I like you. I love you', 'score': 0.2}, {'args': []}, {}]]\n"
|
51 |
]
|
52 |
}
|
53 |
],
|
|
|
56 |
"import numpy as np\n",
|
57 |
"import json\n",
|
58 |
"\n",
|
59 |
+
"# API_URL = \"https://api-inference.huggingface.co/models/zhuwq/PhaseNet\"\n",
|
60 |
+
"API_URL = \"https://api-inference.huggingface.co/models/zhuwq/test-model\"\n",
|
61 |
"headers = {\"Authorization\": \"Bearer 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\"}\n",
|
62 |
"\n",
|
63 |
"def query(payload):\n",
|
|
|
66 |
" # return json.loads(response.content.decode(\"utf-8\"))\n",
|
67 |
"\n",
|
68 |
"# array = np.random.rand(10, 3).tolist()\n",
|
69 |
+
"# inputs = json.dumps(array.tolist())\n",
|
70 |
"data = {\n",
|
71 |
+
"\t\"inputs\": \"I like you. I love you\",\n",
|
72 |
+
" \"arg\": 1,\n",
|
73 |
+
" # \"inputs\": inputs,\n",
|
74 |
+
" \"options\": {\"wait_for_model\": True},\n",
|
75 |
+
" \"parameters\": {\"max_length\": 500}\n",
|
76 |
"}\n",
|
77 |
"\n",
|
78 |
"output = query(data)\n",
|