-
Notifications
You must be signed in to change notification settings - Fork 1
/
populate.py
80 lines (51 loc) · 2.19 KB
/
populate.py
1
2
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
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cmulab.settings')
import django
django.setup()
from rest_framework.request import Request
from rest_framework.test import APIRequestFactory
factory = APIRequestFactory()
request = factory.get('/')
serializer_context = {
'request': Request(request),
}
# Add a couple of models
from annotator.models import Mlmodel
from annotator.serializers import MlmodelSerializer
model1=Mlmodel(name="VAD_model", modelTrainingSpec="python silence.py < {input} > {output}", status='ready', tags=Mlmodel.VAD)
model1.save()
model2=Mlmodel(name="transcription", modelTrainingSpec="require: pytorch; python transcribe.py < {input} {model} > {output}", status='ready', tags=Mlmodel.TRANSCRIPTION)
model2.save()
model3=Mlmodel(name="transcription2", modelTrainingSpec="require: dynet; python transcribe.py < {input} {model} > {output}", status='training', tags=Mlmodel.TRANSCRIPTION)
model3.save()
# Add some corpora
from annotator.models import Corpus
from annotator.serializers import CorpusSerializer
corpus1=Corpus(name="mboshi")
corpus1.save()
corpus2=Corpus(name="griko")
corpus2.save()
# Add some segments
from annotator.models import Segment
from annotator.serializers import SegmentSerializer
segment1=Segment(name="s1", corpus=corpus1)
segment1.save()
segment2=Segment(name="s2", corpus=corpus2)
segment2.save()
segment3=Segment(name="s3", corpus=corpus2)
segment3.save()
segment4=Segment(name="s4", corpus=corpus2)
segment4.save()
# Add annotations
from annotator.models import TextAnnotation
from annotator.serializers import TextAnnotationSerializer
annot=TextAnnotation(field_name="location", segment=segment2, text="Calimera", status=TextAnnotation.CORRECT)
annot.save()
annot=TextAnnotation(field_name="location", segment=segment3, text="Martano", status=TextAnnotation.CORRECT)
annot.save()
from annotator.models import SpanTextAnnotation
from annotator.serializers import SpanTextAnnotationSerializer
annot=SpanTextAnnotation(field_name="phonemes", segment=segment2, text="c", start=0.01, end=0.05, status=TextAnnotation.GENERATED)
annot.save()
annot=SpanTextAnnotation(field_name="phonemes", segment=segment2, text="c", start=0.05, end=0.12)
annot.save()