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

Moved torch_cluster import to prevent hard dependency #21

Merged
merged 2 commits into from
Sep 15, 2024
Merged
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 spine/utils/ghost.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np
import torch
from torch_cluster import knn
from scipy.spatial.distance import cdist

from spine.data import TensorBatch
Expand Down Expand Up @@ -179,6 +178,7 @@ def adapt_labels(clust_label, seg_label, seg_pred, ghost_pred=None,
"""
# Define operations on the basis of the input type
if torch.is_tensor(seg_label):
from torch_cluster import knn # TODO: not PEP8 compliant, refactor
dtype, device = clust_label.dtype, clust_label.device
where, cat, argmax = torch.where, torch.cat, torch.amax
ones = lambda x: torch.ones(x, dtype=dtype, device=device)
Expand Down
Loading