Package Details: vapoursynth-plugin-waifu2x-caffe-git r10.0.g92b50f4-1

Git Clone URL: https://aur.archlinux.org/vapoursynth-plugin-waifu2x-caffe-git.git (read-only)
Package Base: vapoursynth-plugin-waifu2x-caffe-git
Description: Plugin for Vapoursynth: waifu2x-caffe (NVIDIA users only)(static libcaffe)(GIT version)
Upstream URL: http://forum.doom9.org/showthread.php?t=172390
Keywords: vapoursynth
Licenses: MIT
Conflicts: vapoursynth-plugin-waifu2x-caffe
Provides: vapoursynth-plugin-waifu2x-caffe
Submitter: sl1pkn07
Maintainer: sl1pkn07
Last Packager: sl1pkn07
Votes: 2
Popularity: 0.110252
First Submitted: 2017-06-14 15:01
Last Updated: 2018-11-08 16:28

Latest Comments

fitu996 commented on 2019-01-22 05:20

Latest commit break the PKGBUILD here's the new one:

# Maintainer:  Gustavo Alvarez <sl1pkn07@gmail.com>

_plug=waifu2x-caffe
pkgname=vapoursynth-plugin-${_plug}-git
pkgver=r12.3.g157c799
pkgrel=1
pkgdesc="Plugin for Vapoursynth: ${_plug} (NVIDIA users only)(static libcaffe)(GIT version)"
arch=('x86_64')
url='http://forum.doom9.org/showthread.php?t=172390'
license=('MIT')
depends=('vapoursynth'
         'boost-libs'
         'libopenblas'
         'google-glog'
         'gflags'
         'hdf5'
         'protobuf'
         'cudnn'
         'opencv'
         )
makedepends=('git'
             'boost'
             'gcc7'
             'meson'
             'ninja'
             'chrpath'
             )
provides=("vapoursynth-plugin-${_plug}")
conflicts=("vapoursynth-plugin-${_plug}")
source=("${_plug}::git+https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Waifu2x-caffe.git"
        'git+https://github.com/HolyWu/caffe.git#branch=lltcggie/custom'
        )
sha256sums=('SKIP'
            'SKIP'
            )

pkgver() {
  cd "${_plug}"
  echo "$(git describe --long --tags | tr - .)"
}

