Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
YuhangSong committed Jun 24, 2017
2 parents 2d2b821 + aa10d7c commit cc88391
Show file tree
Hide file tree
Showing 29 changed files with 147 additions and 59 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified MeanOverlap.py
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified README.md~
100644 → 100755
Empty file.
Empty file modified TCPsocket_client.py
100644 → 100755
Empty file.
Empty file modified TCPsocket_server.py
100644 → 100755
Empty file.
Empty file modified _config.yml
100644 → 100755
Empty file.
Empty file modified a3c.py
100644 → 100755
Empty file.
Empty file modified cc.py
100644 → 100755
Empty file.
22 changes: 7 additions & 15 deletions config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,8 @@
'''
Description: set your log dir to store results data
'''
<<<<<<< HEAD
basic_log_dir = project+"_40"
log_dir = "run_off_line"

'''
Description: cluster config
'''
cluster_current = 1
cluster_main = cluster_current
=======
basic_log_dir = project+"_50"
log_dir = "run_on_line_baseline_keep"
>>>>>>> f8fd87735638d6287f819ea5854597177a39c6ca
log_dir = "run_off_line_on_vr"

'''
Description: set model structure
Expand Down Expand Up @@ -112,7 +101,7 @@
Description: select data_base you are running on
Availible: vr, vr_new
'''
data_base = 'vr_new'
data_base = 'vr'

'''
Description: select mode
Expand Down Expand Up @@ -147,7 +136,7 @@

'''config for log cc'''
relative_predicted_fixation_num = 1.0
relative_log_cc_interval = 1.0
relative_log_cc_interval = 0.5

'''
Description: config env
Expand Down Expand Up @@ -261,9 +250,13 @@
if data_base is 'vr_new':
from f_game_dic import f_game_dic_new_all
game_dic = f_game_dic_new_all # specific game dic
elif data_base is 'vr':
from f_game_dic import f_game_dic_all
game_dic = f_game_dic_all # specific game dic
my_sigma = (11.75+13.78)/2
import math
sigma_half_fov = 51.0 / (math.sqrt(-2.0*math.log(0.5)))
check_worker_done_time = 2
if mode is 'off_line' or mode is 'data_processor':
'''off line run all video together, should constrain the game_dic'''
if num_workers_one_run_max is not -1:
Expand All @@ -278,7 +271,6 @@
num_subjects = 58
worker_done_signal_dir = 'temp/worker_done_signal_dir/'
worker_done_signal_file = 'worker_done_signal.npz'
check_worker_done_time = 60

if debugging is True:
status = "temp_run"
Expand Down
Empty file modified consistence_result.txt
100644 → 100755
Empty file.
Empty file modified envs.py
100644 → 100755
Empty file.
23 changes: 23 additions & 0 deletions envs_li.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def __init__(self, env_id, task, subject=None, summary_writer=None):

# self.terminate_this_worker()

# self.max_cc = self.env_id_num
# self.write_best_cc()
# print(s)

def get_observation(self):

'''interface to get view'''
Expand Down Expand Up @@ -436,6 +440,8 @@ def log_thread_reset(self):
for step_i in range(self.step_total):

'''generate predicted salmap'''
print(len(self.agent_result_stack))
print(self.step_total)
temp = np.asarray(self.agent_result_stack)[:,step_i]
temp = np.sum(temp,axis=0)
temp = temp / np.max(temp)
Expand All @@ -451,6 +457,7 @@ def log_thread_reset(self):
self.max_cc = self.cur_cc
self.heatmaps_of_max_cc = heatmaps_on_step_i

'''log'''
from config import final_log_dir
record_dir = final_log_dir+'ff_best_heatmaps/'+self.env_id+'/'
subprocess.call(["rm", "-r", record_dir])
Expand All @@ -460,6 +467,22 @@ def log_thread_reset(self):
path=record_dir,
name=str(step_i))

self.write_best_cc()

def write_best_cc(self):
from config import final_log_dir
record_dir = final_log_dir+'ff_best_cc/'+self.env_id+'/'
while True:
try:
subprocess.call(["rm", "-r", record_dir])
subprocess.call(["mkdir", "-p", record_dir])
np.savez(record_dir+'best_cc.npz',
best_cc=[self.max_cc])
break
except Exception, e:
print(str(Exception)+": "+str(e))
time.sleep(1)

def step(self, action, v):

