Metadata-Version: 2.1
Name: efficientbioai
Version: 0.0.6
Summary: efficientbioai is a python package for efficient deep learning in bioimaging
Home-page: UNKNOWN
Author: mmv_lab team
Author-email: yu.zhou@isas.de
License: UNKNOWN
Keywords: deep learning,quantization,microscopy model compression
Platform: UNKNOWN
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: codecarbon
Requires-Dist: torch (<1.11,>=1.10)
Requires-Dist: mmv-im2im
Requires-Dist: cellpose
Requires-Dist: nni
Requires-Dist: tensorboard
Provides-Extra: all
Requires-Dist: openvino ; extra == 'all'
Requires-Dist: openvino-dev[onnx,pytorch] ; extra == 'all'
Requires-Dist: pycuda ; extra == 'all'
Requires-Dist: tensorrt (<8.6,>=8.0) ; extra == 'all'
Provides-Extra: cpu
Requires-Dist: openvino ; extra == 'cpu'
Requires-Dist: openvino-dev[onnx,pytorch] ; extra == 'cpu'
Provides-Extra: gpu
Requires-Dist: pycuda ; extra == 'gpu'
Requires-Dist: tensorrt (<8.6,>=8.0) ; extra == 'gpu'
Provides-Extra: test
Requires-Dist: black (>=19.10b0) ; extra == 'test'
Requires-Dist: codecov (>=2.1.4) ; extra == 'test'
Requires-Dist: flake8 (>=3.8.3) ; extra == 'test'
Requires-Dist: flake8-debugger (>=3.2.1) ; extra == 'test'
Requires-Dist: pytest (>=5.4.3) ; extra == 'test'
Requires-Dist: pytest-cov (>=2.9.0) ; extra == 'test'
Requires-Dist: pytest-raises (>=0.11) ; extra == 'test'

# EfficientBioAI
This package mainly focus on the efficiency of BioImage AI tasks. For the moment we just implemented quantization algorithm.

## Introduction:
The whole project contains two parts: quantization and inference. In the quantization step, we quantize the pretrained model into int8 precision and transform them to the format suitable to the inference engine. The next step is to run the inference on the inference engine and do the analysis. The inference engine that we choose is `openvino` for intel CPU and `tensorrt` for nvidia GPU.   
We support several popular bioimage AI tools like([mmv_im2im](https://github.com/MMV-Lab/mmv_im2im),[cellpose](https://github.com/MouseLand/cellpose)). Also user-defined pytorch models are supported.

## Installation:
### pip:
First create a virtual environment using conda:
```bash
conda config --add channels conda-forge
conda create -n efficientbioai python=3.8 setuptools=59.5.0
```
Then we need to install the dependencies:
```bash
git clone git@github.com:ModelTC/MQBench.git
cd MQBench
python setup.py install
cd ..
```
Then install the `efficientbioai` package:

```bash
git clone git@github.com:MMV-Lab/EfficientBioAI.git
cd EfficientBioAI
pip install -e .[cpu/gpu/all] # for intel cpu, nvidia gpu or both
```

### docker:(recommended)
We use different docker images for both cpu and gpu. Assume that you are in the root directory of the project.
- for CPU:
```bash
cd docker/cpu
bash install.sh # if not install docker, run this command first
bash build_docker.sh # build the docker image
cd ../..
bash docker/cpu/run_container.sh #run the docker container
```
- for GPU:
```bash
cd docker/gpu
bash install.sh # if not install docker, run this command first
bash build_docker.sh # build the docker image
cd ../..
bash docker/gpu/run_container.sh #run the docker container
```

## How to run it:
### Use scripts:
- compression:
 ```bash
python efficientbioai/compress.py --config path/to/the/config.yaml --exp_path experiment/save_path
```
- inference:
```bash
python efficientbioai/inference.py --config path/to/the/config.yaml
```
### Use functions:
There is a simple [example](tutorial/compress_custom_network.ipynb)


Note that pretrained model and data should be placed in the `model` and `data` folders, respectively. You can download our mmv_im2im pretrained model from [nextcloud](). All the intermediate files will be saved in the `experiment` folder. 

