Created
October 9, 2019 13:25
-
-
Save s-c-p/3965464e0e460b82d26bd6624d9fdf0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import trunklucator | |
import json | |
#You can change this format in frontend part. | |
#Current format - (label text, returning value, key code for shortcut) | |
META = {"buttons":[('Cat (A)', 1, 65), ('Dog (X)', 0, 88), ('Skip (Enter)', -1, 13)]} | |
sys_stdin = [ | |
'{"html":"<img src=\\"/data/10005.jpg\\">", "file":"10005.jpg"}', | |
'{"html":"<img src=\\"/data/10006.jpg\\">", "file":"10006.jpg"}', | |
'{"html":"<img src=\\"/data/10038.jpg\\">", "file":"10038.jpg"}', | |
'{"html":"<img src=\\"/data/10039.jpg\\">", "file":"10039.jpg"}', | |
'{"html":"<img src=\\"/data/10082.jpg\\">", "file":"10082.jpg"}', | |
'{"html":"<img src=\\"/data/10083.jpg\\">", "file":"10083.jpg"}', | |
'{"html":"<img src=\\"/data/10127.jpg\\">", "file":"10127.jpg"}', | |
'{"html":"<img src=\\"/data/10128.jpg\\">", "file":"10128.jpg"}', | |
'{"html":"<img src=\\"/data/10172.jpg\\">", "file":"10172.jpg"}', | |
'{"html":"<img src=\\"/data/10173.jpg\\">", "file":"10173.jpg"}' | |
] | |
with trunklucator.WebUI(data_dir="./data") as tru: # start http server in background | |
for data in map(json.loads, sys_stdin): #read json data from standart input | |
y = tru.ask(data, META) #<- wait for user action on web page | |
print("{}".format(json.dumps({"file":data["file"], "is_cat": y}))) #output result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment