fix PIL imports
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
__version__ = '0.1.3'
|
__version__ = '0.1.4'
|
||||||
|
|
||||||
from manga_ocr.ocr import MangaOcr
|
from manga_ocr.ocr import MangaOcr
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import PIL.Image
|
|
||||||
import fire
|
import fire
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pyperclip
|
import pyperclip
|
||||||
|
from PIL import Image
|
||||||
|
from PIL import UnidentifiedImageError
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from manga_ocr import MangaOcr
|
from manga_ocr import MangaOcr
|
||||||
@@ -58,7 +59,7 @@ def run(read_from='clipboard',
|
|||||||
mocr = MangaOcr(pretrained_model_name_or_path, force_cpu)
|
mocr = MangaOcr(pretrained_model_name_or_path, force_cpu)
|
||||||
|
|
||||||
if read_from == 'clipboard':
|
if read_from == 'clipboard':
|
||||||
import PIL.ImageGrab
|
from PIL import ImageGrab
|
||||||
logger.info('Reading from clipboard')
|
logger.info('Reading from clipboard')
|
||||||
|
|
||||||
img = None
|
img = None
|
||||||
@@ -66,11 +67,11 @@ def run(read_from='clipboard',
|
|||||||
old_img = img
|
old_img = img
|
||||||
|
|
||||||
try:
|
try:
|
||||||
img = PIL.ImageGrab.grabclipboard()
|
img = ImageGrab.grabclipboard()
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.warning('Error while reading from clipboard')
|
logger.warning('Error while reading from clipboard')
|
||||||
else:
|
else:
|
||||||
if isinstance(img, PIL.Image.Image) and not are_images_identical(img, old_img):
|
if isinstance(img, Image.Image) and not are_images_identical(img, old_img):
|
||||||
process_and_write_results(mocr, img, write_to)
|
process_and_write_results(mocr, img, write_to)
|
||||||
|
|
||||||
time.sleep(delay_secs)
|
time.sleep(delay_secs)
|
||||||
@@ -93,8 +94,8 @@ def run(read_from='clipboard',
|
|||||||
old_paths.add(path)
|
old_paths.add(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
img = PIL.Image.open(path)
|
img = Image.open(path)
|
||||||
except PIL.UnidentifiedImageError:
|
except UnidentifiedImageError:
|
||||||
logger.warning(f'Error while reading file {path}')
|
logger.warning(f'Error while reading file {path}')
|
||||||
else:
|
else:
|
||||||
process_and_write_results(mocr, img, write_to)
|
process_and_write_results(mocr, img, write_to)
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ long_description = (Path(__file__).parent / "README.md").read_text('utf-8').spli
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="manga-ocr",
|
name="manga-ocr",
|
||||||
version='0.1.3',
|
version='0.1.4',
|
||||||
description="OCR for Japanese manga",
|
description="OCR for Japanese manga",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|||||||
Reference in New Issue
Block a user