mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 14:24:40 -07:00
Adds zoom, keypress bindings
This commit is contained in:
parent
37edc6226c
commit
3e7117b049
3 changed files with 59 additions and 12 deletions
|
@ -58,6 +58,16 @@ def create_flask_app(s2c, c2s, s2flask, args):
|
|||
send(c2s, 'change_history_range')
|
||||
return '', 204
|
||||
|
||||
@app.route('/zoom_prev', methods=['POST'])
|
||||
def zoom_prev():
|
||||
send(c2s, 'zoom_prev')
|
||||
return '', 204
|
||||
|
||||
@app.route('/zoom_next', methods=['POST'])
|
||||
def zoom_next():
|
||||
send(c2s, 'zoom_next')
|
||||
return '', 204
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
|
|
@ -9,34 +9,63 @@
|
|||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('button#save').click(function() {
|
||||
function save() {
|
||||
$.post("{{ url_for('save') }}");
|
||||
});
|
||||
}
|
||||
|
||||
$('button#exit').click(function() {
|
||||
function exit() {
|
||||
$.post("{{ url_for('exit') }}");
|
||||
});
|
||||
}
|
||||
|
||||
$('button#update').click(function() {
|
||||
function update() {
|
||||
$.post("{{ url_for('update') }}");
|
||||
});
|
||||
}
|
||||
|
||||
$('button#next_preview').click(function() {
|
||||
function next_preview() {
|
||||
$.post("{{ url_for('next_preview') }}");
|
||||
}
|
||||
|
||||
function change_history_range() {
|
||||
$.post("{{ url_for('change_history_range') }}");
|
||||
}
|
||||
|
||||
function zoom_prev() {
|
||||
$.post("{{ url_for('zoom_prev') }}");
|
||||
}
|
||||
|
||||
function zoom_next() {
|
||||
$.post("{{ url_for('zoom_next') }}");
|
||||
}
|
||||
|
||||
$(document).keypress(function (event) {
|
||||
switch (event.key) {
|
||||
case "s" : save(); break;
|
||||
case "Enter" : exit(); break;
|
||||
case "p" : update(); break;
|
||||
case " " : next_preview(); break;
|
||||
case "l" : change_history_range(); break;
|
||||
case "-" : zoom_prev(); break;
|
||||
case "=" : zoom_next(); break;
|
||||
}
|
||||
// console.log('kp:', event);
|
||||
});
|
||||
|
||||
$('button#change_history_range').click(function() {
|
||||
$.post("{{ url_for('change_history_range') }}");
|
||||
});
|
||||
$('button#save').click(save);
|
||||
$('button#exit').click(exit);
|
||||
$('button#update').click(update);
|
||||
$('button#next_preview').click(next_preview);
|
||||
$('button#change_history_range').click(change_history_range);
|
||||
$('button#zoom_prev').click(zoom_prev);
|
||||
$('button#zoom_next').click(zoom_next);
|
||||
|
||||
const socket = io.connect('http://' + document.domain + ':' + location.port);
|
||||
socket.on('preview', function(msg) {
|
||||
console.log(new Date(), '- new preview -', msg);
|
||||
console.log(msg);
|
||||
$('img#preview').attr("src", "{{ url_for('preview_image') }}?q=" + new Date().getTime());
|
||||
});
|
||||
|
||||
socket.on('loss', function(loss_string) {
|
||||
console.log(new Date(), '- loss string -', loss_string);
|
||||
console.log(loss_string);
|
||||
$('h2#loss').html(loss_string);
|
||||
});
|
||||
});
|
||||
|
@ -51,6 +80,8 @@
|
|||
<button class='btn btn-default' id='update'>Update</button>
|
||||
<button class='btn btn-default' id='next_preview'>Next preview</button>
|
||||
<button class='btn btn-default' id='change_history_range'>Change History Range</button>
|
||||
<button class='btn btn-default' id='zoom_prev'>Zoom -</button>
|
||||
<button class='btn btn-default' id='zoom_next'>Zoom +</button>
|
||||
</div>
|
||||
<img id='preview' src="{{ url_for('preview_image') }}">
|
||||
</body>
|
||||
|
|
|
@ -357,6 +357,12 @@ def main(args, device_args):
|
|||
elif op == 'close':
|
||||
s2c.put({'op': 'close'})
|
||||
break
|
||||
elif op == 'zoom_prev':
|
||||
zoom = zoom.prev()
|
||||
update_preview = True
|
||||
elif op == 'zoom_next':
|
||||
zoom = zoom.next()
|
||||
update_preview = True
|
||||
|
||||
if update_preview:
|
||||
update_preview = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue