diff --git a/ITServer.log b/ITServer.log index 49c4181..d855170 100644 --- a/ITServer.log +++ b/ITServer.log @@ -304,3 +304,441 @@ RuntimeError: 이미지 저장 중 오류 발생: The truth value of an array wi [2025-07-04 02:20:54,459] [MainThread] [INFO] [image_processor2.py:process_single_image:114] 텍스트 렌더링 완료 [2025-07-04 02:20:54,469] [MainThread] [INFO] [postImageManager.py:save_image_to_path:38] 이미지 저장 완료 : D:\py\IT_Server\temp_images\translated_multi_img_7.png [2025-07-04 02:20:54,506] [MainThread] [INFO] [image_processor2.py:process_single_image:118] 이미지 7 번역 완료: D:\py\IT_Server\temp_images\translated_multi_img_7.png +[2025-07-04 18:18:17,681] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: No module named 'paddleocr' +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR +ModuleNotFoundError: No module named 'paddleocr' + +[2025-07-04 18:18:17,703] [MainThread] [INFO] [image_processor2.py:cleanup:50] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 18:19:41,931] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 18:19:42,000] [MainThread] [INFO] [image_processor2.py:cleanup:50] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 19:32:19,168] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: Unknown argument: use_gpu +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 33, in initialize_ocr + ocr = PaddleOCR( + ^^^^^^^^^^ + File "D:\py\IT_Server\Lib\site-packages\paddleocr\_pipelines\ocr.py", line 161, in __init__ + super().__init__(**base_params) + File "D:\py\IT_Server\Lib\site-packages\paddleocr\_pipelines\base.py", line 62, in __init__ + self._common_args = parse_common_args( + ^^^^^^^^^^^^^^^^^^ + File "D:\py\IT_Server\Lib\site-packages\paddleocr\_common_args.py", line 43, in parse_common_args + raise ValueError(f"Unknown argument: {name}") +ValueError: Unknown argument: use_gpu + +[2025-07-04 19:32:19,245] [MainThread] [INFO] [image_processor2.py:cleanup:50] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 19:33:10,399] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 19:33:10,483] [MainThread] [INFO] [image_processor2.py:cleanup:50] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 19:39:14,900] [MainThread] [INFO] [mask_module.py:__init__:12] 마스크 모듈 초기화 완료 +[2025-07-04 19:39:14,901] [MainThread] [DEBUG] [postImageManager.py:font_load:22] 폰트 로드 성공: D:\py\IT_Server\modules\fonts\HakgyoansimDunggeunmisoTTFB.ttf +[2025-07-04 19:39:14,967] [MainThread] [INFO] [image_processor2.py:cleanup:50] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 19:43:45,223] [MainThread] [INFO] [mask_module.py:__init__:12] 마스크 모듈 초기화 완료 +[2025-07-04 19:43:45,224] [MainThread] [DEBUG] [postImageManager.py:font_load:22] 폰트 로드 성공: D:\py\IT_Server\modules\fonts\HakgyoansimDunggeunmisoTTFB.ttf +[2025-07-04 19:48:18,222] [MainThread] [INFO] [image_processor2.py:cleanup:50] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:04:18,065] [MainThread] [INFO] [mask_module.py:__init__:12] 마스크 모듈 초기화 완료 +[2025-07-04 20:04:18,065] [MainThread] [DEBUG] [postImageManager.py:font_load:22] 폰트 로드 성공: D:\py\IT_Server\modules\fonts\HakgyoansimDunggeunmisoTTFB.ttf +[2025-07-04 20:04:18,066] [MainThread] [INFO] [iop_Manager.py:_start_instances:73] IOPaint 인스턴스 1 개 시작 +[2025-07-04 20:04:18,066] [MainThread] [INFO] [iop_Manager.py:_start_instances:78] [7026] 인스턴스 실행 명령: D:\py\IT_Server\modules\iop\iop.exe start --model=migan --device=cpu --port 7026 --model-dir D:\py\IT_Server\modules\iop\models +[2025-07-04 20:04:18,132] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:15:10,769] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:15:10,849] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:16:11,790] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:16:11,876] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:18:27,628] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:18:27,697] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:18:35,762] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:18:35,834] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:19:00,214] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:19:00,293] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:27:04,149] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:27:04,231] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:30:08,995] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:30:09,065] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:31:30,942] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:31:31,022] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:32:33,354] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: No module named 'paddle' +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 21, in + from paddle.utils import try_import +ModuleNotFoundError: No module named 'paddle' + +[2025-07-04 20:32:33,378] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:33:10,059] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:33:10,148] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 20:37:38,096] [MainThread] [ERROR] [ocr_module.py:initialize_ocr:43] ❌ PaddleOCR 초기화 실패: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. +Traceback (most recent call last): + File "D:\py\IT_Server\modules\ocr_module.py", line 31, in initialize_ocr + from paddleocr import PaddleOCR + File "D:\py\IT_Server\Lib\site-packages\paddleocr\__init__.py", line 14, in + from .paddleocr import ( + File "D:\py\IT_Server\Lib\site-packages\paddleocr\paddleocr.py", line 64, in + from tools.infer import predict_system + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_system.py", line 33, in + import tools.infer.predict_det as predict_det + File "D:\py\IT_Server\Lib\site-packages\paddleocr\tools\infer\predict_det.py", line 31, in + from ppocr.data import create_operators, transform + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\__init__.py", line 35, in + from ppocr.data.imaug import transform, create_operators + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\__init__.py", line 19, in + from .iaa_augment import IaaAugment + File "D:\py\IT_Server\Lib\site-packages\paddleocr\ppocr\data\imaug\iaa_augment.py", line 24, in + import albumentations as A + File "D:\py\IT_Server\Lib\site-packages\albumentations\__init__.py", line 24, in + from .pytorch import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\__init__.py", line 1, in + from .transforms import * + File "D:\py\IT_Server\Lib\site-packages\albumentations\pytorch\transforms.py", line 15, in + import torch + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 270, in + _load_dll_libraries() + File "D:\py\IT_Server\Lib\site-packages\torch\__init__.py", line 253, in _load_dll_libraries + raise err +OSError: [WinError 127] 지정된 프로시저를 찾을 수 없습니다. Error loading "D:\py\IT_Server\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies. + +[2025-07-04 20:37:38,184] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 21:14:22,646] [MainThread] [INFO] [mask_module.py:__init__:12] 마스크 모듈 초기화 완료 +[2025-07-04 21:14:22,647] [MainThread] [DEBUG] [postImageManager.py:font_load:22] 폰트 로드 성공: D:\py\IT_Server\modules\fonts\HakgyoansimDunggeunmisoTTFB.ttf +[2025-07-04 21:14:22,917] [MainThread] [INFO] [image_processor2.py:cleanup:53] 임시 폴더 삭제됨: D:\py\IT_Server\temp_images +[2025-07-04 21:15:59,637] [MainThread] [INFO] [mask_module.py:__init__:12] 마스크 모듈 초기화 완료 +[2025-07-04 21:15:59,638] [MainThread] [DEBUG] [postImageManager.py:font_load:22] 폰트 로드 성공: D:\py\IT_Server\modules\fonts\HakgyoansimDunggeunmisoTTFB.ttf +[2025-07-04 21:15:59,638] [MainThread] [INFO] [iop_server.py:start:31] [IOPaint] 실행 환경 파이썬: D:\py\IT_Server\scripts\python.exe +[2025-07-04 21:15:59,638] [MainThread] [INFO] [iop_server.py:start:32] [IOPaint] 실행 명령: D:\py\IT_Server\scripts\python.exe -m iopaint start --model=migan --device=cpu --port 7024 --model-dir D:\py\IT_Server\iop\models +[2025-07-04 21:15:59,639] [MainThread] [INFO] [iop_server.py:start:33] [IOPaint] 모델 디렉토리: D:\py\IT_Server\iop\models +[2025-07-04 21:16:00,355] [MainThread] [WARNING] [iop_server.py:start:41] [IOPaint] iopaint 모듈이 현재 환경에 설치되어 있지 않습니다! +[2025-07-04 21:16:00,358] [MainThread] [INFO] [iop_server.py:start:47] [IOPaint] 서버 준비 확인 시작 (최대 30초 대기) +[2025-07-04 21:16:06,898] [MainThread] [INFO] [iop_server.py:start:68] [IOPaint] 서버가 포트 7024에서 준비됨. +[2025-07-04 21:17:17,178] [MainThread] [INFO] [ocr_module.py:detect_text:75] 🔍 OCR 감지 방식: polygon +[2025-07-04 21:17:17,599] [MainThread] [INFO] [ocr_module.py:detect_text:81] ocr_raw_results: [[[[[57.0, 44.0], [708.0, 44.0], [708.0, 122.0], [57.0, 122.0]], ('高质量水晶相纸', 0.9983320236206055)], [[[76.0, 195.0], [373.0, 195.0], [373.0, 225.0], [76.0, 225.0]], ('适合各种喷墨打印机', 0.993870735168457)], [[[74.0, 263.0], [348.0, 263.0], [348.0, 294.0], [74.0, 294.0]], ('色彩艳丽还原度高', 0.9967601895332336)], [[[401.0, 260.0], [464.0, 260.0], [464.0, 277.0], [401.0, 277.0]], ('Colors', 0.9959213137626648)], [[[529.0, 259.0], [718.0, 259.0], [718.0, 283.0], [529.0, 283.0]], ('高质量水晶相纸', 0.9965673089027405)], [[[397.0, 273.0], [514.0, 271.0], [514.0, 292.0], [397.0, 294.0]], ('Beautiful彩丽', 0.8809203505516052)], [[[72.0, 324.0], [346.0, 324.0], [346.0, 355.0], [72.0, 355.0]], ('打印快干多种规格', 0.9959524273872375)], [[[428.0, 382.0], [441.0, 382.0], [441.0, 389.0], [428.0, 389.0]], ('12', 0.768598198890686)], [[[452.0, 576.0], [499.0, 576.0], [499.0, 613.0], [452.0, 613.0]], ('4R', 0.9986311793327332)], [[[428.0, 599.0], [442.0, 599.0], [442.0, 614.0], [428.0, 614.0]], ('20', 0.964126706123352)], [[[428.0, 619.0], [448.0, 619.0], [448.0, 636.0], [428.0, 636.0]], ('100', 0.9982807636260986)], [[[412.0, 640.0], [449.0, 640.0], [449.0, 654.0], [412.0, 654.0]], ('SHEETS', 0.9623520970344543)], [[[463.0, 633.0], [495.0, 633.0], [495.0, 653.0], [463.0, 653.0]], ('230', 0.9994370937347412)], [[[459.0, 654.0], [495.0, 654.0], [495.0, 672.0], [459.0, 672.0]], ('g/m"', 0.7422822713851929)]]] +[2025-07-04 21:17:17,600] [MainThread] [INFO] [ocr_module.py:detect_text:83] line: [[[[57.0, 44.0], [708.0, 44.0], [708.0, 122.0], [57.0, 122.0]], ('高质量水晶相纸', 0.9983320236206055)], [[[76.0, 195.0], [373.0, 195.0], [373.0, 225.0], [76.0, 225.0]], ('适合各种喷墨打印机', 0.993870735168457)], [[[74.0, 263.0], [348.0, 263.0], [348.0, 294.0], [74.0, 294.0]], ('色彩艳丽还原度高', 0.9967601895332336)], [[[401.0, 260.0], [464.0, 260.0], [464.0, 277.0], [401.0, 277.0]], ('Colors', 0.9959213137626648)], [[[529.0, 259.0], [718.0, 259.0], [718.0, 283.0], [529.0, 283.0]], ('高质量水晶相纸', 0.9965673089027405)], [[[397.0, 273.0], [514.0, 271.0], [514.0, 292.0], [397.0, 294.0]], ('Beautiful彩丽', 0.8809203505516052)], [[[72.0, 324.0], [346.0, 324.0], [346.0, 355.0], [72.0, 355.0]], ('打印快干多种规格', 0.9959524273872375)], [[[428.0, 382.0], [441.0, 382.0], [441.0, 389.0], [428.0, 389.0]], ('12', 0.768598198890686)], [[[452.0, 576.0], [499.0, 576.0], [499.0, 613.0], [452.0, 613.0]], ('4R', 0.9986311793327332)], [[[428.0, 599.0], [442.0, 599.0], [442.0, 614.0], [428.0, 614.0]], ('20', 0.964126706123352)], [[[428.0, 619.0], [448.0, 619.0], [448.0, 636.0], [428.0, 636.0]], ('100', 0.9982807636260986)], [[[412.0, 640.0], [449.0, 640.0], [449.0, 654.0], [412.0, 654.0]], ('SHEETS', 0.9623520970344543)], [[[463.0, 633.0], [495.0, 633.0], [495.0, 653.0], [463.0, 653.0]], ('230', 0.9994370937347412)], [[[459.0, 654.0], [495.0, 654.0], [495.0, 672.0], [459.0, 672.0]], ('g/m"', 0.7422822713851929)]] +[2025-07-04 21:17:17,601] [MainThread] [INFO] [ocr_module.py:filter_chinese_text:137] 중국어 텍스트 6개 필터링 완료 +[2025-07-04 21:17:22,501] [MainThread] [INFO] [image_processor2.py:process_translated_texts:234] 최종 치환 결과: ['고품질 크리스탈 사진지', '모든 잉크젯 프린터에 적합', '색상이 선명하고 재현도가 높음', '색상', '고품질 크리스탈 사진지', '아름다운 화려함', '빠른 건조, 다양한 규격', '12', '4R', '20', '100', '장', '230', 'g/m²'] +[2025-07-04 21:17:22,502] [MainThread] [INFO] [image_processor2.py:process_single_image:102] 이미지 1 치환됨 +[2025-07-04 21:17:22,508] [MainThread] [INFO] [image_processor2.py:process_single_image:108] 마스크 생성 완료 +[2025-07-04 21:17:31,648] [MainThread] [INFO] [image_processor2.py:process_single_image:112] 인페인팅 완료 +[2025-07-04 21:17:31,714] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 텍스트 렌더링 완료 +[2025-07-04 21:17:31,725] [MainThread] [INFO] [postImageManager.py:save_image_to_path:38] 이미지 저장 완료 : D:\py\IT_Server\temp_images\translated_test_img_1.png +[2025-07-04 21:17:31,806] [MainThread] [INFO] [image_processor2.py:process_single_image:121] 이미지 1 번역 완료: D:\py\IT_Server\temp_images\translated_test_img_1.png diff --git a/iop/models/huggingface/hub/version.txt b/iop/models/huggingface/hub/version.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/iop/models/huggingface/hub/version.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/iop/models/huggingface/hub/version_diffusers_cache.txt b/iop/models/huggingface/hub/version_diffusers_cache.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/iop/models/huggingface/hub/version_diffusers_cache.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/iop/models/torch/hub/checkpoints/migan_traced.pt b/iop/models/torch/hub/checkpoints/migan_traced.pt new file mode 100644 index 0000000..88d2979 Binary files /dev/null and b/iop/models/torch/hub/checkpoints/migan_traced.pt differ diff --git a/main.py b/main.py index 04debd2..28d0821 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from modules.image_translate_server import run_server from modules.image_processor2 import ImageProcessor from modules.loggerModule import Logger1 from modules.gpt_client import GPTClient +from modules.iop_server import IOPaint_Server import sys, os @@ -21,6 +22,11 @@ def get_base_dir(): base_dir = os.path.dirname(os.path.abspath(__file__)) debug_dir = os.path.join(base_dir) # lib 디렉토리 포함 return debug_dir + +def run_iop_server(logger, base_dir): + iop_server = IOPaint_Server(logger=logger, base_dir=base_dir) + iop_port = iop_server.start() + return iop_port def main(): parser = argparse.ArgumentParser(description="이미지 번역 FastAPI 서버 실행") @@ -37,8 +43,12 @@ def main(): image_processor = ImageProcessor(logger, gpt_client, base_dir, font_path) + iop_port = run_iop_server(logger, base_dir) + image_processor.update_iop_port(iop_port) + port = run_server(image_processor, max_workers) - print(f"서버가 127.0.0.1:{port} 에서 실행 중입니다.") + print(f"이미지번역서버가 127.0.0.1:{port} 에서 실행 중입니다.") + if __name__ == "__main__": main() diff --git a/modules/image_processor2.py b/modules/image_processor2.py index c00fc14..dc18060 100644 --- a/modules/image_processor2.py +++ b/modules/image_processor2.py @@ -24,8 +24,8 @@ class ImageProcessor: self.base_dir = base_dir self.gpt_client = gpt_client - # OCR 관련 - self.inpaint_sv_port = 8080 + # 인페인트 포트 + self.inpaint_sv_port = None self.font_path = font_path self.TEMP_IMAGE_DIR = os.path.join(self.base_dir, "temp_images") @@ -39,6 +39,9 @@ class ImageProcessor: def __del__(self): """소멸자에서 리소스 정리""" self.cleanup() + + def update_iop_port(self, port): + self.inpaint_sv_port = port def cleanup(self): """리소스 정리""" @@ -179,7 +182,7 @@ class ImageProcessor: else: mask_np = mask - api_url = f"http://localhost:{self.inpaint_sv_port}/api/v1/inpaint" + api_url = f"http://127.0.0.1:{self.inpaint_sv_port}/api/v1/inpaint" _, img_encoded = cv2.imencode('.png', image_np) _, mask_encoded = cv2.imencode('.png', mask_np) img_b64 = base64.b64encode(img_encoded).decode('utf-8') diff --git a/modules/image_translate_server.py b/modules/image_translate_server.py index d21f488..7374bd7 100644 --- a/modules/image_translate_server.py +++ b/modules/image_translate_server.py @@ -9,7 +9,7 @@ from concurrent.futures import ThreadPoolExecutor from modules.image_processor2 import ImageProcessor # 포트 범위 설정 -PORT_RANGE = (7000, 7000) +PORT_RANGE = (7000, 7010) # 사용 가능한 포트 찾기 def find_free_port(): diff --git a/modules/iop/models/huggingface/hub/version.txt b/modules/iop/models/huggingface/hub/version.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/modules/iop/models/huggingface/hub/version.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/modules/iop/models/huggingface/hub/version_diffusers_cache.txt b/modules/iop/models/huggingface/hub/version_diffusers_cache.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/modules/iop/models/huggingface/hub/version_diffusers_cache.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/modules/iop/models/torch/hub/checkpoints/migan_traced.pt b/modules/iop/models/torch/hub/checkpoints/migan_traced.pt new file mode 100644 index 0000000..88d2979 Binary files /dev/null and b/modules/iop/models/torch/hub/checkpoints/migan_traced.pt differ diff --git a/modules/iop_Manager.py b/modules/iop_Manager.py index 98421c3..e248728 100644 --- a/modules/iop_Manager.py +++ b/modules/iop_Manager.py @@ -26,14 +26,15 @@ class IOPaintManager: def is_alive(self): return self.process.poll() is None - def __init__(self, logger, num_instances=1, port_range=(8099, 8199), base_dir=None, wait_ready=30, model_dir=None): + def __init__(self, logger, base_dir, num_instances=1, port_range=(7020, 7030), wait_ready=30, model_dir=None): self.logger = logger + self.base_dir = base_dir + self.iop_port = None self.instances = [] self.port_range = port_range self.lock = threading.Lock() - self.base_dir = base_dir or os.getcwd() - self.model_dir = model_dir or os.path.join(self.base_dir, 'iop', 'models') - self.exe_path = os.path.join(self.base_dir, 'iop', 'iop.exe') + self.model_dir = model_dir or os.path.join(self.base_dir, 'modules', 'iop', 'models') + self.exe_path = os.path.join(self.base_dir, 'modules', 'iop', 'iop.exe') self._start_instances(num_instances, wait_ready) def _get_random_port(self): @@ -72,14 +73,17 @@ class IOPaintManager: self.logger.log(f"IOPaint 인스턴스 {num} 개 시작", level=logging.INFO) for _ in range(num): port = self._get_random_port() - cmd = [self.exe_path, 'start', '--model=lama', '--device=cpu', '--port', str(port), '--model-dir', self.model_dir] + self.iop_port = port + cmd = [self.exe_path, 'start', '--model=migan', '--device=cpu', '--port', str(port), '--model-dir', self.model_dir] self.logger.log(f"[{port}] 인스턴스 실행 명령: {' '.join(cmd)}", level=logging.INFO) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) instance = self.ServerInstance(port, proc) self.instances.append(instance) + start_wait = 8 - time.sleep(start_wait) self.logger.log(f"[{port}] 인스턴스 실행 명시대기: {start_wait}초", level=logging.INFO) + time.sleep(start_wait) + if self.wait_for_server_ready(port, timeout=wait_ready): self.logger.log(f"IOPaint 인스턴스 {instance.port} 준비됨", level=logging.INFO) else: @@ -191,9 +195,8 @@ class IOPaintManager: return instance - # if __name__ == '__main__': -# manager = IOPaintManager(num_instances=1) -# # result = manager.inpaint(image, mask) # 자동으로 idle 인스턴스에 요청 -# print(manager.get_instance_info()) -# manager.shutdown_all() \ No newline at end of file + # manager = IOPaintManager(num_instances=1) + # result = manager.inpaint(image, mask) # 자동으로 idle 인스턴스에 요청 + # print(manager.get_instance_info()) + # manager.shutdown_all() diff --git a/modules/iop_server.py b/modules/iop_server.py new file mode 100644 index 0000000..3b3b098 --- /dev/null +++ b/modules/iop_server.py @@ -0,0 +1,91 @@ +import subprocess +import logging +import socket +import random +import time +import os +import sys + +class IOPaint_Server: + def __init__(self, logger, base_dir): + self.logger = logger + self.base_dir = base_dir + + def find_free_port(self, port_range=(7020, 7030)): + """포트 범위 내에서 사용 가능한 포트 반환""" + for _ in range(20): + port = random.randint(*port_range) + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + try: + s.bind(("0.0.0.0", port)) + return port + except OSError: + continue + raise RuntimeError("사용 가능한 포트를 찾을 수 없습니다.") + + def start(self, wait_ready=30): + """iopaint 서버를 실행하고, 정상 실행시 포트 반환""" + port = self.find_free_port() + model_dir = os.path.join(self.base_dir, 'iop', 'models') + cmd = [sys.executable, '-m', 'iopaint', 'start', '--model=migan', '--device=cpu', '--port', str(port), '--model-dir', model_dir] + self.logger.log(f"[IOPaint] 실행 환경 파이썬: {sys.executable}", level=logging.INFO) + self.logger.log(f"[IOPaint] 실행 명령: {' '.join(cmd)}", level=logging.INFO) + self.logger.log(f"[IOPaint] 모델 디렉토리: {model_dir}", level=logging.INFO) + # pip list로 iopaint 설치여부 확인 + try: + pip_list = subprocess.check_output([sys.executable, '-m', 'pip', 'list'], text=True) + found = any('iopaint' in line for line in pip_list.splitlines()) + if found: + self.logger.log("[IOPaint] iopaint 모듈이 현재 환경에 설치되어 있습니다.", level=logging.INFO) + else: + self.logger.log("[IOPaint] iopaint 모듈이 현재 환경에 설치되어 있지 않습니다!", level=logging.WARNING) + except Exception as e: + self.logger.log(f"[IOPaint] pip list 실행 실패: {e}", level=logging.ERROR, exc_info=True) + + # subprocess를 실시간 출력으로 실행 + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1) + self.logger.log(f"[IOPaint] 서버 준비 확인 시작 (최대 {wait_ready}초 대기)", level=logging.INFO) + url = f"http://localhost:{port}/api/v1/server-config" + start_time = time.time() + stdout_lines = [] + stderr_lines = [] + import threading + def read_stream(stream, lines, stream_name): + for line in iter(stream.readline, ''): + lines.append(line) + print(f"[{stream_name}] {line}", end='') + stream.close() + t_out = threading.Thread(target=read_stream, args=(proc.stdout, stdout_lines, 'STDOUT')) + t_err = threading.Thread(target=read_stream, args=(proc.stderr, stderr_lines, 'STDERR')) + t_out.start() + t_err.start() + ready = False + while time.time() - start_time < wait_ready: + try: + import requests + r = requests.get(url, timeout=2) + if r.status_code == 200: + self.logger.log(f"[IOPaint] 서버가 포트 {port}에서 준비됨.") + ready = True + break + except Exception as e: + time.sleep(0.5) + t_out.join(timeout=2) + t_err.join(timeout=2) + if ready: + return port + # 실패 시 로그 및 예외 + self.logger.log(f"[IOPaint] 서버 실행 실패.\nstdout:\n{''.join(stdout_lines)}\nstderr:\n{''.join(stderr_lines)}", level=logging.ERROR, exc_info=True) + print("[IOPaint] 서버 실행 실패. 전체 STDOUT:") + print(''.join(stdout_lines)) + print("[IOPaint] 서버 실행 실패. 전체 STDERR:") + print(''.join(stderr_lines)) + raise RuntimeError(f"IOPaint 서버가 {wait_ready}초 내에 준비되지 않았습니다.") + +# if __name__ == "__main__": +# logging.basicConfig(level=logging.INFO) +# logger = logging.getLogger(__name__) +# base_dir = os.path.dirname(os.path.abspath(__file__)) +# iop = IOPaint(logger, base_dir) +# iop.start() + diff --git a/modules/local_image_server.py b/modules/local_image_server.py deleted file mode 100644 index caad46c..0000000 --- a/modules/local_image_server.py +++ /dev/null @@ -1,131 +0,0 @@ -import os -import socket -import threading -from http.server import HTTPServer, SimpleHTTPRequestHandler -import logging - - -class LocalImageServer: - """로컬 이미지 파일을 웹에서 접근 가능하도록 하는 HTTP 서버""" - - def __init__(self, logger, image_dir, port=8000): - self.logger = logger - self.image_dir = os.path.abspath(image_dir) # 절대 경로로 변환 - self.original_cwd = os.getcwd() # 원래 작업 디렉토리 저장 - self.port = self.find_available_port(port) - self.server = None - self.server_thread = None - - def find_available_port(self, start_port=8000, max_port=8100): - """사용 가능한 포트를 찾습니다""" - for port in range(start_port, max_port + 1): - try: - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.bind(('localhost', port)) - return port - except OSError: - continue - raise RuntimeError(f"포트 {start_port}-{max_port} 범위에서 사용 가능한 포트를 찾을 수 없습니다.") - - def start_server(self): - """HTTP 서버를 시작합니다""" - if self.server_thread and self.server_thread.is_alive(): - self.logger.log(f"로컬 이미지 서버가 이미 포트 {self.port}에서 실행 중입니다.", level=logging.DEBUG) - return - - # 이미지 디렉토리 존재 확인 - if not os.path.exists(self.image_dir): - try: - os.makedirs(self.image_dir, exist_ok=True) - self.logger.log(f"이미지 디렉토리 생성: {self.image_dir}", level=logging.INFO) - except Exception as e: - self.logger.log(f"이미지 디렉토리 생성 실패: {e}", level=logging.ERROR) - raise - - try: - # 작업 디렉토리 변경 없이 CustomHandler에서 직접 경로 처리 - class CustomHandler(SimpleHTTPRequestHandler): - def __init__(self, *args, image_directory=None, **kwargs): - self.image_directory = image_directory - super().__init__(*args, **kwargs) - - def translate_path(self, path): - """요청 경로를 이미지 디렉토리 내의 실제 파일 경로로 변환""" - # 기본 translate_path 호출하여 상대 경로 얻기 - path = super().translate_path(path) - # 현재 작업 디렉토리 대신 이미지 디렉토리 사용 - rel_path = os.path.relpath(path, os.getcwd()) - return os.path.join(self.image_directory, rel_path) - - def log_message(self, format, *args): - # 로그 출력을 비활성화 (너무 많은 로그 방지) - pass - - def end_headers(self): - # CORS 헤더 추가 - self.send_header('Access-Control-Allow-Origin', '*') - self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS') - self.send_header('Access-Control-Allow-Headers', 'Content-Type') - super().end_headers() - - # 핸들러에 이미지 디렉토리 전달 - def handler_factory(*args, **kwargs): - return CustomHandler(*args, image_directory=self.image_dir, **kwargs) - - self.server = HTTPServer(('localhost', self.port), handler_factory) - self.server_thread = threading.Thread(target=self.server.serve_forever, daemon=True) - self.server_thread.start() - - self.logger.log(f"로컬 이미지 서버가 포트 {self.port}에서 시작되었습니다. (디렉토리: {self.image_dir})", level=logging.INFO) - - except Exception as e: - self.logger.log(f"로컬 웹서버 시작 실패: {e}", level=logging.ERROR) - # 실패 시 상태 정리 - self.server = None - self.server_thread = None - raise - - def stop_server(self): - """HTTP 서버를 중지합니다""" - if self.server: - try: - self.server.shutdown() - self.server.server_close() - if self.server_thread and self.server_thread.is_alive(): - self.server_thread.join(timeout=5) - self.logger.log("로컬 이미지 서버가 중지되었습니다.", level=logging.INFO) - except Exception as e: - self.logger.log(f"로컬 웹서버 중지 중 오류 발생: {e}", level=logging.ERROR) - finally: - self.server = None - self.server_thread = None - - def restart_server(self): - """서버를 재시작합니다""" - self.logger.log("로컬 이미지 서버 재시작 중...", level=logging.INFO) - self.stop_server() - # 새로운 포트 찾기 - self.port = self.find_available_port(self.port) - self.start_server() - - def get_base_url(self): - """서버의 기본 URL을 반환합니다""" - return f"http://localhost:{self.port}" - - def is_running(self): - """서버가 실행 중인지 확인합니다""" - return self.server is not None and self.server_thread and self.server_thread.is_alive() - - def get_file_url(self, filename): - """특정 파일의 URL을 반환합니다""" - if not self.is_running(): - self.logger.log("서버가 실행되지 않았습니다.", level=logging.WARNING) - return None - return f"{self.get_base_url()}/{filename}" - - def __del__(self): - """소멸자에서 서버 정리""" - try: - self.stop_server() - except: - pass \ No newline at end of file diff --git a/modules/ocr_module_mmocr.py b/modules/ocr_module_mmocr.py new file mode 100644 index 0000000..e8c3f2d --- /dev/null +++ b/modules/ocr_module_mmocr.py @@ -0,0 +1,64 @@ +import os +import cv2 +import numpy as np +import logging +from typing import List, Dict, Any +from mmocr.apis import TextDetInferencer, TextRecogInferencer + +class OCRModule: + def __init__(self, det_config: str, det_checkpoint: str, + rec_config: str, rec_checkpoint: str, + logger=None): + self.logger = logger or logging.getLogger(__name__) + os.environ['CUDA_VISIBLE_DEVICES'] = '' + + # MMOCR detection 및 recognition inferencer 초기화 + self.det_infer = TextDetInferencer(model=dict(config=det_config, ckpt=det_checkpoint), device='cpu') + self.rec_infer = TextRecogInferencer(model=dict(config=rec_config, ckpt=rec_checkpoint), device='cpu') + self.logger.info("✅ MMOCR detection 및 recognition 모델 초기화 완료") + + def detect_text(self, image_path: str, method: str = 'polygon') -> List[Dict[str, Any]]: + if not os.path.exists(image_path): + self.logger.error(f"이미지 파일을 찾을 수 없습니다: {image_path}") + return [] + + img = cv2.imread(image_path) + if img is None: + self.logger.error(f"이미지를 읽을 수 없습니다: {image_path}") + return [] + self.logger.info(f"❇️ OCR 감지(method={method}) 시작") + + # 1) 텍스트 영역 감지 + det_res = self.det_infer(image_path) + polys = det_res[0]['boundary_result'] + self.logger.info(f"👉 감지된 텍스트 영역 수: {len(polys)}") + + # 2) 영역 crop 후 recognition + crops = [self._crop_poly(img, poly) for poly in polys] + rec_res = self.rec_infer(crops) + self.logger.info("📖 텍스트 인식 완료") + + ocr_results = [] + for poly, rec in zip(polys, rec_res): + text, score = rec + x, y, w, h = cv2.boundingRect(np.array(poly, dtype=np.int32)) + ocr_results.append({ + 'text': text, + 'confidence': float(score), + 'polygon': poly, + 'bbox': (int(x), int(y), int(w), int(h)), + 'method': method + }) + + return ocr_results + + def filter_chinese_text(self, ocr_results: List[Dict]) -> List[Dict]: + chinese = [r for r in ocr_results if any('\u4e00' <= c <= '\u9fff' for c in r['text'])] + self.logger.info(f"중국어 텍스트 {len(chinese)}개 필터링 완료") + return chinese + + def _crop_poly(self, img: np.ndarray, poly: List[List[int]]) -> np.ndarray: + mask = np.zeros(img.shape[:2], dtype=np.uint8) + cv2.fillPoly(mask, [np.array(poly, dtype=np.int32)], 255) + x, y, w, h = cv2.boundingRect(np.array(poly, dtype=np.int32)) + return cv2.bitwise_and(img[y:y+h, x:x+w], img[y:y+h, x:x+w], mask=mask[y:y+h, x:x+w]) diff --git a/modules/test_translate_api.py b/modules/test_translate_api.py index 79578c8..bcc28f1 100644 --- a/modules/test_translate_api.py +++ b/modules/test_translate_api.py @@ -1,13 +1,14 @@ import requests import json -API_URL = "http://127.0.0.1:7000/translate_image" +# API_URL = "http://192.168.0.150:7000/translate_image" +API_URL = "http://127.0.0.1:7002/translate_image" payload = { - "local_image_path": "d:/py/IT_Server/modules/img/6.jpg", + "local_image_path": "d:/py/IT_Server/modules/img/1.jpg", "file_prefix": "test", "toggle_states": {"ocr": True}, - "unwanted_texts": {"크리스탈": "크리미"}, + "unwanted_texts": {"크리스탈": "크리미", "미니멀": "확화곽"}, "watermark_text": "테스트 워터마크", "watermark_opacity": 0.5, "watermark_font_size": 32 diff --git a/modules/test_translate_api_base64.py b/modules/test_translate_api_base64.py new file mode 100644 index 0000000..0361e2f --- /dev/null +++ b/modules/test_translate_api_base64.py @@ -0,0 +1,102 @@ +import requests +import json +import base64 +import os +import time + +API_URL = "http://192.168.0.150:7000/translate_image" +# API_URL = "http://127.0.0.1:7000/translate_image" + +# 이미지 파일을 base64로 변환하는 함수 +def image_to_base64(image_path): + """이미지 파일을 base64 문자열로 변환""" + if not os.path.exists(image_path): + raise FileNotFoundError(f"이미지 파일을 찾을 수 없습니다: {image_path}") + + with open(image_path, "rb") as image_file: + encoded_string = base64.b64encode(image_file.read()).decode('utf-8') + return encoded_string + +# base64 데이터를 이미지 파일로 저장하는 함수 +def base64_to_image(base64_data, output_path): + """base64 문자열을 이미지 파일로 저장""" + try: + image_data = base64.b64decode(base64_data) + with open(output_path, "wb") as image_file: + image_file.write(image_data) + return True + except Exception as e: + print(f"이미지 저장 중 오류: {e}") + return False + +# 이미지 파일 경로 +image_path = "d:/py/IT_Server/modules/img/6.jpg" + +print("=== 이미지 번역 API 테스트 시작 ===") +start_total_time = time.time() + +# 이미지를 base64로 변환 +print("\n1. 이미지 base64 변환 중...") +start_encode_time = time.time() +try: + image_base64 = image_to_base64(image_path) + encode_time = time.time() - start_encode_time + print(f" ✓ 이미지 파일 '{image_path}' 를 base64로 변환 완료") + print(f" ✓ Base64 길이: {len(image_base64):,} 문자") + print(f" ✓ 인코딩 시간: {encode_time:.3f}초") +except FileNotFoundError as e: + print(f" ✗ 오류: {e}") + exit(1) + +payload = { + "image_data": image_base64, # 필드명을 image_data로 수정 + "file_prefix": "test", + "toggle_states": {"ocr": True}, + "unwanted_texts": {"크리스탈": "크리미"}, + "watermark_text": "테스트 워터마크", + "watermark_opacity": 0.5, + "watermark_font_size": 32 +} + +headers = {"Content-Type": "application/json"} + +print(f"\n2. API 요청 전송 중... (URL: {API_URL})") +start_api_time = time.time() +response = requests.post(API_URL, data=json.dumps(payload), headers=headers) +api_time = time.time() - start_api_time + +total_time = time.time() - start_total_time + +print(f"\n=== 처리 결과 ===") +print(f"상태 코드: {response.status_code}") +print(f"API 처리 시간: {api_time:.3f}초") +print(f"전체 처리 시간: {total_time:.3f}초") + +try: + response_data = response.json() + print(f"\n응답 내용:") + print(json.dumps(response_data, indent=2, ensure_ascii=False)) + + # 성공적으로 처리된 경우 추가 정보 출력 + if response.status_code == 200: + print(f"\n=== 성능 요약 ===") + print(f"• Base64 인코딩: {encode_time:.3f}초") + print(f"• API 서버 처리: {api_time:.3f}초") + print(f"• 전체 소요 시간: {total_time:.3f}초") + if api_time > 10: + print("⚠️ API 처리 시간이 10초를 초과했습니다.") + elif api_time > 5: + print("⚠️ API 처리 시간이 5초를 초과했습니다.") + else: + print("✓ 처리 시간이 양호합니다.") + + # 결과 이미지를 파일로 저장 + output_path = "d:/py/IT_Server/modules/translated_result.png" + if base64_to_image(response_data["result"], output_path): + print(f"처리된 이미지가 저장되었습니다: {output_path}") + else: + print("이미지 저장에 실패했습니다.") + +except json.JSONDecodeError: + print(f"\nJSON 응답이 아닙니다:") + print(response.text) \ No newline at end of file diff --git a/modules/translated_result.png b/modules/translated_result.png new file mode 100644 index 0000000..c119449 Binary files /dev/null and b/modules/translated_result.png differ diff --git a/requirements.txt b/requirements.txt index 6d6e57c..db8edf4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +# torch==2.2.2+cpu --index-url https://download.pytorch.org/whl/cpu +# torchvision==0.17.2+cpu --index-url https://download.pytorch.org/whl/cpu fastapi uvicorn pydantic @@ -7,3 +9,7 @@ numpy requests pillow openai +shapely +paddleocr==2.10.0 +paddlepaddle==2.6.2 +iopaint==1.6.0