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

Updated code (contrastive learning) #130

Merged
merged 10 commits into from
Aug 9, 2024
Merged

Conversation

alishbaimran
Copy link
Collaborator

I made the following changes:
—> Updated triplet code such that during prediction evaluation can be done for specific pre-defined cells.
—> Changed stride to be the same as stem kernel size which was also changed to (5, 4, 4).
—> Output file name is configurable for the prediction.
—> Updated training_script.py and predict.py

To-do:
—> Should be merged before any other branches merged into main.

viscy/light/engine.py Outdated Show resolved Hide resolved
viscy/data/triplet.py Outdated Show resolved Hide resolved
viscy/data/triplet.py Outdated Show resolved Hide resolved
viscy/light/engine.py Outdated Show resolved Hide resolved
self.tracks = self._filter_tracks(tracks_tables)
self.tracks = (
self._specific_cells(self.tracks) if self.predict_cells else self.tracks
)

def _filter_tracks(self, tracks_tables: list[pd.DataFrame]) -> pd.DataFrame:
Copy link
Member

@mattersoflight mattersoflight Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ziw-liu please edit docstrings related to processing of tracking info for accuracy.

channel_wise=False,
dtype=None,
allow_missing_keys=False
),
]

def main(hparams):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's clean up the predict.py in the next PR

Comment on lines +588 to +590
features_output_path: str = "",
projections_output_path: str = "",
metadata_output_path: str = "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these three paths are needed to save predictions. I suggest renaming these three to predict_output_path and assign these three variables a consistent names, predict_output_path + features.npy, projecttions.npy, meta.csv ...

trainer.fit(model, datamodule=data_module)

# # Validate the model
trainer.validate(model, datamodule=data_module)

# # Test the model
# trainer.test(model, datamodule=data_module)

# Argument parser for command-line options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alishbaimran In the next PR, this training script should be turned into a config for use with lightning CLI and then deleted.

Copy link
Member

@mattersoflight mattersoflight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am merging this PR to unblock the rest of the improvements in model construction. Let's revisit comments in this PR to:

  • delete applications/contrastive_phenotyping/training_script.py
  • clean up predict.py.
  • document key methods in viscy.data.triplet.py
  • clean up excess input parameters to viscy.light.engine.ContrastiveModule

@mattersoflight mattersoflight merged commit 0f85c4e into main Aug 9, 2024
4 checks passed
edyoshikun pushed a commit that referenced this pull request Aug 15, 2024
* updated prediction code to test specific cells

* updated kernel and stride

* updated kernel and stride

* new training script and predict takes in output path as parameter

* passing ci requirements

* fixed error for output path

* fixed error for output path

* fixed formatting

* format resolved

* docstrings for methods that parse tracks

---------

Co-authored-by: Shalin Mehta <[email protected]>
edyoshikun pushed a commit that referenced this pull request Aug 15, 2024
* updated prediction code to test specific cells

* updated kernel and stride

* updated kernel and stride

* new training script and predict takes in output path as parameter

* passing ci requirements

* fixed error for output path

* fixed error for output path

* fixed formatting

* format resolved

* docstrings for methods that parse tracks

---------

Co-authored-by: Shalin Mehta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants