hysts HF staff commited on
Commit
02878af
β€’
1 Parent(s): 2953d5a
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +20 -11
  3. requirements.txt +2 -2
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: πŸ“ˆ
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.36.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 4.36.0
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -2,7 +2,6 @@
2
 
3
  from __future__ import annotations
4
 
5
- import functools
6
  import os
7
  import pathlib
8
  import urllib.request
@@ -24,26 +23,36 @@ def download_sample_images() -> list[pathlib.Path]:
24
  return sorted(image_dir.rglob("*.jpg"))
25
 
26
 
27
- def run(image: PIL.Image.Image, mocr: MangaOcr) -> str:
28
- return mocr(image)
29
 
30
 
31
- mocr = MangaOcr()
32
- fn = functools.partial(run, mocr=mocr)
33
 
34
- image_paths = download_sample_images()
35
- examples = [[path.as_posix()] for path in image_paths]
36
 
37
  with gr.Blocks(css="style.css") as demo:
38
  gr.Markdown(DESCRIPTION)
39
  with gr.Row():
40
  with gr.Column():
41
  image = gr.Image(label="Input", type="pil")
42
- run_button = gr.Button("Run")
43
  with gr.Column():
44
  result = gr.Text(label="Output")
45
  gr.Examples(
46
- examples=examples, inputs=image, outputs=result, fn=fn, cache_examples=os.getenv("CACHE_EXAMPLES") == "1"
 
 
 
 
 
 
 
 
 
47
  )
48
- run_button.click(fn=fn, inputs=image, outputs=result, api_name="run")
49
- demo.queue().launch()
 
 
 
2
 
3
  from __future__ import annotations
4
 
 
5
  import os
6
  import pathlib
7
  import urllib.request
 
23
  return sorted(image_dir.rglob("*.jpg"))
24
 
25
 
26
+ mocr = MangaOcr()
 
27
 
28
 
29
+ def run(image: PIL.Image.Image) -> str:
30
+ return mocr(image)
31
 
32
+
33
+ examples = download_sample_images()
34
 
35
  with gr.Blocks(css="style.css") as demo:
36
  gr.Markdown(DESCRIPTION)
37
  with gr.Row():
38
  with gr.Column():
39
  image = gr.Image(label="Input", type="pil")
40
+ run_button = gr.Button()
41
  with gr.Column():
42
  result = gr.Text(label="Output")
43
  gr.Examples(
44
+ examples=examples,
45
+ inputs=image,
46
+ outputs=result,
47
+ fn=run,
48
+ )
49
+ run_button.click(
50
+ fn=run,
51
+ inputs=image,
52
+ outputs=result,
53
+ api_name="run",
54
  )
55
+
56
+
57
+ if __name__ == "__main__":
58
+ demo.queue().launch()
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- manga_ocr==0.1.10
2
- Pillow==9.5.0
 
1
+ manga_ocr==0.1.11
2
+ Pillow==10.3.0