Git Product home page Git Product logo

imageseg's Introduction

EcoDynIZW

We are the Department of Ecological Dynamics at the Leibniz Institute for Zoo and Wildlife Research (IZW).

Information

Repositories of Published Studies

R Packages

  • d6: A package for simplifying workflows at our department
  • d6berlin: A package with template maps for Berlin
  • d6raster: A package to automate raster access and processing
  • imageseg: R package for deep learning image segmentation
  • vietnameseConverter: R package for converting characters in legacy Vietnamese encodings to correct Unicode characters

imageseg's People

Contributors

jniedballa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

imageseg's Issues

imageSegmatiation incompatible with purrr >1.0.0

recent versions of purrr cause error in map_depth in function imageSegmentation.


library(imageseg)
library(magick)
library(tidyverse)
library(keras)
library(tensorflow)

wd_images <- system.file("images/canopy/resized",
                         package = "imageseg")
images <- loadImages(wd_images)

wd_masks <- system.file("images/canopy/masks",
                        package = "imageseg")

masks <- loadImages(wd_masks)

split_data <- function(n, frac_test = NULL, frac_val = NULL, seed) {
  set.seed(seed) # for reproducible splitting
  if(is.null(frac_test)) frac_test <- 0
  if(is.null(frac_val)) frac_val <- 0
  split_tmp <- sample(rep(1:3,
                          diff(floor(n * c(0, frac_test, (frac_test + frac_val), 1)))))
  test <- which(split_tmp == 1)
  validation <- which(split_tmp == 2)
  train <- which(split_tmp == 3)
  return(list(index_test = test,
              index_val = validation,
              index_train = train))
}

test_split <- 0.2           # 20% of images for testing
validation_split <- 0.1     # 10% of images for validation

split_tmp <- split_data(n = nrow(images$info), frac_test = test_split, frac_val = validation_split, seed = 100)

# get indices of values 1 (test), 2 (validation), 3 (training images)
test_index   <- split_tmp$index_test
val_index    <- split_tmp$index_val
train_index  <- split_tmp$index_train

images_aug <- dataAugmentation(images = images, 
                               subset = train_index,
                               rotation_angles = c(0, 90, 180, 270),
                               flip = TRUE, 
                               flop = TRUE)

masks_aug <- dataAugmentation(images = masks, 
                              subset = train_index,
                              rotation_angles = c(0, 90, 180, 270),
                              flip = TRUE, 
                              flop = TRUE)

x_train <- imagesToKerasInput(images_aug, type = "image")
y_train <- imagesToKerasInput(masks_aug, type = "mask")

x_test <- imagesToKerasInput(images_aug, type = "image", subset = test_index)
y_test <- imagesToKerasInput(masks_aug, type = "mask", subset = test_index)

x_val <- imagesToKerasInput(images_aug, type = "image", subset = val_index)
y_val <- imagesToKerasInput(masks_aug, type = "mask", subset = val_index)

model <- u_net(net_h = 256, 
               net_w = 256,  
               filters = 16)

bce_dice_loss <- imageseg:::bce_dice_loss
dice_coef     <- imageseg:::dice_coef
jaccard_index <- imageseg:::jaccard_index

model %>% compile(
  optimizer = optimizer_adam(),
  loss = bce_dice_loss,
  metrics = list(custom_metric("dice_coef", dice_coef),
                 custom_metric("jaccard_index", jaccard_index))
)

epochs <- 2
batch_size <- 8 

history <- model %>% fit(
  x_train, 
  y_train, 
  epochs = epochs, 
  batch_size = batch_size,   
  # validation_split = 0.15
  validation_data = list(x_val, y_val),
)

plot_history <- plot(history)
plot_history

scores <- model %>% evaluate(
  x_test, y_test, verbose = 0
)
print(scores)

# works with purrr 0.3.5, not with 1.0.2
out <- imageSegmentation(model, x = x_test)

image

Installation problem

Dear creator,
I have tried to install the package by using remotes R procedure but i have got the follow problem

√  checking for file 'C:\Users\Fiorentini\AppData\Local\Temp\RtmpeuGFE1\remotes1b64158335a6\EcoDynIZW-imageseg-388d34b/DESCRIPTION' ... 
-  preparing 'imageseg':
√  checking DESCRIPTION meta-information ... 
-  installing the package to process help pages
-  saving partial Rd database (6.7s)
   Errore in loadVignetteBuilder(pkgdir, TRUE) : 
     vignette builder 'R.rsp' not found
   Esecuzione interrotta
Error: Failed to install 'imageseg' from GitHub:
  System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed

Error in load_model_hdf5

I have successfully used the package before but yesterday when I tried to load a model I got the following message:

Error in load_model_hdf5(filepath = modelFile, custom_objects = restoreCustomObjects()) :
The h5py Python package is required to save and load models

I tried on a different computer today and got the same message. Everything is up to date and the h5py package do exists. Any idea what might be the issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.