SamWood is an open-source Python package designed to automate the segmentation and measurement of wood cells in transverse sections of both modern and fossil samples. It uses SAM2 (Segment Anything Model 2), a state-of-the-art Vision Transformer for zero-shot segmentation, and a dedicated algorithms to reconstruct cell files and extract anatomical traits along growth gradients.
We rely on some dependencies :
sam2for the deep learning segmentation,opencv-pythonandtifffilefor image handling,scipyandpandasfor cell lines graph analysis,matplotlibas an optional dependency for plots.
Please check sam2 documentation for sam2 installation instructions.
To install, you can use the following command
pip install git+https//github.com/umr-amap/samwood.git
To work, samwood must find the sam2 model config and corresponding weights. By default, the script will search for a ./sam2 path within this project but you can provide another path.
You also need to provide an input path and output path.
The script assumes your images are .tif files.
python src/segment_fossil.py -i path/to/your/tiff/images -o path/to/output/directory
python src/cell_line_extractor.py -i path/to/previous/output/directory