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

Add kwargs to get_features #294

Merged
merged 1 commit into from
Mar 26, 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
11 changes: 3 additions & 8 deletions fmcib/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
from .preprocessing import get_dataloader


def get_features(
csv_path,
weights_path=None,
spatial_size=(50, 50, 50),
precropped=False,
):
def get_features(csv_path, weights_path=None, spatial_size=(50, 50, 50), precropped=False, **kwargs):
"""
Extracts features from images specified in a CSV file.

Expand All @@ -23,13 +18,13 @@ def get_features(
weights_path (str, optional): Path to the pre-trained weights file. Default is None.
spatial_size (tuple, optional): Spatial size of the input images. Default is (50, 50, 50).
precropped (bool, optional): Whether the images are already pre-cropped. Default is False.

**kwargs: Additional arguments to be passed to the dataloader.
Returns:
pandas.DataFrame: DataFrame containing the original data from the CSV file along with the extracted features.
"""
logger.info("Loading CSV file ...")
df = pd.read_csv(csv_path)
dataloader = get_dataloader(csv_path, spatial_size=spatial_size, precropped=precropped)
dataloader = get_dataloader(csv_path, spatial_size=spatial_size, precropped=precropped, **kwargs)
device = "cuda" if torch.cuda.is_available() else "cpu"

if weights_path is None:
Expand Down
Loading