haesleinhuepf / apoc Goto Github PK
View Code? Open in Web Editor NEWAccelerated Pixel and Object Classifiers (APOC)
License: BSD 3-Clause "New" or "Revised" License
Accelerated Pixel and Object Classifiers (APOC)
License: BSD 3-Clause "New" or "Revised" License
Hello,
I am an APOC newbie and was wondering if there was a formal API document?
Specifically, what is my total choice (description) for selecting features?
Can I input, train, and test on RGB or BGR color images?
segmenter = apoc.ObjectSegmenter(opencl_filename=cl_filename, positive_class_identifier=5) features = apoc.PredefinedFeatureSet.object_size_1_to_5_px.value apoc.train_classifier_from_image_folders( segmenter, features, image = image_folder, ground_truth = masks_folder)
thx e.-
... should be available from the menu
This idea is very much borrowed from Ilastik, which shows an uncertainty
overlay on top of the output classification. I did a quick search, and it seems like uncertainty for random forest classifiers is simply the difference of the two highest probabilities (see also here).
So for a background/foreground segmentation, this would mean the following.
If - for a single pixel - 90 trees vote for class 1
and 10 trees vote for class 2
, the uncertainty would be 1 - (0.9 - 0.1) = 0.2
LMKWYT :)
Hi
Great stuff.
I am running the apoc.pixelclassifer via a pipeline (spyder).
So I do as shown in one of your demos
features = "original_image gaussian_blur=7"
cl_filename = workingdir + foldername + '_classifier.cl'
apoc.erase_classifier(cl_filename)
clf = apoc.PixelClassifier(opencl_filename=cl_filename)
clf.train(features, label1, raw1,continue_training=True)
clf.train(features, label2, raw2,continue_training=True)
clf.train(features, label3, raw3,continue_training=True)
and I get this error when it attempts the second clf.train with label2 and raw2
I checked the images, and they seem fine.
any comment or advice will be great
thanks
------------------------------------------
File "C:\Users\piango\AppData\Local\Temp/ipykernel_27864/2139741856.py", line 1, in <module>
runfile('D:/OneDrive/Postdoc/GB_Lab/Analysis/quantification/organoid-segmentation-3D/predict_mesh_multipleobjects.py', wdir='D:/OneDrive/Postdoc/GB_Lab/Analysis/quantification/organoid-segmentation-3D')
File "C:\Users\piango\anaconda3\envs\apoc\lib\site-packages\debugpy\_vendored\pydevd\_pydev_bundle\pydev_umd.py", line 167, in runfile
execfile(filename, namespace)
File "C:\Users\piango\anaconda3\envs\apoc\lib\site-packages\debugpy\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile
exec(compile(contents + "\n", file, 'exec'), glob, loc)
File "D:/OneDrive/Postdoc/GB_Lab/Analysis/quantification/organoid-segmentation-3D/predict_mesh_multipleobjects.py", line 54, in <module>
clf.train(features,
File "C:\Users\piango\anaconda3\envs\apoc\lib\site-packages\apoc\_pixel_classifier.py", line 63, in train
X, y = self._to_np(features, ground_truth)
File "C:\Users\piango\anaconda3\envs\apoc\lib\site-packages\apoc\_pixel_classifier.py", line 206, in _to_np
X = X[mask]
IndexError: boolean index did not match indexed array along dimension 0; dimension is 1221025 but corresponding boolean dimension is 1660594
--------------------------------------
Hello! Quick question about the ObjectClassifer._select_features()
docstring.
apoc/apoc/_object_classifier.py
Lines 170 to 188 in 1a07fef
It says that the returned result
vectors (i.e., table columns) are length n+1 for n labels. When I use the debugger in test_object_classification()
, it looks like the result
vectors have length 2. Since there are two label values (1 and 2 in labels
), I would have expected them to be length 3. However, I can see why length 2 makes more sense. Which is correct? (working on the TableRowClassifer
- just making sure I understand)
Thanks!
This is a follow up for #14 :
The return type specified here is list, but in fact, we return a dictionary.
The dictionary contains vectors as values (supposedly), but those have shape (1, n) for n labels.
The dictionary also contains measurements for background. This should be avoided.
I should clean up this mess :-)
Would be cool to have auto-context classifiers
To give more options for object classification while maintaining the installability of apoc, it might make sense to setup a second ObjectClassfier, that uses internally the regionprops from SimpleITK.
We could then classify objects accorind to their
We could alternatively build this in optionally in the existing object classifier. The user-interface in napari may need a major redesign for this.
I have the suspicion that a TableRowClassifier
trained with features "A B C" would also be applicable to a table with columns "E D F". We should check if provided tables contains the right columns.
This issue may be have been introduced with #17
I'd like to get rid of the return_numpy
parameter here, because:
Instead of this:
result_numpy = table_row_classifier.predict(table, return_numpy=True)
A user could run this:
result_numpy = np.asarray( table_row_classifier.predict(table) )
The second appears more standard to me and it simplifies the API. The other classifers also don't have this parameter.
@kevinyamauchi what do you think about this? Would it be ok to remove it immediately or shall we use some deprecation mechanism? I guess you and me might be the only users as this is relatively young functionality?
Just a minor "bug": I just discovered that the training from folder throws an error if the paths are passed as path/to/image
rather than path/to/image/
. There is probably a folder + filename
somewhere in the code when the data is loaded, but I couldn't find it straight away. If you point me to the right place I'd be happy to send a PR - putting a os.path.join()
there should probably do it.
It might be worth converting the tests to pytest. Then we could take advantage of fixtures such as temporary directories for writing the .cl
files so that we don't get conflicts between tests. Also, it would allow for test parameterization.
Amazing work on APOC! ๐
I am learning how to process my data in python and noticed there was no documentation for training/using a pixel classifier from Python - just opening an issue because this would have been really helpful but I think I've figured things out now!
Thanks,
Alia
Since #17 we have we have two places where feature specification is stored in the TableRowClassifier
:
self.feature_specification
is a string separated list of featuresself._ordered_feature_names
is a list with the same content, but split by spacesAll other classifiers have feature_specification
, so we may potentially reduce the code to only this.
It would be nice if there were a function that could show some info about the classifier, e.g. the expexted dimensionality of input data, the used features, etc.
reported by @FloskelSalomon
It should be pretty straight forward to rip out some parts of the ObjectClassifier and make a new classifier that does not use images, but table as input.
That would also make this easier to implement:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.