'''these will be returned, but not sure to updated'''
Expand Down
Empty file modified experience_server.py
100644 → 100755
Empty file.
39 changes: 37 additions & 2 deletions f_game_dic.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,43 @@
Description: game dic for f
'''
f_game_dic_all=[
'A380',
'AcerPredator',
'Pokemon',
'Gliding',
'Parachuting',
'RollerCoaster',
'Skiing',
'CS',
'Dota2',
'GalaxyOnFire',
'LOL',
'MC',
'BTSRun',
# 'Graffiti',
# 'KasabianLive',
# 'LetsNotBeAloneTonight',
# 'Antarctic',
# 'BlueWorld',
# 'Dubai',
# 'Egypt',
# 'StarryPolar',
# 'A380',
# 'CandyCarnival',
# 'MercedesBenz',
# 'RingMan',
# 'RioOlympics',
# 'Help',
# 'IRobot',
# 'Predator',
# 'ProjectSoul',
# 'AirShow',
# 'DrivingInAlps',
# 'F5Fighter',
# 'HondaF1',
# 'Rally',
# 'AcerPredator',
# 'BFG',
# 'CMLauncher',
# 'Cryogenian',
]
f_game_dic_new_all=[
'A380',
Expand Down
Empty file modified g_game_dic.py
100644 → 100755
Empty file.
Empty file modified kill.py
100644 → 100755
Empty file.
Empty file modified model.py
100644 → 100755
Empty file.
Empty file modified move_view_lib.py
100644 → 100755
Empty file.
Empty file modified move_view_lib_new.py
100644 → 100755
Empty file.
Empty file modified read_yuv.py
100644 → 100755
Empty file.
Empty file modified socket_client.py
100644 → 100755
Empty file.
Empty file modified socket_server.py
100644 → 100755
Empty file.
Empty file modified socket_struct.py
100644 → 100755
Empty file.
Empty file modified suppor_lib.py
100644 → 100755
Empty file.
122 changes: 80 additions & 42 deletions train.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,32 @@ def kill_a_pair_of_ps_worker_windows(session,game,subject):
'''excute cmds'''
os.system("\n".join(cmds))

def check_best_cc():

best_cc_dic = {}

for i in range(len(config.game_dic)):

env_id = config.game_dic[i]

from config import final_log_dir
record_dir = final_log_dir+'ff_best_cc/'+env_id+'/'

try:
best_cc_dic[env_id] = np.load(record_dir+'best_cc.npz')['best_cc'][0]
except Exception, e:
pass
# print(str(Exception)+": "+str(e))

if len(best_cc_dic) is 0:
return

best_cc_dic=sorted(best_cc_dic.items(), key=lambda e:e[1], reverse=True)

print('=======================sorted cc==========================')
for i in range(len(best_cc_dic)):
print(best_cc_dic[i][0]+'\t'+str(best_cc_dic[i][1]))

def run():

args = parser.parse_args()
Expand All @@ -181,63 +207,75 @@ def run():
os.system("\n".join(cmds))

from config import project, mode
if (project is 'f') and (mode is 'on_line'):
if project is 'f':

'''auto worker starter'''
if mode is 'on_line':

'''init position recorder'''
worker_running = config.num_workers_one_run # this is fake to start the run
game_i_at=0
subject_i_at=0
'''auto worker starter'''

'''detecting'''
while True:
'''init position recorder'''
worker_running = config.num_workers_one_run # this is fake to start the run
game_i_at=0
subject_i_at=0

# print('checking if any worker done')
'''detecting'''
while True:

from config import worker_done_signal_dir, worker_done_signal_file
'''load done_sinal_dic'''
# print('checking if any worker done')

'''use try except to avoid file_io_conflict'''
from time import sleep
while True:
try:
done_sinal_dic = np.load(worker_done_signal_dir+worker_done_signal_file)['done_sinal_dic']
from config import worker_done_signal_dir, worker_done_signal_file
'''load done_sinal_dic'''

break
except Exception, e:
print(str(Exception)+": "+str(e))
sleep(1)
'''use try except to avoid file_io_conflict'''
from time import sleep
while True:
try:
done_sinal_dic = np.load(worker_done_signal_dir+worker_done_signal_file)['done_sinal_dic']

'''clear the done_sinal_dic'''
while True:
try:
np.savez(worker_done_signal_dir+worker_done_signal_file,
done_sinal_dic=[[-1,-1]])
break
except Exception, e:
print(str(Exception)+": "+str(e))
sleep(1)
break
except Exception, e:
print(str(Exception)+": "+str(e))
sleep(1)

'''clear the done_sinal_dic'''
while True:
try:
np.savez(worker_done_signal_dir+worker_done_signal_file,
done_sinal_dic=[[-1,-1]])
break
except Exception, e:
print(str(Exception)+": "+str(e))
sleep(1)



'''scan done_sinal_dic, kill windows according to done_sinal_dic'''
for i in range(np.shape(done_sinal_dic)[0]):
'''scan done_sinal_dic, kill windows according to done_sinal_dic'''
for i in range(np.shape(done_sinal_dic)[0]):

'''if done_sinal_dic signal is -1, it is putted in by the control and it is invalid'''
if done_sinal_dic[i][0] < 0:
continue
'''if done_sinal_dic signal is -1, it is putted in by the control and it is invalid'''
if done_sinal_dic[i][0] < 0:
continue

'''kill_a_pair_of_ps_worker_windows'''
kill_a_pair_of_ps_worker_windows(session,done_sinal_dic[i][0],done_sinal_dic[i][1])
'''refresh the worker_running'''
worker_running -= 1
'''kill_a_pair_of_ps_worker_windows'''
kill_a_pair_of_ps_worker_windows(session,done_sinal_dic[i][0],done_sinal_dic[i][1])
'''refresh the worker_running'''
worker_running -= 1

'''refresh to see if any thing need to create'''
worker_running, game_i_at, subject_i_at = create_tmux_commands_auto(session, config.final_log_dir, worker_running, game_i_at, subject_i_at)

'''sleep for we do not need to detecting very frequent'''
time.sleep(config.check_worker_done_time)

if mode is 'off_line':

'''detecting'''
while True:

'''refresh to see if any thing need to create'''
worker_running, game_i_at, subject_i_at = create_tmux_commands_auto(session, config.final_log_dir, worker_running, game_i_at, subject_i_at)
check_best_cc()

'''sleep for we do not need to detecting very frequent'''
time.sleep(config.check_worker_done_time)
'''sleep for we do not need to detecting very frequent'''
time.sleep(config.check_worker_done_time)


if __name__ == "__main__":
Expand Down
Empty file modified vrplayer.py
100644 → 100755
Empty file.
Empty file modified worker.py
100644 → 100755
Empty file.

0 comments on commit cc88391

Please sign in to comment.