Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small PR allowing the animate CLI to take in 2 models #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clip_eval/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def animate_embeddings():
from clip_eval.plotting.animation import build_animation, save_animation_to_file

# Error could be localised better
defns = select_existing_embedding_definitions(by_dataset=True)
defns = select_existing_embedding_definitions(by_dataset=True, select_pair=True)
assert len(defns) == 2, "Please select exactly two models to make animation"
def1 = max(defns, key=lambda d: int(d.model == "clip"))
def2 = defns[0] if defns[0] != def1 else defns[1]
Expand Down
7 changes: 5 additions & 2 deletions clip_eval/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ def _by_dataset(defs: list[EmbeddingDefinition] | dict[str, list[EmbeddingDefini

def select_existing_embedding_definitions(
by_dataset: bool = False,
select_pair: bool = False,
) -> list[EmbeddingDefinition]:
defs = read_all_cached_embeddings(as_list=True)

if by_dataset:
# Subset definitions to specific dataset
defs = _by_dataset(defs)

return _do_embedding_definition_selection(defs)
if select_pair:
return _do_embedding_definition_selection(defs) + _do_embedding_definition_selection(defs)
else:
return _do_embedding_definition_selection(defs)


def select_from_all_embedding_definitions(
Expand Down
1 change: 0 additions & 1 deletion clip_eval/plotting/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def rotate_to_target(source: N2Array, destination: N2Array):

rot, *_ = R.align_vectors(source, destination, return_sensitivity=True)
out = source @ rot.as_matrix()
print(out[:, 2].std())
return out[:, :2]


Expand Down
Loading