code

Image modification

library(tidyverse)
library(magick)

imgdir <- choose.dir() 
newdir <- choose.dir() 

imgfiles <- list.files(path = imgdir
                       , full.names = T
                       , recursive = T
                       )

movefiles <- imgfiles %>% 
  enframe(name = "num", value = "path") %>% 
  mutate(imgname = gsub('.*GERM/(.+)', '\\1', path)) %>% 
  mutate(across(imgname, ~gsub('/', '_', .))) %>% 
  mutate(across(imgname, ~gsub('[[:space:]]', '-', .))) %>% 
  mutate(across(imgname, ~gsub('\\(|\\)', '_', .))) %>% 
  mutate(across(imgname, ~gsub('__', '_', .))) %>% 
  mutate(newdir = file.path({{newdir}}, imgname)) %>% 
  filter(str_detect(imgname, "DIA-(3|4)")) %>% 
  filter(!str_detect(imgname, "mp4"))

nrow(movefiles)

walk(movefiles, \(x) {
  
  file.copy(from = movefiles$path, to = movefiles$newdir
            , overwrite = T)
})

Image URL for Label Studio

newdir <- "library"

imgs <- list.files(path = newdir
                   , pattern = "JPG|NEF"
                   , full.names = T
                   ) %>% 
  enframe() %>% 
  mutate(url = file.path("https://github.com/Henry-WSC/Imagenes.git", value))

imgs %>% 
  select(url) %>% 
  write_csv(file.path(newdir, "images4labelstudio.txt"), col_names = F)