Useful packages for DL
Project description
FusionLab
FusionLab is an open-source frameworks built for Deep Learning research written in PyTorch and Tensorflow. The code is easy to read and modify especially for newbie. Feel free to send pull requests :D
Installation
With pip
pip install fusionlab
For Mac M1 chip users
Requirements:
- Apple Mac with M1 chips
- MacOS > 12.6 (Monterey)
Following steps
- Clone this repo
git clone https://github.com/taipingeric/fusionlab.git
cd fusionlab
- (remove anaconda first)
- Install Miniconda
- Miniconda3 macOS Apple M1 64-bit pkg
- Miniconda3 macOS Apple M1 64-bit bash
- Install the xcode-select command-line
xcode-select --install
- Deactivate the base environment
conda deactivate
- Create conda environment using config
conda env create -f ./configs/tf-apple-m1-conda.yaml -n fusionlab
- Replace requirements.txt with requirements-m1.txt
- Install by pip
pip install -r requirements-m1.txt
How to use
import fusionlab as fl
# PyTorch
encoder = fl.encoders.VGG16()
# Tensorflow
encoder = fl.encoders.TFVGG16()
Encoders
Losses
- DiceLoss, TFDiceLoss
- IoULoss, TFIoULoss
# Dice Loss (Multiclass)
import fusionlab as fl
# PyTorch
import torch
loss_fn = fl.losses.DiceLoss("multiclass", from_logits=True)
pred = torch.tensor([[
[1., 2., 3., 4.],
[2., 6., 4., 4.],
[9., 6., 3., 4.]
]]).view(1, 3, 4) # (BS, *, C)
true = torch.tensor([[2, 1, 0, 2]]).view(1, 4) # (BS, *)
loss = loss_fn(pred, true)
# Tensorflow
import tensorflow as tf
loss_fn = fl.losses.TFDiceLoss("multiclass", from_logits=True)
pred = tf.convert_to_tensor([[
[1., 2., 3.],
[2., 6., 4.],
[9., 6., 3.],
[4., 4., 4.],
]]) # (BS, *, C)
true = tf.convert_to_tensor([[2, 1, 0, 2]]) # (BS, *)
loss = loss_fn(true, pred)
# Dice Loss (Binary)
# PyTorch
import torch
pred = torch.tensor([0.4, 0.2, 0.3, 0.5]).reshape(1, 1, 2, 2) # (BS, 1, *)
true = torch.tensor([0, 1, 0, 1]).reshape(1, 2, 2) # (BS, *)
loss_fn = fl.losses.IoULoss("binary", from_logits=True)
loss = loss_fn(pred, true)
# Tensorflow
pred = tf.convert_to_tensor([0.4, 0.2, 0.3, 0.5])
pred = tf.reshape(pred, [1, 2, 2, 1]) # (BS, *, 1)
true = tf.convert_to_tensor([0, 1, 0, 1])
true = tf.reshape(true, [1, 2, 2]) # (BS, *)
loss_fn = fl.losses.TFIoULoss("binary", from_logits=True)
loss = loss_fn(true, pred)
Segmentation
import fusionlab as fl
# PyTorch UNet
unet = fl.segmentation.UNet(cin=3, num_cls=10, base_dim=64)
# Tensorflow UNet
import tensorflow as tf
# Binary Segmentation
unet = tf.keras.Sequential([
fl.segmentation.TFUNet(num_cls=1, base_dim=64),
tf.keras.layers.Activation(tf.nn.sigmoid),
])
unet.compile(loss=fl.losses.TFDiceLoss("binary"))
# Multiclass Segmentation
unet = tf.keras.Sequential([
fl.segmentation.TFUNet(num_cls=10, base_dim=64),
tf.keras.layers.Activation(tf.nn.softmax),
])
unet.compile(loss=fl.losses.TFDiceLoss("multiclass"))
- UNet, TFUNet
- ResUNet, TFResUNet
- UNet2plus, TFUNet2plus
Acknowledgements
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
fusionlab-0.0.50.tar.gz
(20.0 kB
view hashes)
Built Distribution
fusionlab-0.0.50-py3-none-any.whl
(36.9 kB
view hashes)
Close
Hashes for fusionlab-0.0.50-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df8281dfdafe1b157e9b2aa332c570245391d160bb12f87e0c448936a84093f |
|
MD5 | aa4ce5f0da3f025a980301b1b0b542c3 |
|
BLAKE2b-256 | 5c923f5eb1c367b91e0523e15038d890b37c9cb164735cb654c077849a19acdb |