Skip to content

Commit

Permalink
Merge pull request #48 from Gregor-Mendel-Institute/1.2.1
Browse files Browse the repository at this point in the history
merge 1.2.1 > master
  • Loading branch information
phue authored Jul 23, 2020
2 parents ab05371 + 98aad42 commit 409d199
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [v1.2.1](https://github.com/Gregor-Mendel-Institute/aradeepopsis/releases/tag/v1.2.1) - 2020-07-23

* updated pipeline to fetch trained models from the deposited [Zenodo record](https://doi.org/10.5281/zenodo.3946321) instead of Dropbox
* fixed an issue where the DPP addon produced sub-par segmentation results compared to the [tools](https://deep-plant-phenomics.readthedocs.io/en/latest/Tools/#vegetation-segmentation-network) implementation in Deep Plant Phenomics.
* updated shiny app to show visualizations sorted by filename

## [v1.2](https://github.com/Gregor-Mendel-Institute/aradeepopsis/releases/tag/v1.2) - 2020-07-15

* updated `shiny` dependency `1.4.0` > `1.5.0`
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ![araDeepopsis](assets/logo/logo.png)
# ![ARADEEPOPSIS](assets/logo/logo.png)

![CI](https://github.com/Gregor-Mendel-Institute/aradeepopsis/workflows/Integration%20test/badge.svg?branch=master)
![Latest Release](https://img.shields.io/github/v/release/Gregor-Mendel-Institute/aradeepopsis?sort=semver)
![License](https://img.shields.io/github/license/Gregor-Mendel-Institute/aradeepopsis)
[![DOI](https://zenodo.org/badge/240287274.svg)](https://zenodo.org/badge/latestdoi/240287274)
![CI](https://github.com/Gregor-Mendel-Institute/aradeepopsis/workflows/Integration%20test/badge.svg?branch=master)
[![DOI](https://zenodo.org/badge/240287274.svg)](https://zenodo.org/badge/latestdoi/240287274)
[![Nextflow](https://img.shields.io/badge/nextflow-%E2%89%A520.01.0-important.svg)](https://www.nextflow.io/)
[![conda](https://img.shields.io/badge/install%20with-conda-brightgreen.svg)](https://conda.io/)

Expand All @@ -16,7 +16,7 @@

# Introduction

araDeepopsis is a software tool that enables plant researchers to non-invasively score plant growth, biomass accumulation and senescence from image data in a highly parallelized, high throughput, yet easy to use manner.
`ARADEEPOPSIS` is a software tool that enables plant researchers to non-invasively score plant growth, biomass accumulation and senescence from image data in a highly parallelized, high throughput, yet easy to use manner.

It is built upon the published, convolutional neural network (CNN) [DeepLabv3+](https://github.com/tensorflow/models/tree/master/research/deeplab)<sup>[[1]](#ref1)</sup> that serves the task of semantic image segmentation. A [pretrained checkpoint](http://download.tensorflow.org/models/deeplabv3_xception_2018_01_04.tar.gz) of this model has been trained upon using manually annotated top-view images of *Arabidopsis thaliana* plants of different ages.
The code that was used for training can be found [here](https://github.com/phue/models/tree/aradeepopsis_manuscript/research/deeplab). The different models are available here [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3946618.svg)](https://doi.org/10.5281/zenodo.3946618)
Expand Down
8 changes: 6 additions & 2 deletions assets/shiny/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ library(jpeg)
# raise file upload limit to 20MB
options(shiny.maxRequestSize=20*1024^2)

data <- read_csv("aradeepopsis_traits.csv")
data <- read_csv("aradeepopsis_traits.csv") %>% arrange(file)

labels <- Sys.getenv(c("LABELS"),"class_background=0,class_norm=1,class_senesc=2,class_antho=3") %>%
str_replace_all(.,"=[:digit:]+","") %>%
str_split(.,",") %>%
unlist() %>%
tail(-1)

num_labels <- data %>% select(any_of(glue::glue("{labels}_area"))) %>% ncol()

imagenames <- data %>% select(file)
invalid <- ifelse(file.exists('invalid_images.txt'),length(read_lines('invalid_images.txt')),0)
traitcount <- ncol(data) - 2 # exclude filename and suffix
Expand All @@ -56,7 +58,7 @@ ui <- navbarPage(title="aradeepopsis", id="nav", theme = shinytheme("flatly"),
tabPanel("Convex Hull",value=0,imageOutput("hull")),
tabPanel("Rosette",value=0,imageOutput("rosette")),
tabPanel("Color Channels",value=0,plotOutput("color") %>% withSpinner()),
tabPanel("Leaf Classification",value=0,chartJSRadarOutput("radar", height = "200") %>% withSpinner())
tabPanel("Leaf Classification",value=1,chartJSRadarOutput("radar", height = "200") %>% withSpinner())
),
),
),
Expand Down Expand Up @@ -109,6 +111,8 @@ ui <- navbarPage(title="aradeepopsis", id="nav", theme = shinytheme("flatly"),
)

server <- function(input, output, session) {
# hide radarchart if there is only one class
if (num_labels < 2) { hideTab(inputId = "tabset1", target = "1") }
# nextflow report is only generated after the run has finished once, show the tab only for resumed runs
if (dir.exists("www")) {
appendTab("nav",
Expand Down
12 changes: 6 additions & 6 deletions conf/base.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@ env {

process {
withName: build_records {
container = 'beckerlab/aradeepopsis-base:1.2'
container = 'beckerlab/aradeepopsis-base:1.2.1'
cpus = 1
memory = 2.GB
time = 1.h
}
withName: run_predictions {
container = 'beckerlab/aradeepopsis-base:1.2'
container = 'beckerlab/aradeepopsis-base:1.2.1'
cpus = 2
memory = params.multiscale ? 12.GB : 6.GB
time = 4.h
}
withName: run_predictions_DPP {
container = 'beckerlab/aradeepopsis-dpp:1.2'
container = 'beckerlab/aradeepopsis-dpp:1.2.1'
cpus = 2
memory = 2.GB
time = 4.h
}
withName: extract_traits {
container = 'beckerlab/aradeepopsis-base:1.2'
container = 'beckerlab/aradeepopsis-base:1.2.1'
cpus = 1
memory = 2.GB
time = 1.h
}
withName: draw_diagnostics {
container = 'beckerlab/aradeepopsis-base:1.2'
container = 'beckerlab/aradeepopsis-base:1.2.1'
cpus = 1
memory = 2.GB
time = 1.h
}
withName: launch_shiny {
container = 'beckerlab/aradeepopsis-shiny:1.2'
container = 'beckerlab/aradeepopsis-shiny:1.2.1'
}
}
2 changes: 1 addition & 1 deletion containers/addons/dpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ LABEL authors="[email protected]" \
COPY environment.yml /
RUN apt-get update && apt-get install -y procps graphviz && apt-get clean -y
RUN conda env create -f /environment.yml && conda clean -afy
ENV PATH /opt/conda/envs/aradeepopsis-dpp-v1.2/bin:$PATH
ENV PATH /opt/conda/envs/aradeepopsis-dpp-v1.2.1/bin:$PATH
2 changes: 1 addition & 1 deletion containers/addons/dpp/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: aradeepopsis-dpp-v1.2
name: aradeepopsis-dpp-v1.2.1
channels:
- conda-forge
- defaults
Expand Down
2 changes: 1 addition & 1 deletion containers/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ LABEL authors="[email protected]" \
COPY environment.yml /
RUN apt-get update && apt-get install -y procps graphviz && apt-get clean -y
RUN conda env create -f /environment.yml && conda clean -afy
ENV PATH /opt/conda/envs/aradeepopsis-base-v1.2/bin:$PATH
ENV PATH /opt/conda/envs/aradeepopsis-base-v1.2.1/bin:$PATH
3 changes: 1 addition & 2 deletions containers/base/environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: aradeepopsis-base-v1.2
name: aradeepopsis-base-v1.2.1
channels:
- conda-forge
- r
- defaults
dependencies:
- anaconda::tensorflow-base=2.0.0
Expand Down
2 changes: 1 addition & 1 deletion containers/shiny/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ LABEL authors="[email protected]" \
COPY environment.yml /
RUN apt-get update && apt-get install -y procps graphviz && apt-get clean -y
RUN conda env create -f /environment.yml && conda clean -afy
ENV PATH /opt/conda/envs/aradeepopsis-shiny-v1.2/bin:$PATH
ENV PATH /opt/conda/envs/aradeepopsis-shiny-v1.2.1/bin:$PATH

EXPOSE 44333
2 changes: 1 addition & 1 deletion containers/shiny/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: aradeepopsis-shiny-v1.2
name: aradeepopsis-shiny-v1.2.1
channels:
- conda-forge
- r
Expand Down
2 changes: 1 addition & 1 deletion docs/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ Launch a [Shiny](https://shiny.rstudio.com/) app as the last step of the pipelin
> R -e "shiny::runApp('app.R', port=44333)"
>
> # if using the container image
> {docker|podman} run -v $(pwd):/mnt/shiny -p 44333:44333 beckerlab/aradeepopsis-shiny:1.2 R -e "shiny::runApp('/mnt/shiny/app.R', port=44333, host='0.0.0.0')"
> {docker|podman} run -v $(pwd):/mnt/shiny -p 44333:44333 beckerlab/aradeepopsis-shiny:1.2.1 R -e "shiny::runApp('/mnt/shiny/app.R', port=44333, host='0.0.0.0')"
> ```
> The shiny app can then be opened in a browser by typing localhost:44333 in the address bar. It will terminate when the browser window is closed.
18 changes: 11 additions & 7 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,22 @@ Pipeline parameters

switch(params.model) {
case 'A':
model = params.multiscale ? 'https://www.dropbox.com/s/19eeq3yog975otz/1_class_multiscale.pb?dl=1' : 'https://www.dropbox.com/s/ejpkgnvsv9p9s5d/1_class_singlescale.pb?dl=1'
model = "https://zenodo.org/record/3946618/files/1_class_${params.multiscale ? 'multiscale' : 'singlescale'}.pb"
labels = "class_background=0,class_norm=1"
ignore_label = "None"
max_dimension = 602
break
case 'B':
model = params.multiscale ? 'https://www.dropbox.com/s/9m4wy990ajv7cmg/2_class_multiscale.pb?dl=1' : 'https://www.dropbox.com/s/s808kcq9jgiyko9/2_class_singlescale.pb?dl=1'
model = "https://zenodo.org/record/3946618/files/2_class_${params.multiscale ? 'multiscale' : 'singlescale'}.pb"
labels = "class_background=0,class_norm=1,class_senesc=2"
ignore_label = params.ignore_senescence ? "2" : "None"
max_dimension = 602
break
case 'C':
model = params.multiscale ? 'https://www.dropbox.com/s/xwnqytcf6xzdumq/3_class_multiscale.pb?dl=1' : 'https://www.dropbox.com/s/1axmww7cqor6i7x/3_class_singlescale.pb?dl=1'
model = "https://zenodo.org/record/3946618/files/3_class_${params.multiscale ? 'multiscale' : 'singlescale'}.pb"
labels = "class_background=0,class_norm=1,class_senesc=2,class_antho=3"
ignore_label = params.ignore_senescence ? "2" : "None"
max_dimension = 602
break
case 'DPP':
model = [
Expand All @@ -133,6 +136,7 @@ switch(params.model) {
]
labels = !params.label_spec ? "class_background=0,class_norm=1" : params.label_spec
ignore_label = !params.ignore_label ? 'None' : params.ignore_label
max_dimension = 256
break
}

Expand Down Expand Up @@ -226,7 +230,7 @@ process build_records {
continue
height, width = image.shape[:2]
max_dimension = 602
max_dimension = ${max_dimension}
ratio = 1.0
if height * width > max_dimension**2:
Expand Down Expand Up @@ -302,15 +306,15 @@ if (params.model == "DPP") {
for i in samples:
img, filename = tf.cast(samples['original'],tf.float32), samples['filename']
img = tf.image.per_image_standardization(img)
raw = pretrainedDPP.model.forward_pass(img, deterministic=True)
try:
while True:
prediction, name = pretrainedDPP.model._session.run([raw,filename])
logger.info("Running prediction on image %s" % name)
seg = np.interp(prediction, (prediction.min(), prediction.max()), (0, 1))
mask = (np.squeeze(seg) > 0.5).astype(np.uint8)
mask = (np.squeeze(prediction) >= 0.5)
name = name[0].decode('utf-8').rsplit('.', 1)[0]
imwrite(f'{name}.png', mask)
imwrite(f'{name}.png', mask.astype(np.uint8))
except tf.errors.OutOfRangeError:
pass
"""
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ manifest {
homePage = 'https://github.com/Gregor-Mendel-Institute/aradeepopsis'
description = "Nextflow pipeline to run semantic segmentation on plant rosette images with DeepLab V3+"
name = 'aradeepopsis'
version = '1.2'
version = '1.2.1'
mainScript = 'main.nf'
nextflowVersion = '>=20.01.0'
}
Expand Down

0 comments on commit 409d199

Please sign in to comment.