Skip to content

Commit

Permalink
inr_net support idx 0
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterouZh committed Mar 20, 2022
1 parent f01ede6 commit f6beb5b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exp/cips3d_inversion/configs/ffhq_diffcam_exp_v6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ G_cfg_3D2D: &G_cfg_3D2D
app_block_end_index: 1
inr_block_end_index: 9
inr_detach: true

# inr_block_end_index: 0
# inr_detach: false

G_kwargs: &G_kwargs
psi: 1.
Expand Down
65 changes: 65 additions & 0 deletions exp/tests/test_cips3d_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,71 @@ class Testing_ffhq_diffcam_exp_v6(unittest.TestCase):
"""

def test__plot_fid(self):
"""
export PYTHONPATH=.:./tl2_lib
python -c "from exp.tests.test_cips3d import Testing_ffhq_exp;\
Testing_ffhq_exp().test__plot_fid()"
"""
if 'CUDA_VISIBLE_DEVICES' not in os.environ:
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
if 'TIME_STR' not in os.environ:
os.environ['TIME_STR'] = '0'
from tl2.launch.launch_utils import \
(get_command_and_outdir, setup_outdir_and_yaml, get_append_cmd_str, start_cmd_run)

command, outdir = get_command_and_outdir(self, func_name=sys._getframe().f_code.co_name, file=__file__)
argv_str = f"""
--tl_config_file none
--tl_command none
--tl_outdir {outdir}
"""
args = setup_outdir_and_yaml(argv_str)
outdir = args.tl_outdir

from tl2.proj.matplot.plot_results import PlotResults
import collections
import pickle

outfigure = os.path.join(outdir, 'FID.jpg')
default_dicts = collections.OrderedDict()
show_max = []

bucket_root = "/home/ma-user/work/ZhouPeng/bucket_3690/"

FID_r64 = collections.defaultdict(dict)
title = 'FID_r64'
log_file = 'textdir/eval.ma0.FID.log'
dd = eval(title)
dd[f'{bucket_root}/results/CIPS-3D/ffhq_diffcam_exp_v6/train_ffhq-20220320_230250_444'] = \
{'20220320_230250_444-ffhq_r64-gpu.4x8-block_idx.8_1_9-inr_detach.T': f"{log_file}", }
dd[f'{bucket_root}/results/CIPS-3D/ffhq_diffcam_exp_v6/train_ffhq-20220320_230358_278'] = \
{'20220320_230358_278-ffhq_r64-gpu.4x8-block_idx.8_1_9-inr_detach.T': f"{log_file}", }
dd[f'{bucket_root}/results/CIPS-3D/ffhq_diffcam_exp_v6/train_ffhq-20220320_231604_470'] = \
{'20220320_231604_470-ffhq_r64-gpu.4x8-block_idx.8_1_9-inr_detach.F': f"{log_file}", }
dd[f'{bucket_root}/results/CIPS-3D/ffhq_diffcam_exp_v6/train_ffhq-20220320_235103_022'] = \
{'20220320_235103_022-ffhq_r64-gpu.4x8-block_idx.8_1_0-inr_detach.F': f"{log_file}", }

dd['properties'] = {'title': title,
# 'xlim': [0, 3000000],
# 'ylim': [0, 100]
}
default_dicts[title] = dd
show_max.append(False)

plotobs = PlotResults()
label2datas_list = plotobs.plot_defaultdicts(
outfigure=outfigure, default_dicts=default_dicts, show_max=show_max, figsize_wh=(16, 7.2))
print(f'Save to {outfigure}.')

saved_data = '__'.join(outdir.split('/')[-2:])
saved_data = f"{outdir}/{saved_data}.pkl"
with open(saved_data, 'wb') as f:
pickle.dump(label2datas_list, f)
print(f"Save data to {saved_data}")
pass

def test__build_generator(self, debug=True):
"""
Usage:
Expand Down

0 comments on commit f6beb5b

Please sign in to comment.