danforthcenter / plantcv

Plant phenotyping with image analysis
Mozilla Public License 2.0
652 stars 263 forks source link

Update `plantcv.kmeans_classifier.predict_kmeans` to accept array rather than a filepath #1605

Open HaleySchuhl opened 4 hours ago

HaleySchuhl commented 4 hours ago

Start a discussion about anything you would like Throughout PlantCV we use img as a parameter input name when the function takes numpy array data, and filepath when the function takes a path. Currently plantcv.kmeans_classifier.predict_kmeans(img, model_path="./kmeansout.fit", patch_size=10) is expecting a path for the img parameter.

I propose we update the behavior of this function, keep the parameter name the name, and just require users to read the image in upstream. Happy medium might be to just extend the functionality to accept both types of input, @k034b363 thoughts?

k034b363 commented 3 hours ago

I think that's a great idea! When I added that function, I didn't have a ton of experience using the rest of plantcv, so it wasn't on purpose that it kind of breaks the convention. There's nothing about it that means it couldn't use the image instead of path, but allowing it to accept either wouldn't hurt, so I have no strong feelings either way.