prepare() {
  mkdir -p fakeroot

  # CUDA 10 requires gcc7
  sed -e '/CUSTOM_CXX/s/^# //' \
      -e '/CUSTOM_CXX/s/$/-7/' \
      -i caffe/Makefile.config

  # set CUDA directory
  sed '/CUDA_DIR/s/\/usr\/local\/cuda/\/opt\/cuda/' -i caffe/Makefile.config

  # disable python
  sed -e '/PYTHON_INCLUDE/s/^P/# P/g' \
      -e '/PYTHON_LIB/s/^P/# P/g' \
      -i caffe/Makefile.config

  # set OpenBlas
  sed -e '/\/blas/s/^# //g' \
      -e '/^BLAS_INCLUDE/s/\/path\/to\/your\/blas/\$(shell pkg-config --cflags openblas)/g' \
      -e '/^BLAS_LIB/s/\/path\/to\/your\/blas/\$(shell pkg-config --libs-only-L openblas)/g' \
      -i caffe/Makefile.config

  # -- local
  sed -e 's| /usr/local/include||g' \
      -e 's| /usr/local/lib||g' \
      -i caffe/Makefile.config

  # use pkgconfig
  sed "s|+= openblas|+= \$(shell pkg-config --libs openblas \| sed 's\|-l\|\|g')|g" \
      -i caffe/Makefile

  cd "${srcdir}/${_plug}"
  # Set caffe include path
  #sed "s|include_directories(get_option('caffe_includedir'))|include_directories('${srcdir}/fakeroot/include')|g" -i meson.build
  # Set caffe library path
  #sed "s|cc.find_library('caffe', dirs : get_option('caffe_libdir'))|cc.find_library('caffe', dirs: '$(pwd)')|g" -i meson.build
  # Fix opencv4
  sed -e 's/CV_GRAY2RGB/cv::COLOR_GRAY2RGB/g' \
      -e 's/CV_RGB2GRAY/cv::COLOR_RGB2GRAY/g' \
      -e 's/CV_BGR2YUV/cv::COLOR_BGR2YUV/g' \
      -e 's/CV_YUV2BGR/cv::COLOR_YUV2BGR/g' \
      -e 's/CV_BGR2RGB/cv::COLOR_BGR2RGB/g' \
      -e 's/CV_BGRA2RGBA/cv::COLOR_BGRA2RGBA/g' \
      -e 's/CV_BGR2RGBA/cv::COLOR_BGR2RGBA/g' \
      -e 's/CV_BGRA2RGB/cv::COLOR_BGRA2RGB/g' \
      -i Waifu2x-caffe/stImage.cpp Waifu2x-caffe/waifu2x.cpp
  # Fix unknown layer
  echo '#include "caffe/common.hpp"
#include "caffe/layers/input_layer.hpp"
#include "caffe/layers/flatten_layer.hpp"
#include "caffe/layers/scale_layer.hpp"
#include "caffe/layers/crop_layer.hpp"
namespace caffe{
    extern INSTANTIATE_CLASS(InputLayer);
    extern INSTANTIATE_CLASS(FlattenLayer);
    extern INSTANTIATE_CLASS(ScaleLayer);
    extern INSTANTIATE_CLASS(CropLayer);
    //REGISTER_LAYER_CLASS(Scale);
}' > Waifu2x-caffe/addlayer.h
  sed '1i#include "addlayer.h"' -i Waifu2x-caffe/cNet.cpp Waifu2x-caffe/waifu2x.cpp Waifu2x-caffe/Waifu2x-caffe.cpp
  #cd waifu2x-caffe

  # use pkgconfig
  #sed -e 's|-lopenblas|$(shell pkg-config --libs openblas)|g' \
  #    -i Makefile.am

  # link static libcaffe
  #sed 's|-lcaffe|libcaffe.a|g' \
  #    -i Makefile.am

  #./autogen.sh
}

build() {
  cd caffe
  make lib

  install -Dm644 build/lib/libcaffe.a "${srcdir}/waifu2x-caffe/libcaffe.a"
  cp -R include "${srcdir}/fakeroot"
  install -Dm644 build/src/caffe/proto/caffe.pb.h "${srcdir}/fakeroot/include/caffe/proto/caffe.pb.h"

  cd "${srcdir}/${_plug}"
  #CXXFLAGS+=" -I${srcdir}/fakeroot/include" \
  CXXFLAGS+=" -I/usr/include/$(pacman -Qlq opencv | grep -i '^/usr/include.*/$' | cut -d '/' -f 4 | sort | uniq | xargs)" \
    meson build -Dcuda_includedir=/opt/cuda/include -Dcuda_libdir=/opt/cuda/lib64 \
    "-Dcaffe_includedir=$(readlink -e "${srcdir}/fakeroot/include")" \
    "-Dcaffe_libdir=$(pwd)"
  ninja -C build
#  ./configure \
#    --prefix=/usr \
#    --libdir=/usr/lib/vapoursynth

#  make
}

