Spaces:
Sleeping
Sleeping
quantumiracle-git
commited on
Commit
·
8db6229
1
Parent(s):
f18b79d
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import os
|
|
3 |
import random
|
4 |
import numpy as np
|
5 |
import gdown
|
|
|
|
|
6 |
|
7 |
from datasets import load_dataset
|
8 |
from hfserver import HuggingFaceDatasetSaver, HuggingFaceDatasetJSONSaver
|
@@ -32,7 +34,7 @@ def nan():
|
|
32 |
|
33 |
FORMAT = ['mp4', 'gif'][1]
|
34 |
|
35 |
-
def update(data_folder='videos'):
|
36 |
# data_folder='videos'
|
37 |
envs = parse_envs()
|
38 |
env_name = envs[random.randint(0, len(envs)-1)]
|
@@ -46,7 +48,18 @@ def update(data_folder='videos'):
|
|
46 |
selected_video_ids = np.random.choice(len(video_files), 2, replace=False)
|
47 |
left = video_files[selected_video_ids[0]]
|
48 |
right = video_files[selected_video_ids[1]]
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
return left, right
|
51 |
|
52 |
# def update(left, right):
|
@@ -112,7 +125,7 @@ def build_interface(iter=3, data_folder='./videos'):
|
|
112 |
callback.setup([user_choice, left, right], "flagged_data_points")
|
113 |
|
114 |
btn1.click(fn=replay, inputs=[left, right], outputs=[left, right])
|
115 |
-
btn2.click(fn=update, inputs=
|
116 |
|
117 |
# We can choose which components to flag -- in this case, we'll flag all of them
|
118 |
btn2.click(lambda *args: callback.flag(args), [user_choice, left, right], None, preprocess=False)
|
|
|
3 |
import random
|
4 |
import numpy as np
|
5 |
import gdown
|
6 |
+
from datetime import datetime
|
7 |
+
from csv import writer
|
8 |
|
9 |
from datasets import load_dataset
|
10 |
from hfserver import HuggingFaceDatasetSaver, HuggingFaceDatasetJSONSaver
|
|
|
34 |
|
35 |
FORMAT = ['mp4', 'gif'][1]
|
36 |
|
37 |
+
def update(user_choice, data_folder='videos'):
|
38 |
# data_folder='videos'
|
39 |
envs = parse_envs()
|
40 |
env_name = envs[random.randint(0, len(envs)-1)]
|
|
|
48 |
selected_video_ids = np.random.choice(len(video_files), 2, replace=False)
|
49 |
left = video_files[selected_video_ids[0]]
|
50 |
right = video_files[selected_video_ids[1]]
|
51 |
+
|
52 |
+
# log
|
53 |
+
current_time = datetime.datetime.now()
|
54 |
+
time_stamp = current_time.timestamp()
|
55 |
+
date_time = datetime.fromtimestamp(time_stamp)
|
56 |
+
str_date_time = date_time.strftime("%d-%m-%Y-%H-%M-%S")
|
57 |
+
print(env_name, user_choice, left, right, str_date_time)
|
58 |
+
info = [env_name, user_choice, left, right]
|
59 |
+
with open('data.csv', 'a') as file:
|
60 |
+
writer_object = writer(file)
|
61 |
+
writer_object.writerow(info)
|
62 |
+
file.close()
|
63 |
return left, right
|
64 |
|
65 |
# def update(left, right):
|
|
|
125 |
callback.setup([user_choice, left, right], "flagged_data_points")
|
126 |
|
127 |
btn1.click(fn=replay, inputs=[left, right], outputs=[left, right])
|
128 |
+
btn2.click(fn=update, inputs=[user_choice], outputs=[left, right])
|
129 |
|
130 |
# We can choose which components to flag -- in this case, we'll flag all of them
|
131 |
btn2.click(lambda *args: callback.flag(args), [user_choice, left, right], None, preprocess=False)
|