Skip to content

Commit

Permalink
mitosis shape and dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Nov 26, 2023
1 parent d6b1e38 commit 31d61d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
13 changes: 9 additions & 4 deletions src/napatrackmater/Trackvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,11 @@ def train_mitosis_neural_net(
if total_val_class2 > 0
else 0
)
loss_class1 = criterion_class1(outputs_class1, labels_class1)
loss_class2 = criterion_class2(outputs_class2, labels_class2)

running_val_loss_class1 += loss_class1.item()
running_val_loss_class2 += loss_class2.item()
pbar_val.set_postfix(
{"Acc Class1": accuracy_class1, "Acc Class2": accuracy_class2}
)
Expand Down Expand Up @@ -1494,7 +1499,9 @@ def predict_with_model(saved_model_path, saved_model_json, features_array):
num_classes_class1=num_classes_class1,
num_classes_class2=num_classes_class2,
)
model.load_state_dict(torch.load(saved_model_path, map_location=torch.device(device)))
model.load_state_dict(
torch.load(saved_model_path, map_location=torch.device(device))
)
model.to(device)
model.eval()

Expand All @@ -1505,11 +1512,9 @@ def predict_with_model(saved_model_path, saved_model_json, features_array):
outputs_class1, outputs_class2 = model(features_tensor)
predicted_probs_class1 = torch.softmax(outputs_class1, dim=1)
predicted_probs_class2 = torch.softmax(outputs_class2, dim=1)

predicted_class1 = torch.argmax(predicted_probs_class1, dim=1).cpu().numpy()
predicted_class2 = torch.argmax(predicted_probs_class2, dim=1).cpu().numpy()



return predicted_class1, predicted_class2

Expand Down
15 changes: 8 additions & 7 deletions src/napatrackmater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
train_mitosis_classifier,
train_mitosis_neural_net,
extract_neural_training_data,
predict_with_model

predict_with_model,
plot_metrics_from_npz,
)
from .DeepEmbeddedClustering import DeepEmbeddedClustering
from .CloudAutoEncoder import CloudAutoEncoder
Expand Down Expand Up @@ -73,11 +73,12 @@ def load_json(fpath):
"unsupervised_clustering",
"DeepEmbeddedClustering",
"load_json",
'create_mitosis_training_data',
'train_mitosis_classifier',
'train_mitosis_neural_net',
'extract_neural_training_data',
'predict_with_model'
"create_mitosis_training_data",
"train_mitosis_classifier",
"train_mitosis_neural_net",
"extract_neural_training_data",
"predict_with_model",
"plot_metrics_from_npz",
)

clear_models_and_aliases(DeepEmbeddedClustering, CloudAutoEncoder)
Expand Down
4 changes: 2 additions & 2 deletions src/napatrackmater/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = version = "4.4.7"
__version_tuple__ = version_tuple = (4, 4, 7)
__version__ = version = "4.4.8"
__version_tuple__ = version_tuple = (4, 4, 8)

0 comments on commit 31d61d6

Please sign in to comment.