package(){
  cd "${_plug}"
  #make DESTDIR="${pkgdir}" install
  chrpath -d "build/lib${_plug}.so"
  DESTDIR="${pkgdir}" ninja -C build install

  (cd Waifu2x-caffe/models; for i in $(find . -type f); do install -Dm644 "${i}" "${pkgdir}/usr/lib/vapoursynth/models/${i}"; done)
  chmod -R a+w "${pkgdir}/usr/lib/vapoursynth/models"

  install -Dm644 README.md "${pkgdir}/usr/share/doc/vapoursynth/plugins/${_plug}/README.md"
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

fitu996 commented on 2019-01-21 11:47

This is a simple fix for meson build and opencv4. It works for me.

# Maintainer:  Gustavo Alvarez <sl1pkn07@gmail.com>

_plug=waifu2x-caffe
pkgname=vapoursynth-plugin-${_plug}-git
pkgver=r12.1.g56c45a5
pkgrel=1
pkgdesc="Plugin for Vapoursynth: ${_plug} (NVIDIA users only)(static libcaffe)(GIT version)"
arch=('x86_64')
url='http://forum.doom9.org/showthread.php?t=172390'
license=('MIT')
depends=('vapoursynth'
         'boost-libs'
         'libopenblas'
         'google-glog'
         'gflags'
         'hdf5'
         'protobuf'
         'cudnn'
         'opencv'
         )
makedepends=('git'
             'boost'
             'gcc7'
             'meson'
             'ninja'
             'chrpath'
             )
provides=("vapoursynth-plugin-${_plug}")
conflicts=("vapoursynth-plugin-${_plug}")
source=("${_plug}::git+https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Waifu2x-caffe.git"
        'git+https://github.com/HolyWu/caffe.git#branch=lltcggie/custom'
        )
sha256sums=('SKIP'
            'SKIP'
            )

pkgver() {
  cd "${_plug}"
  echo "$(git describe --long --tags | tr - .)"
}

prepare() {
  mkdir -p fakeroot

  # CUDA 10 requires gcc7
  sed -e '/CUSTOM_CXX/s/^# //' \
      -e '/CUSTOM_CXX/s/$/-7/' \
      -i caffe/Makefile.config

  # set CUDA directory
  sed '/CUDA_DIR/s/\/usr\/local\/cuda/\/opt\/cuda/' -i caffe/Makefile.config

  # disable python
  sed -e '/PYTHON_INCLUDE/s/^P/# P/g' \
      -e '/PYTHON_LIB/s/^P/# P/g' \
      -i caffe/Makefile.config

  # set OpenBlas
  sed -e '/\/blas/s/^# //g' \
      -e '/^BLAS_INCLUDE/s/\/path\/to\/your\/blas/\$(shell pkg-config --cflags openblas)/g' \
      -e '/^BLAS_LIB/s/\/path\/to\/your\/blas/\$(shell pkg-config --libs-only-L openblas)/g' \
      -i caffe/Makefile.config

  # -- local
  sed -e 's| /usr/local/include||g' \
      -e 's| /usr/local/lib||g' \
      -i caffe/Makefile.config

  # use pkgconfig
  sed "s|+= openblas|+= \$(shell pkg-config --libs openblas \| sed 's\|-l\|\|g')|g" \
      -i caffe/Makefile

  cd "${srcdir}/${_plug}"
  # Set caffe library path
  sed "s|cc.find_library('caffe')|cc.find_library('caffe', dirs: '$(pwd)')|g" -i meson.build
  # Fix opencv4
  sed -e 's/CV_GRAY2RGB/cv::COLOR_GRAY2RGB/g' \
      -e 's/CV_RGB2GRAY/cv::COLOR_RGB2GRAY/g' \
      -e 's/CV_BGR2YUV/cv::COLOR_BGR2YUV/g' \
      -e 's/CV_YUV2BGR/cv::COLOR_YUV2BGR/g' \
      -e 's/CV_BGR2RGB/cv::COLOR_BGR2RGB/g' \
      -e 's/CV_BGRA2RGBA/cv::COLOR_BGRA2RGBA/g' \
      -e 's/CV_BGR2RGBA/cv::COLOR_BGR2RGBA/g' \
      -e 's/CV_BGRA2RGB/cv::COLOR_BGRA2RGB/g' \
      -i Waifu2x-caffe/stImage.cpp Waifu2x-caffe/waifu2x.cpp
  # Fix unknown layer
  echo '#include "caffe/common.hpp"
#include "caffe/layers/input_layer.hpp"
#include "caffe/layers/flatten_layer.hpp"
#include "caffe/layers/scale_layer.hpp"
#include "caffe/layers/crop_layer.hpp"
namespace caffe{
    extern INSTANTIATE_CLASS(InputLayer);
    extern INSTANTIATE_CLASS(FlattenLayer);
    extern INSTANTIATE_CLASS(ScaleLayer);
    extern INSTANTIATE_CLASS(CropLayer);
    //REGISTER_LAYER_CLASS(Scale);
}' > Waifu2x-caffe/addlayer.h
  sed '1i#include "addlayer.h"' -i Waifu2x-caffe/cNet.cpp Waifu2x-caffe/waifu2x.cpp Waifu2x-caffe/Waifu2x-caffe.cpp
  #cd waifu2x-caffe

  # use pkgconfig
  #sed -e 's|-lopenblas|$(shell pkg-config --libs openblas)|g' \
  #    -i Makefile.am

  # link static libcaffe
  #sed 's|-lcaffe|libcaffe.a|g' \
  #    -i Makefile.am

  #./autogen.sh
}

build() {
  cd caffe
  make lib

  install -Dm644 build/lib/libcaffe.a "${srcdir}/waifu2x-caffe/libcaffe.a"
  cp -R include "${srcdir}/fakeroot"
  install -Dm644 build/src/caffe/proto/caffe.pb.h "${srcdir}/fakeroot/include/caffe/proto/caffe.pb.h"

  cd "${srcdir}/${_plug}"
  CXXFLAGS+=" -I${srcdir}/fakeroot/include" \
    meson build -Dcuda_includedir=/opt/cuda/include -Dcuda_libdir=/opt/cuda/lib64
  ninja -C build
#  ./configure \
#    --prefix=/usr \
#    --libdir=/usr/lib/vapoursynth

#  make
}

package(){
  cd "${_plug}"
  #make DESTDIR="${pkgdir}" install
  chrpath -d "build/lib${_plug}.so"
  install -Dm755 "build/lib${_plug}.so" "${pkgdir}/usr/lib/vapoursynth/lib${_plug}.so"

  (cd Waifu2x-caffe/models; for i in $(find . -type f); do install -Dm644 "${i}" "${pkgdir}/usr/lib/vapoursynth/models/${i}"; done)
  chmod -R a+w "${pkgdir}/usr/lib/vapoursynth/models"

  install -Dm644 README.md "${pkgdir}/usr/share/doc/vapoursynth/plugins/${_plug}/README.md"
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

fitu996 commented on 2019-01-13 02:18

Upstream have switched to meson build system.

sl1pkn07 commented on 2018-01-12 20:16

done

fitu996 commented on 2018-01-12 13:21

CXX src/caffe/util/io.cpp

/bin/sh: g++-5: command not found

make: *** [Makefile:579: .build_release/src/caffe/util/io.o] Error 1

==> ERROR: A failure occurred in build().

Aborting...

fitu996 commented on 2017-08-13 13:23

It works.

Thanks.

sl1pkn07 commented on 2017-08-13 13:17

try now again

fitu996 commented on 2017-08-13 13:08

Still not work:
_________________
==> Starting prepare()...
sed: can't read /CUSTOM_CXX/s/$/-5/: No such file or directory
==> ERROR: A failure occurred in prepare().
Aborting...
==> ERROR: Makepkg was unable to build vapoursynth-plugin-waifu2x-caffe-git.
_________________
I guess you foget to add '-e' to your PKGBUILD at line 49. It seems work perfectly after I manually add '-e' at line 49.

A little suggestion:
Building this package takes times. It should be better to add "-j4" option when using "make".

sl1pkn07 commented on 2017-08-13 12:55

try now

midgard commented on 2017-08-13 12:50

Hi, there are an unquoted ${srcdir}s and ${pkgdir} on lines 81, 103 (twice) and 104 of PKGBUILD. The ones on lines 84 and 85 may also give problems, I think.