Skip to content

Commit

Permalink
merging bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alishbaimran committed Oct 18, 2024
1 parent 99d43cf commit 6996bbd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions viscy/data/hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import tempfile
import warnings
from pathlib import Path
from typing import Callable, Literal, Sequence

Expand All @@ -25,8 +26,12 @@
from torch.utils.data import DataLoader, Dataset

from viscy.data.typing import ChannelMap, DictTransform, HCSStackIndex, NormMeta, Sample
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message="To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).")

warnings.filterwarnings(
"ignore",
category=UserWarning,
message="To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).",
)
_logger = logging.getLogger("lightning.pytorch")


Expand Down Expand Up @@ -551,7 +556,7 @@ def predict_dataloader(self):
self.predict_dataset,
batch_size=self.batch_size,
num_workers=self.num_workers,
shuffle=False,
shuffle=False,
)

def _fit_transform(self) -> tuple[Compose, Compose]:
Expand Down
3 changes: 1 addition & 2 deletions viscy/representation/contrastive.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import warnings
from typing import Literal

import timm
import torch.nn as nn
from torch import Tensor

from viscy.unet.networks.unext2 import StemDepthtoChannels
import warnings

warnings.filterwarnings("ignore", category=UserWarning, module="torch")

Expand Down Expand Up @@ -84,7 +84,6 @@ def __init__(
)
# Append modified encoder.
self.encoder = encoder
self.intermediate_projection = intermediate_projection
# Append modified projection head.
self.projection = projection

Expand Down
6 changes: 3 additions & 3 deletions viscy/representation/evalutation/clustering.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Methods for evaluating clustering performance."""

import numpy as np
from sklearn.cluster import DBSCAN
from sklearn.metrics import (
accuracy_score,
adjusted_rand_score,
normalized_mutual_info_score,
)
from sklearn.neighbors import KNeighborsClassifier
from sklearn.mixture import GaussianMixture
import numpy as np
from sklearn.neighbors import KNeighborsClassifier


class GMMClustering:
def __init__(self, features_data, n_clusters_range=np.arange(2, 10)):
Expand Down Expand Up @@ -78,7 +79,6 @@ def predict_clusters(self):
return cluster_labels



def knn_accuracy(embeddings, annotations, k=5):
"""
Evaluate the k-NN classification accuracy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def compute_pca(embedding_dataset, n_components=None, normalize_features=False):

return PCA_features, PCA_projection, pca_df


def _fit_transform_umap(
embeddings: NDArray, n_components: int = 2, normalize: bool = True
) -> tuple[umap.UMAP, NDArray]:
Expand Down

0 comments on commit 6996bbd

Please sign in to comment.