Skip to content

Commit 278eaf5

Browse files
committed
Fix spacy 2
1 parent 0fb0d66 commit 278eaf5

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

label_studio_ml/examples/nemo_asr/test_api.py

+1-43
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,7 @@ def client():
2727
def test_predict(client):
2828
request = json.loads('{"tasks": [{"id": 102651352, "data": {"audio": "https://htx-pub.s3.amazonaws.com/datasets/audio/f2bjrop1.1.wav"}, "meta": {}, "created_at": "2024-04-08T15:52:07.473205Z", "updated_at": "2024-04-08T15:52:07.473210Z", "is_labeled": false, "overlap": 1, "inner_id": 2, "total_annotations": 0, "cancelled_annotations": 0, "total_predictions": 0, "comment_count": 0, "unresolved_comment_count": 0, "last_comment_updated_at": null, "project": 62075, "updated_by": null, "file_upload": 1430391, "comment_authors": [], "annotations": [], "predictions": []}], "project": "62075.1712591487", "label_config": "<View>\\n <Audio name=\\"audio\\" value=\\"$audio\\" zoom=\\"true\\" hotkey=\\"ctrl+enter\\" />\\n <Header value=\\"Provide Transcription\\" />\\n <TextArea name=\\"transcription\\" toName=\\"audio\\"\\n rows=\\"4\\" editable=\\"true\\" maxSubmissions=\\"1\\" />\\n</View>", "params": {"login": null, "password": null, "context": null}}')
2929

30-
expected_response = {
31-
"results": [
32-
{
33-
"model_version": "SpacyMLBackend-v0.0.1",
34-
"result": [
35-
{
36-
"from_name": "ner_tags",
37-
"to_name": "text",
38-
"type": "labels",
39-
"value": {
40-
"end": 10,
41-
"labels": ["PERSON"],
42-
"start": 0,
43-
"text": "Katy Perry"
44-
}
45-
},
46-
{
47-
"from_name": "ner_tags",
48-
"to_name": "text",
49-
"type": "labels",
50-
"value": {
51-
"end": 23,
52-
"labels": ["ORG"],
53-
"start": 15,
54-
"text": "Pharrell"
55-
}
56-
},
57-
{
58-
"from_name": "ner_tags",
59-
"to_name": "text",
60-
"type": "labels",
61-
"value": {
62-
"end": 83,
63-
"labels": ["PRODUCT"],
64-
"start": 47,
65-
"text": "Apple Watches http://t.co/k6k3SdwShP"
66-
}
67-
}
68-
],
69-
"score": 0.0
70-
}
71-
]
72-
}
30+
expected_response = json.loads('{"results":[{"model_version":"NemoASR-v0.0.1","result":[{"from_name":"transcription","to_name":"audio","type":"textarea","value":{"text":["ffected to be named in march it may be the most important appointment governor michael dukakis makes during the remainder of his administration and one of the toughest s w b ar as murgr menikovi"]}}],"score":1.0}]}\n')
7331

7432
response = client.post('/predict', data=json.dumps(request), content_type='application/json')
7533
assert response.status_code == 200

label_studio_ml/examples/spacy/test_api.py

+45-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,50 @@ def client():
1313

1414

1515
def test_predict(client):
16+
expected_response = {
17+
"results": [
18+
{
19+
"model_version": "SpacyMLBackend-v0.0.1",
20+
"result": [
21+
{
22+
"from_name": "ner_tags",
23+
"to_name": "text",
24+
"type": "labels",
25+
"value": {
26+
"end": 10,
27+
"labels": ["PERSON"],
28+
"start": 0,
29+
"text": "Katy Perry"
30+
}
31+
},
32+
{
33+
"from_name": "ner_tags",
34+
"to_name": "text",
35+
"type": "labels",
36+
"value": {
37+
"end": 23,
38+
"labels": ["ORG"],
39+
"start": 15,
40+
"text": "Pharrell"
41+
}
42+
},
43+
{
44+
"from_name": "ner_tags",
45+
"to_name": "text",
46+
"type": "labels",
47+
"value": {
48+
"end": 83,
49+
"labels": ["PRODUCT"],
50+
"start": 47,
51+
"text": "Apple Watches http://t.co/k6k3SdwShP"
52+
}
53+
}
54+
],
55+
"score": 0.0
56+
}
57+
]
58+
}
59+
1660
response = client.post('/predict', json=json.loads('{"tasks": [{"id": 1428, "data": {"text": "Katy Perry and Pharrell have the same taste in Apple Watches http://t.co/k6k3SdwShP"}, "meta": {}, "created_at": "2024-03-20T20:50:22.955810Z", "updated_at": "2024-03-20T20:50:22.955819Z", "is_labeled": false, "overlap": 1, "inner_id": 18, "total_annotations": 0, "cancelled_annotations": 0, "total_predictions": 0, "comment_count": 0, "unresolved_comment_count": 0, "last_comment_updated_at": null, "project": 6, "updated_by": null, "file_upload": 8, "comment_authors": [], "annotations": [], "predictions": []}], "project": "6.1710967805", "label_config": "<View>\\n <Labels name=\\"ner_tags\\" toName=\\"text\\">\\n <Label value=\\"label_1\\" background=\\"#FFA39E\\"/>\\n <Label value=\\"label_2\\" background=\\"#D4380D\\"/>\\n <Label value=\\"label_3\\" background=\\"#FFC069\\"/>\\n </Labels>\\n <Text name=\\"text\\" value=\\"$text\\"/>\\n</View>", "params": {"login": null, "password": null, "context": null}}'))
1761
assert response.status_code == 200
18-
assert response.json == json.loads('{"results":[{"model_version":"SpacyMLBackend-v0.0.1","result":[{"from_name":"ner_tags","to_name":"text","type":"labels","value":{"end":10,"labels":["PERSON"],"start":0,"text":"Katy Perry"}},{"from_name":"ner_tags","to_name":"text","type":"labels","value":{"end":23,"labels":["ORG"],"start":15,"text":"Pharrell"}},{"from_name":"ner_tags","to_name":"text","type":"labels","value":{"end":60,"labels":["ORG"],"start":47,"text":"Apple Watches"}}],"score":0.0}]}\n')
62+
assert response.json == expected_response

0 commit comments

Comments
 (0)