3D cell shape analysis using geometric deep learning on point clouds
Project description
Cellshape-cloud is an easy-to-use tool to analyse the shapes of cells using deep learning and, in particular, graph-neural networks. The tool provides the ability to train popular graph-based autoencoders on point cloud data of 2D and 3D single cell masks as well as providing pre-trained networks for inference.
To install
pip install cellshape-cloud
Usage
Basic Usage
import torch
from cellshape_cloud import CloudAutoEncoder
model = CloudAutoEncoder(num_features=128,
k=20,
encoder_type="dgcnn",
decoder_type="foldingnet")
points = torch.randn(1, 2048, 3)
recon, features = model(points)
To train an autoencoder on a set of point clouds created using cellshape-helper:
import torch
from torch.utils.data import DataLoader
import cellshape_cloud as cloud
from cellshape_cloud.vendor.chamfer_distance import ChamferLoss
input_dir = "path/to/pointcloud/files/"
batch_size = 16
learning_rate = 0.0001
num_epochs = 1
output_dir = "path/to/save/output/"
model = cloud.CloudAutoEncoder(num_features=128,
k=20,
encoder_type="dgcnn",
decoder_type="foldingnet")
dataset = cloud.PointCloudDataset(input_dir)
dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
criterion = ChamferLoss()
optimizer = torch.optim.Adam(
model.parameters(),
lr=learning_rate * 16 / batch_size,
betas=(0.9, 0.999),
weight_decay=1e-6,
)
cloud.train(model, dataloader, num_epochs, criterion, optimizer, output_dir)
Parameters
num_features
: int.
The size of the latent space of the autoencoder.k
: int.
The number of neightbours to use in the k-nearest-neighbours graph construction.encoder_type
: str.
The type of encoder: 'foldingnet' or 'dgcnn'decoder_type
: str.
The type of decoder: 'foldingnet' or 'dgcnn'
For developers
- Fork the repository
- Clone your fork
git clone https://github.com/USERNAME/cellshape-cloud
- Install an editable version (
-e
) with the development requirements (dev
)
cd cellshape-cloud
pip install -e .[dev]
- To install pre-commit hooks to ensure formatting is correct:
pre-commit install
- To release a new version:
Firstly, update the version with bump2version (bump2version patch
,
bump2version minor
or bump2version major
). This will increment the
package version (to a release candidate - e.g. 0.0.1rc0
) and tag the
commit. Push this tag to GitHub to run the deployment workflow:
git push --follow-tags
Once the release candidate has been tested, the release version can be created with:
bump2version release
References
[1] An Tao, 'Unsupervised Point Cloud Reconstruction for Classific Feature Learning', GitHub Repo, 2020
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cellshape-cloud-0.0.26rc0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac3d6563407d8d0b1e8db03cc4b40bd8225c2974944b5f9ff4cd9362abe4702d |
|
MD5 | c99a8197c0dd8e85bf8911784aa855b7 |
|
BLAKE2b-256 | 13ed3b0e65214a2676493e8b80fb85198c8e6403c48675bc7115b9130f921854 |
Hashes for cellshape_cloud-0.0.26rc0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a26f6bbe193ff2aaa5f07fc2dc5040ab0cfbe26858a4bab249f6b549442c5f1b |
|
MD5 | fcc41d8b8c7befc4b84a95c453c6a106 |
|
BLAKE2b-256 | 8190c76aa74151134114c1a068e6fa014c36b41cf5bcf97c0f307ea5233baa95 |