이미지 처리 모듈에서 인페인팅 기능을 추가하고, 결과를 base64 형식으로 반환하도록 수정. OCR 모듈의 파라미터 조정 및 이미지 경로 검증 로직 개선.

This commit is contained in:
AGX 2025-07-05 16:20:01 +09:00
parent 4687fcca9a
commit d57ac54d8d
12 changed files with 13555 additions and 17 deletions

View File

@ -423,3 +423,172 @@ ModuleNotFoundError: No module named 'paddleocr'
[2025-07-04 16:11:24,897] [MainThread] [ERROR] [image_translate_server.py:translate_image:59] 이미지 파일을 찾을 수 없습니다: d:/py/IT_Server/modules/img/6.jpg
[2025-07-04 16:11:24,899] [MainThread] [INFO] [image_translate_server.py:translate_image:59] 중국어 텍스트 0개 필터링 완료
[2025-07-04 16:11:24,899] [MainThread] [INFO] [routing.py:run_endpoint_function:212] 이미지 1 중국어 텍스트 없음, 원본 이미지 반환
[2025-07-04 16:41:56,332] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 16:41:56,338] [MainThread] [ERROR] [image_processor2.py:__init__:34] ❌ PaddleOCR 초기화 실패: Unknown argument: total_process_num
Traceback (most recent call last):
File "/home/ckh08045/work/IT_Server/modules/ocr_module.py", line 40, in initialize_ocr
ocr = PaddleOCR(
File "/home/ckh08045/work/IT_Server/lib/python3.8/site-packages/paddleocr/_pipelines/ocr.py", line 161, in __init__
super().__init__(**base_params)
File "/home/ckh08045/work/IT_Server/lib/python3.8/site-packages/paddleocr/_pipelines/base.py", line 62, in __init__
self._common_args = parse_common_args(
File "/home/ckh08045/work/IT_Server/lib/python3.8/site-packages/paddleocr/_common_args.py", line 43, in parse_common_args
raise ValueError(f"Unknown argument: {name}")
ValueError: Unknown argument: total_process_num
[2025-07-04 17:02:00,774] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:02:04,532] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-04 17:02:04,538] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-04 17:07:50,735] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751616470_cc989d2b.png
[2025-07-04 17:07:50,781] [MainThread] [INFO] [image_translate_server.py:translate_image:81] 🔍 OCR 감지 방식: polygon
[2025-07-04 17:07:54,640] [MainThread] [INFO] [image_translate_server.py:translate_image:81] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-04 17:07:54,641] [MainThread] [INFO] [image_translate_server.py:translate_image:81] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-04 17:07:54,641] [MainThread] [INFO] [image_translate_server.py:translate_image:81] 중국어 텍스트 4개 필터링 완료
[2025-07-04 17:07:58,795] [MainThread] [INFO] [image_translate_server.py:translate_image:81] 최종 치환 결과: ['현대 미니멀리즘 스타일', '다양한 사용 환경에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-04 17:07:58,796] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-04 17:07:58,842] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-04 17:08:05,042] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-04 17:08:05,436] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-04 17:08:05,669] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:08:06,217] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:09:55,145] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751616595_611af512.png
[2025-07-04 17:09:55,177] [MainThread] [INFO] [image_translate_server.py:translate_image:81] 🔍 OCR 감지 방식: polygon
[2025-07-04 17:09:55,524] [MainThread] [INFO] [image_translate_server.py:translate_image:81] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-04 17:09:55,525] [MainThread] [INFO] [image_translate_server.py:translate_image:81] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-04 17:09:55,525] [MainThread] [INFO] [image_translate_server.py:translate_image:81] 중국어 텍스트 4개 필터링 완료
[2025-07-04 17:09:57,350] [MainThread] [INFO] [image_translate_server.py:translate_image:81] 최종 치환 결과: ['현대 미니멀리즘 스타일', '다양한 사용 환경에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-04 17:09:57,350] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-04 17:09:57,386] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-04 17:09:59,582] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-04 17:09:59,797] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-04 17:09:59,964] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:10:00,473] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:10:40,995] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:15:58,402] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:18:19,733] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:23:15,363] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:41:12,939] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:41:20,142] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-04 17:41:20,147] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-04 17:41:40,306] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:42:41,851] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:42:48,670] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-04 17:42:48,672] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-04 17:43:05,371] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:43:12,104] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-04 17:43:12,105] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-04 17:46:08,605] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:54:37,766] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-04 17:54:44,702] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-04 17:54:44,703] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-04 17:55:26,309] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751619326_9d146cfd.png
[2025-07-04 17:55:26,361] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-04 17:55:29,714] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-04 17:55:29,714] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-04 17:55:29,715] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-04 17:55:32,070] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀 스타일', '다양한 사용 상황에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-04 17:55:32,071] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-04 17:55:32,115] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-04 17:55:37,283] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-04 17:55:37,661] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-04 17:55:37,861] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:55:38,500] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:55:56,081] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751619356_123d6a32.png
[2025-07-04 17:55:56,114] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-04 17:55:56,326] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-04 17:55:56,327] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-04 17:55:56,327] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-04 17:55:57,782] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀리즘 스타일', '다양한 사용 환경에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-04 17:55:57,782] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-04 17:55:57,816] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-04 17:55:59,579] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-04 17:55:59,794] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-04 17:55:59,952] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:56:00,467] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:56:30,009] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751619390_31bccc72.png
[2025-07-04 17:56:30,042] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-04 17:56:30,430] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-04 17:56:30,431] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-04 17:56:30,431] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-04 17:56:33,301] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀 스타일', '다양한 사용 환경에 더 쉽게 어울림', '반원형 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-04 17:56:33,302] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-04 17:56:33,338] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-04 17:56:35,187] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-04 17:56:35,385] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-04 17:56:35,532] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:56:36,035] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:57:03,690] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751619423_626d1708.png
[2025-07-04 17:57:03,720] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-04 17:57:03,910] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-04 17:57:03,911] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-04 17:57:03,911] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-04 17:57:06,671] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀리즘 스타일', '다양한 사용 상황에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-04 17:57:06,672] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-04 17:57:06,706] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-04 17:57:08,462] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-04 17:57:08,648] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-04 17:57:08,789] [MainThread] [INFO] [image_processor2.py:process_single_image:117] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-04 17:57:09,283] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_img_1.png
[2025-07-05 13:41:32,955] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-05 13:41:42,225] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-05 13:41:42,226] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-05 13:42:06,325] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-05 13:42:09,230] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-05 13:42:09,231] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-05 13:42:09,231] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-05 13:42:11,387] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대적인 미니멀리즘 스타일', '다양한 사용 환경에 더 쉽게 어울림', '반원형 양쪽 끝 디자인', '다양한 즐거움을 담아냄']
[2025-07-05 13:42:11,388] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-05 13:42:11,426] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-05 13:42:20,680] [MainThread] [ERROR] [routing.py:run_endpoint_function:191] 이미지 1 처리 중 오류: name 'cv2' is not defined
Traceback (most recent call last):
File "/home/ckh08045/work/IT_Server/modules/image_processor2.py", line 111, in process_single_image
inpainted_image = inpaint_with_simple_lama(local_image_path, masks)
File "/home/ckh08045/work/IT_Server/modules/lama_inpaint.py", line 27, in inpaint_with_simple_lama
result_np = cv2.cvtColor(np.array(result), cv2.COLOR_RGB2BGR)
NameError: name 'cv2' is not defined
[2025-07-05 13:42:21,660] [MainThread] [INFO] [routing.py:run_endpoint_function:191] base64 이미지 데이터를 임시 파일로 저장: /home/ckh08045/work/IT_Server/temp_images/temp_image_1751690541_838c8ecd.png
[2025-07-05 13:42:21,688] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-05 13:42:21,926] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-05 13:42:21,926] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-05 13:42:21,927] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-05 13:42:24,738] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀리즘 스타일', '다양한 사용 환경에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-05 13:42:24,739] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-05 13:42:24,774] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-05 13:42:32,346] [MainThread] [ERROR] [routing.py:run_endpoint_function:191] 이미지 1 처리 중 오류: name 'cv2' is not defined
Traceback (most recent call last):
File "/home/ckh08045/work/IT_Server/modules/image_processor2.py", line 111, in process_single_image
inpainted_image = inpaint_with_simple_lama(local_image_path, masks)
File "/home/ckh08045/work/IT_Server/modules/lama_inpaint.py", line 27, in inpaint_with_simple_lama
result_np = cv2.cvtColor(np.array(result), cv2.COLOR_RGB2BGR)
NameError: name 'cv2' is not defined
[2025-07-05 13:45:13,618] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-05 13:45:13,950] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-05 13:45:13,950] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-05 13:45:13,950] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-05 13:45:15,629] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀리즘 스타일', '다양한 사용 상황에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-05 13:45:15,629] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-05 13:45:15,666] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-05 13:45:23,485] [MainThread] [ERROR] [routing.py:run_endpoint_function:191] 이미지 1 처리 중 오류: name 'cv2' is not defined
Traceback (most recent call last):
File "/home/ckh08045/work/IT_Server/modules/image_processor2.py", line 111, in process_single_image
inpainted_image = inpaint_with_simple_lama(local_image_path, masks)
File "/home/ckh08045/work/IT_Server/modules/lama_inpaint.py", line 27, in inpaint_with_simple_lama
result_np = cv2.cvtColor(np.array(result), cv2.COLOR_RGB2BGR)
NameError: name 'cv2' is not defined
[2025-07-05 13:46:19,017] [MainThread] [INFO] [image_processor2.py:__init__:34] PaddleOCR use_gpu: True
[2025-07-05 13:46:28,171] [MainThread] [INFO] [main.py:main:38] 마스크 모듈 초기화 완료
[2025-07-05 13:46:28,172] [MainThread] [DEBUG] [image_processor2.py:__init__:37] 폰트 로드 성공: /home/ckh08045/work/IT_Server/modules/fonts/HakgyoansimDunggeunmisoTTFB.ttf
[2025-07-05 13:46:30,894] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 🔍 OCR 감지 방식: polygon
[2025-07-05 13:46:33,807] [MainThread] [INFO] [image_translate_server.py:translate_image:82] ocr_raw_results: [[[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]]
[2025-07-05 13:46:33,807] [MainThread] [INFO] [image_translate_server.py:translate_image:82] line: [[[[344.0, 108.0], [855.0, 108.0], [855.0, 182.0], [344.0, 182.0]], ('现代极简风格', 0.9951319694519043)], [[[235.0, 219.0], [964.0, 219.0], [964.0, 279.0], [235.0, 279.0]], ('更易搭配各种使用场景', 0.9972087144851685)], [[[136.0, 447.0], [717.0, 447.0], [717.0, 534.0], [136.0, 534.0]], ('半圆两端设计', 0.9981245398521423)], [[[134.0, 571.0], [715.0, 571.0], [715.0, 658.0], [134.0, 658.0]], ('承载各种欢乐', 0.9950275421142578)]]
[2025-07-05 13:46:33,808] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 중국어 텍스트 4개 필터링 완료
[2025-07-05 13:46:35,721] [MainThread] [INFO] [image_translate_server.py:translate_image:82] 최종 치환 결과: ['현대 미니멀 스타일', '다양한 사용 상황에 더 쉽게 어울림', '반원 양쪽 끝 디자인', '다양한 즐거움을 담다']
[2025-07-05 13:46:35,721] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 치환됨
[2025-07-05 13:46:35,758] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 마스크 생성 완료
[2025-07-05 13:46:44,407] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 인페인팅 완료
[2025-07-05 13:46:44,724] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 텍스트 렌더링 완료
[2025-07-05 13:46:44,912] [MainThread] [INFO] [image_processor2.py:process_single_image:120] 이미지 저장 완료 : /home/ckh08045/work/IT_Server/temp_images/translated_test_path_img_1.png
[2025-07-05 13:46:45,420] [MainThread] [INFO] [routing.py:run_endpoint_function:191] 이미지 1 번역 완료: /home/ckh08045/work/IT_Server/temp_images/translated_test_path_img_1.png

1
PaddleX Submodule

@ -0,0 +1 @@
Subproject commit 00f18fd4aee83d49a9b31f6bbe9f709c81ca544d

2
iop_start.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
iopaint start --host=0.0.0.0 --port=8000 --device=cuda --enable-remove-bg --remove-bg-device=cuda --model=migan

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ from modules.ocr_module import OCRModule
from modules.mask_module import MaskModule
from modules.text_rendering_module import TextRenderingModule
from modules.postImageManager import PostImageManager
from modules.lama_inpaint import inpaint_with_simple_lama
class ImageProcessor:
"""이미지 다운로드, OCR, 번역 처리를 담당하는 클래스"""
@ -105,9 +105,12 @@ class ImageProcessor:
self.logger.log(f"마스크 생성 완료", level=logging.INFO)
# 인페인팅
inpainted_image = self.call_inpaint_api(local_image_path, masks)
# inpainted_image = self.call_inpaint_api(local_image_path, masks)
# self.logger.log(f"인페인팅 완료", level=logging.INFO)
inpainted_image = inpaint_with_simple_lama(local_image_path, masks)
self.logger.log(f"인페인팅 완료", level=logging.INFO)
# 텍스트 렌더링
text_rendered_image = self.text_rendering_module.render_text(
inpainted_image, ocr_results, filtered_translated_texts, font_path=self.font_path)

View File

@ -8,6 +8,7 @@ import asyncio
from concurrent.futures import ThreadPoolExecutor
from modules.image_processor2 import ImageProcessor
import os
import base64
# 포트 범위 설정
PORT_RANGE = (7000, 7000)
@ -81,10 +82,24 @@ def create_app(image_processor: ImageProcessor, max_workers: int = 2):
result = await image_processor.process_single_image(
toggle_states, req.unwanted_texts or {}, image_path, 0, req.file_prefix
)
# 경로만 반환
# 결과를 base64로 변환하여 반환
if isinstance(result, dict):
return {"result": result.get("path", None)}
return {"result": result}
result_path = result.get("path", None)
else:
result_path = result
if result_path and os.path.exists(result_path):
try:
# 처리된 이미지를 base64로 변환
with open(result_path, "rb") as f:
image_data = f.read()
result_base64 = base64.b64encode(image_data).decode('utf-8')
return {"result": result_base64, "format": "base64"}
except Exception as e:
return {"error": f"이미지를 base64로 변환하는 중 오류: {str(e)}"}
else:
return {"error": "처리된 이미지 파일을 찾을 수 없습니다."}
@app.post("/translate_images")
async def translate_images(req: ImagesRequest):
@ -127,12 +142,28 @@ def create_app(image_processor: ImageProcessor, max_workers: int = 2):
for idx, path in enumerate(image_paths):
tasks.append(sem_task(idx, path))
results = await asyncio.gather(*tasks)
# 경로만 리스트로 반환
def extract_path(res):
if isinstance(res, dict):
return res.get("path", None)
return res
return {"results": [extract_path(r) for r in results]}
# 결과들을 base64로 변환하여 반환
base64_results = []
for result in results:
if isinstance(result, dict):
result_path = result.get("path", None)
else:
result_path = result
if result_path and os.path.exists(result_path):
try:
# 처리된 이미지를 base64로 변환
with open(result_path, "rb") as f:
image_data = f.read()
result_base64 = base64.b64encode(image_data).decode('utf-8')
base64_results.append(result_base64)
except Exception as e:
base64_results.append(None) # 변환 실패시 None
else:
base64_results.append(None) # 파일이 없으면 None
return {"results": base64_results, "format": "base64"}
return app

30
modules/lama_inpaint.py Normal file
View File

@ -0,0 +1,30 @@
from simple_lama_inpainting import SimpleLama
from PIL import Image
import numpy as np
import cv2
def inpaint_with_simple_lama(image, mask, device="cuda"):
"""
simple-lama-inpainting을 사용해 인페인팅을 수행합니다.
image: 파일 경로(str), np.ndarray, 또는 PIL.Image.Image
mask: 파일 경로(str), np.ndarray, 또는 PIL.Image.Image (흑백)
device: "cuda" 또는 "cpu"
return: np.ndarray (BGR)
"""
# 이미지 로딩
if isinstance(image, str):
image = Image.open(image)
elif isinstance(image, np.ndarray):
image = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
# mask도 동일하게 처리
if isinstance(mask, str):
mask = Image.open(mask)
elif isinstance(mask, np.ndarray):
mask = Image.fromarray(mask)
# 인페인팅
simple_lama = SimpleLama(device=device)
result = simple_lama(image, mask)
# PIL.Image -> np.ndarray(BGR)
result_np = cv2.cvtColor(np.array(result), cv2.COLOR_RGB2BGR)
return result_np

View File

@ -41,10 +41,11 @@ class OCRModule:
use_gpu=use_gpu, # GPU 사용 가능하면 활성화
use_angle_cls=True, # 텍스트 방향 분류 활성화
lang="ch",
# precision='fp16', # 또는 use_fp16=True (버전에 따라 다름)
enable_hpi=True,
# use_tensorrt=True,
precision='fp16', # 또는 use_fp16=True (버전에 따라 다름)
use_mp=True, # 멀티프로세스 활성화
total_process_num=8,
total_process_num=4,
show_log=True,
det_model_dir=self.det_model_dir,
rec_model_dir=self.rec_model_dir,
cls_model_dir=self.cls_model_dir

View File

@ -1,6 +1,9 @@
import requests
import json
import base64
import os
import cv2
import numpy as np
API_URL = "http://127.0.0.1:7000/translate_image"
@ -22,7 +25,25 @@ def test_with_path():
print("=== 경로 사용 테스트 ===")
print("응답 결과:")
print(response.status_code)
print(response.json())
# print(response.json())
# 결과 이미지를 temp_image 폴더에 PNG로 저장
result = response.json()
# 예시: result["image"]에 base64 인코딩된 이미지가 있다고 가정
image_b64 = result.get("image")
if image_b64:
os.makedirs("temp_image", exist_ok=True)
image_bytes = base64.b64decode(image_b64)
nparr = np.frombuffer(image_bytes, np.uint8)
img_np = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
if img_np is not None:
out_path = os.path.join("temp_image", "result_path.png")
cv2.imwrite(out_path, img_np)
print(f"이미지 저장 완료: {out_path}")
else:
print("이미지 디코딩 실패")
else:
print("응답에 이미지 데이터가 없습니다.")
# 방법 2: base64 이미지 데이터 사용 (새로운 방식)
def test_with_base64():
@ -56,4 +77,4 @@ def test_with_base64():
if __name__ == "__main__":
test_with_path()
test_with_base64()
# test_with_base64()

View File

@ -0,0 +1,83 @@
import requests
import json
import base64
import os
# 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"
# 이미지를 base64로 변환
try:
image_base64 = image_to_base64(image_path)
print(f"이미지 파일 '{image_path}' 를 base64로 변환했습니다.")
print(f"Base64 길이: {len(image_base64)} 문자")
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("API 요청을 보내는 중...")
response = requests.post(API_URL, data=json.dumps(payload), headers=headers)
print("응답 결과:")
print(f"상태 코드: {response.status_code}")
try:
response_data = response.json()
print("응답 내용:")
if "error" in response_data:
print(f"오류: {response_data['error']}")
elif "result" in response_data and response_data.get("format") == "base64":
result_base64 = response_data["result"]
print(f"처리된 이미지 base64 길이: {len(result_base64)} 문자")
# 결과 이미지를 파일로 저장
output_path = "d:/py/IT_Server/modules/translated_result.png"
if base64_to_image(result_base64, output_path):
print(f"처리된 이미지가 저장되었습니다: {output_path}")
else:
print("이미지 저장에 실패했습니다.")
else:
print("예상치 못한 응답 형식:")
print(json.dumps(response_data, indent=2, ensure_ascii=False))
except json.JSONDecodeError:
print("JSON 응답이 아닙니다:")
print(response.text)