diff --git a/docs/cli.html b/docs/cli.html index 41095a0..79c654a 100644 --- a/docs/cli.html +++ b/docs/cli.html @@ -95,20 +95,6 @@
download
-download
VWORDS = [1_000]
-N_IMGS = 15_000
-N_FRAMES_TO_KEEP = [1]
+# N_IMGS = 15_000
+# N_FRAMES_TO_KEEP = [1]
FPS = 30
-out_path = Path("/tf/main/tango_reproduction_package/outputs")
-art_path = Path("/tf/main/tango_reproduction_package/artifacts")
+out_path = Path("/tf/main/data/output")
+art_path = Path("/tf/main/data/tango_reproduction_package/artifacts")
vis_model = "SimCLR"
-vid_ds = VideoDataset.from_path(
- art_path/"videos", fr = FPS
-).label_from_paths()
+# vid_ds = VideoDataset.from_path(
+# art_path/"videos", fr = FPS
+# ).label_from_paths()
-_generate_vis_results(vid_ds, out_path, art_path, vis_model)
+# _generate_vis_results(vid_ds, out_path, art_path, vis_model)
download
N_FRAMES_TO_KEEP = [1, 5]
-_generate_txt_results(vid_ds, out_path, art_path, vis_model)
+_generate_txt_results(None, out_path, art_path, vis_model)
download
convert_results_format<
get_info_to_rankin
tango_combined
-dl_ranking_path = path/'outputs/user_rankings_weighted_all/all_rankings.csv'
-ir_rankings_path = path/'models/tango_txt/tango_txt_rankings/all_rankings.json'
-settings_path = path/'outputs/evaluation_settings'
+# ir_rankings_path = path/'models/tango_txt/tango_txt_rankings/all_rankings.json'
+# settings_path = path/'outputs/evaluation_settings'
-tango_combined(dl_ranking_path, ir_rankings_path, settings_path)
+# tango_combined(dl_ranking_path, ir_rankings_path, settings_path)
@@ -279,6 +278,86 @@ tango_combined
+
+
+BEST_DL_MODELS= [
+ "SIFT-10000vw-1ftk-bovw_weighted_lcs",
+ "SimCLR-1000vw-5ftk-bovw", "SimCLR-5000vw-5ftk-bovw_lcs",
+ "SimCLR-5000vw-5ftk-bovw_weighted_lcs", "SimCLR-1000vw-5ftk-bovw_weighted_lcs"
+]
+BEST_IR_MODELS = [
+ "ocr+ir-1ftk-all_text", "ocr+ir-5ftk-all_text",
+ "ocr+ir-5ftk-unique_frames", "ocr+ir-5ftk-unique_words"
+]
+
+BEST_MODEL_CONFIGS = {
+ "SimCLR": "SimCLR-1000vw-5ftk-bovw",
+ "SIFT": "SIFT-10000vw-1ftk-bovw_weighted_lcs",
+ "OCR+IR": "ocr+ir-5-all_text"
+}
+
+
+
+
+
+
+
+ {% endraw %}
+
+ {% raw %}
+
+
+
+
+
+
+out_path = Path("/tf/main/data/output")
+art_path = Path("/tf/main/data/downloads/tango_reproduction_package/artifacts")
+
+combo_out_path = out_path/"combined"
+dl_ranking_path = out_path/"user_rankings_weighted_all"/"all_rankings.csv"
+txt_path = art_path/"models"/"OCR+IR"
+ir_rankings_path = txt_path/"tango_txt_rankings"/"all_rankings.json"
+settings_path = out_path/"evaluation_settings"
+
+tango_combined(combo_out_path, dl_ranking_path, ir_rankings_path, settings_path, BEST_DL_MODELS, BEST_IR_MODELS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% endraw %}
+
+ {% raw %}
+
+
+
+
from nbdev.export import notebook2script
@@ -289,6 +368,29 @@ tango_combined
+
+
+
+
+
+
+
+
+
+
{% endraw %}
diff --git a/two_to_tango/cli.py b/two_to_tango/cli.py
index 86ad397..fc17390 100644
--- a/two_to_tango/cli.py
+++ b/two_to_tango/cli.py
@@ -77,13 +77,12 @@ def download(
BEST_MODEL_CONFIGS = {
"SimCLR": "SimCLR-1000vw-5ftk-bovw",
"SIFT": "SIFT-10000vw-1ftk-bovw_weighted_lcs",
- "OCR+IR": "ocr+ir-5-all_text"
+ "OCR+IR": "ocr+ir-5ftk-all_text"
}
# Cell
def _generate_vis_results(vid_ds, out_path, art_path, vis_model):
if vis_model == "SimCLR":
- vis_model = "M01"
simclr = SimCLRModel.load_from_checkpoint(
checkpoint_path = str(
art_path/"models"/"SimCLR"/"checkpointepoch=98.ckpt"
@@ -92,7 +91,6 @@ def _generate_vis_results(vid_ds, out_path, art_path, vis_model):
model = SimCLRExtractor(simclr)
sim_func = simclr_frame_sim
else:
- vis_model = "M00"
model = SIFTExtractor(cv2.xfeatures2d.SIFT_create(nfeatures = 10))
sim_func = sift_frame_sim
diff --git a/two_to_tango/combo.py b/two_to_tango/combo.py
index 02aea2c..82c4199 100644
--- a/two_to_tango/combo.py
+++ b/two_to_tango/combo.py
@@ -116,6 +116,7 @@ def convert_results_format(sim_path, settings_path, out_path, models):
vwords = file_tokens[3]
frames_per_sec = file_tokens[4]
+ ftk = file_tokens[5]
model_similarities = pickle.load(open(sim_file, 'rb'))
@@ -126,6 +127,7 @@ def convert_results_format(sim_path, settings_path, out_path, models):
"model": model,
"vwords": vwords,
"fps": frames_per_sec,
+ "ftk": ftk,
"technique": technique
}
@@ -177,7 +179,10 @@ def get_info_to_ranking_results(ranking, ranking_results, run, dl_model, ir_mode
return ranking_info, ranking_results
# Cell
-def tango_combined(out_path, dl_rankings_path, ir_rankings_path, settings_path, dl_models, ir_models):
+def tango_combined(
+ out_path, dl_rankings_path, ir_rankings_path,
+ settings_path, dl_models, ir_models
+):
# all_data
results_out_path = out_path/"tango_comb_results"
rankings_out_path = out_path/"tango_comb_rankings"
@@ -199,11 +204,11 @@ def tango_combined(out_path, dl_rankings_path, ir_rankings_path, settings_path,
settings = load_settings(settings_path)
dl_rankings = read_json_line_by_line(dl_rankings_path)
- dl_rankings_by_config = group_dict(dl_rankings, lambda rec: (rec['model'], rec['vwords'], rec['fps'],
+ dl_rankings_by_config = group_dict(dl_rankings, lambda rec: (rec['model'], rec['vwords'], rec['ftk'],
rec['technique'],))
ir_rankings = read_json(ir_rankings_path)
- ir_rankings_by_config = group_dict(ir_rankings, lambda rec: (rec['model'], rec['fps'],
+ ir_rankings_by_config = group_dict(ir_rankings, lambda rec: (rec['model'], rec['fps'] + "ftk",
rec['technique'],))
# best_dl_models = [
@@ -226,9 +231,8 @@ def tango_combined(out_path, dl_rankings_path, ir_rankings_path, settings_path,
dl_models = list(filter(lambda rec: "-".join([rec[0], rec[1], rec[2], rec[3]]) in dl_models,
dl_rankings_by_config.keys()))
- ir_models = list(filter(lambda rec: "-".join([rec[0], "", rec[1] + "ftk", rec[2]]) in ir_models,
+ ir_models = list(filter(lambda rec: "-".join([rec[0], rec[1], rec[2]]) in ir_models,
ir_rankings_by_config.keys()))
-
# run combinations
start_time = time.time()
@@ -242,7 +246,7 @@ def tango_combined(out_path, dl_rankings_path, ir_rankings_path, settings_path,
print(dl_model, ir_model)
- app_for_comb = ir_model_apps_for_comb["-".join([ir_model[1] + "ftk", ir_model[2]])]
+ app_for_comb = ir_model_apps_for_comb["-".join([ir_model[1], ir_model[2]])]
for setting in settings_to_run:
dl_runs = group_dict(dl_mod_rankings[setting], lambda rec: rec["run_id"])
diff --git a/two_to_tango/prep.py b/two_to_tango/prep.py
index fe5676a..7c52511 100644
--- a/two_to_tango/prep.py
+++ b/two_to_tango/prep.py
@@ -275,6 +275,7 @@ def get_all_texts(vid_ds, out_path, fps):
frames_text = sorted(frames_text, key=lambda t: t["f"])
+ video_name = video_name.replace("_fixed_30", "")
out_file = os.path.join(video_output_path, video_name + '.json')
write_json_line_by_line(frames_text, out_file)
@@ -260,11 +260,10 @@
@@ -233,7 +233,7 @@