File size: 5,076 Bytes
29792f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
{% extends "base.html" %}
{% block content %}
<h1>Survey #{{signature}}</h1>
{% if success %}
<p class="success"> Your ratings have been saved!
You have been moved to the next random seed, if you want
to keep rating more samples. </p>
{% endif %}
{% if already_filled %}
<p class="warning"> You already rated those samples in the past,
    filling this form will override your previous ratings.
</p>
{% endif %}
<p>Welcome <span class='special'>{{session['user']}}</span> to the survey <span class='special'>#{{signature}}</span>.
Go to <a href="{{url_for('results', signature=signature)}}">the result page</a> to check the results. Go to <a href="{{url_for('index')}}">the home page</a> to start a new survey.
</p>

{% for error in errors %}
<p class="error">{{error}}</p>
{% endfor %}

{% if not blind %}
<p>Base config is: <span class="xp_name">{{ref_name}}</span></p>
<p>The following experiments are compared:</p>
<ul>
    {% for experiment in experiments %}
    <li><span class='special'>{{experiment.xp.sig}}</span> ({{experiment.epoch}} epochs): <span class="xp_name">{{experiment.name}}</span></li>
    {% endfor %}
</ul>
{% else %}
<p>This is a blind experiment, the order of all XPs is shuffled with every sample.</p>
{% endif %}
<p>The current random seed is {{seed}}. You can change it with the following form, and also update blind/non blind.
</p>
<form method="get" action="" class="simple_form">
    <input type="number" name="seed" value="{{seed}}">
    <label>Blind?
    <input type="checkbox" name="blind" {% if blind %} checked {% endif %}> </label>
    <label>Exclude unprompted?
    <input type="checkbox" name="exclude_unprompted" {% if exclude_unprompted %} checked {% endif %}> </label>
    <label>Exclude prompted?
    <input type="checkbox" name="exclude_prompted" {% if exclude_prompted %} checked {% endif %}> </label>
    <label>Max epoch?
    <input type="text" name="max_epoch" value="{{max_epoch}}"> </label>
    <input type="submit" value="Update">
</form>

<h2>Samples</h2>
<div class="survey">
<form method="post" action="{{url_for('survey', signature=signature, blind='true' if blind else 'false', exclude_prompted='true' if exclude_prompted else 'false', exclude_unprompted='true' if exclude_unprompted else 'false', seed=seed, max_epoch=max_epoch)}}" class="simple_form">
{% for id in model_ids %}
    <div class="track">
    <h4>{{id}}</h4>
    {% for model in models_by_id[id] %}
        {% if loop.index == 1 and model.is_prompted %}
            <section class="prompt">
            <p>Prompt is </p>
                <audio controls>
                    <source src="{{url_for('audio', path=model.sample.prompt.path)}}" type="audio/mp3">
                </audio>
            <p>Ground truth is </p>
                <audio controls>
                    <source src="{{url_for('audio', path=model.sample.prompt.ground_truth_path)}}" type="audio/mp3">
                </audio>
            </section>
        {% endif %}
        {% for err in model['errors'] %}
            <p class="error">{{err}}</p>
        {% endfor %}
        <section class="model">
        {% if not blind %}
            <p class="special">{{model.xp.sig}}:</p>
        {% endif %}
        <audio controls>
                <source src="{{url_for('audio', path=model.sample.path)}}" type="audio/mp3">
            Your browser does not support the audio element.
        </audio>
        <p>Rating:</p>
        <section class="ratings" id="ratings-{{model.model_id}}">
            {% for rating in ratings %}
            <span class="rating rating_{{rating}} {% if rating == model.rating %}rating_selected{% endif %}"
                    data-target="{{model.model_id}}" data-rating="{{rating}}" onclick="updateNote(this)">{{rating}}</span>
            {% endfor %}
            <input type="hidden" name="{{model.model_id}}" id="{{model.model_id}}" value="{{model.rating}}">
        </section>
        </p>
        </section>
    {% endfor %}
        </div>
        <hr>
{% endfor %}
    <button type="submit" class="submit-big">
        Submit evaluations
    </button>
<form>
</div>
<script>
function updateNote(node) {
    var target = node.getAttribute('data-target');
    var rating = node.getAttribute('data-rating');
    var field = document.getElementById(target);
    field.value = rating;
    node.classList.add('rating_selected');

    var parent = document.getElementById('ratings-' + target);
    for (const other of parent.childNodes) {
        if (other.tagName === 'SPAN' && other.classList.contains('rating_selected') && other !== node) {
            other.classList.remove('rating_selected');
        }
    }
}

function setupCallback(elem, elems) {
  elem.addEventListener("play", function () {
    for (var other of elems) {
      if (other !== elem) {
        other.pause();
        // other.currentTime = 0.;
      }
    }
  });
}

document.addEventListener('DOMContentLoaded', function () {
  var elems = document.body.getElementsByTagName("audio");
  for (var elem of elems) {
    setupCallback(elem, elems);
  }
});
</script>
{% endblock %}