about summary refs log tree commit diff
path: root/pkgs/development/python-modules/manga-ocr/default.nix
blob: 7f0371c356ae30dfbbafc0d203d1adb0dcad3cc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  lib,
  fetchFromGitHub,
  buildPythonPackage,
  fire,
  fugashi,
  jaconv,
  loguru,
  numpy,
  pillow,
  pyperclip,
  torch,
  transformers,
  unidic-lite,
  pythonOlder,
}:
buildPythonPackage rec {
  pname = "manga-ocr";
  version = "0.1.11";
  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "kha-white";
    repo = pname;
    rev = "refs/tags/v${version}";
    hash = "sha256-cLmgHBt6HvhY6Hb9yQ425Gk181axnMr+Mp2LxSmPoDg=";
  };

  preBuild = ''
    # remove subproject dedicated to model training
    rm -rf manga_ocr_dev
    # copy assets/example.jpg inside the package
    # required by https://github.com/kha-white/manga-ocr/blob/ba1b0d94a8ef6676b618ba4e5ffe8ce2ab655270/manga_ocr/ocr.py#L27-L30
    # see also package_data.patch
    mkdir manga_ocr/assets
    cp assets/example.jpg manga_ocr/assets/example.jpg
  '';

  patches = [
    # instruct setuptool to copy assets/example.jpg to package when building wheel
    ./package_data.patch
  ];

  propagatedBuildInputs = [
    # taken from requirements.txt
    fire
    fugashi
    jaconv
    loguru
    numpy
    pillow
    pyperclip
    torch
    transformers
    unidic-lite
  ];

  meta = with lib; {
    description = "Optical character recognition for Japanese text, with the main focus being Japanese manga";
    homepage = "https://github.com/kha-white/manga-ocr";
    changelog = "https://github.com/kha-white/manga-ocr/releases/tag/${version}";
    license = licenses.asl20;
    maintainers = with maintainers; [laurent-f1z1];
  };
}