46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
import os
|
|
import asyncio
|
|
import random
|
|
from image_processor3 import ImageProcessor3
|
|
from playwright.async_api import async_playwright, playwright
|
|
|
|
class SimpleLogger:
|
|
def log(self, msg, level=None, exc_info=None):
|
|
print(msg)
|
|
|
|
async def main():
|
|
logger = SimpleLogger()
|
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
|
file_num = 7
|
|
img_path = os.path.join(base_dir, 'img', f"{file_num}.jpg")
|
|
|
|
# ImageProcessor3 인스턴스 생성
|
|
toggle_states = {
|
|
'TEMP_IMAGE_DIR': os.path.join(base_dir, 'img'),
|
|
'ocr': True
|
|
}
|
|
image_processor = ImageProcessor3(
|
|
logger=logger,
|
|
browser_page=None,
|
|
toggle_states=toggle_states,
|
|
base_dir=base_dir
|
|
)
|
|
|
|
unwanted_texts = {
|
|
"고품질": "저품질",
|
|
"세탁기": "세세탁기"
|
|
}
|
|
|
|
image_processor.update_unwanted_texts(unwanted_texts)
|
|
|
|
# # process_single_image 호출
|
|
# result = await image_processor.process_single_image(
|
|
# page=None, original_image_url=img_path, delay=0, index=file_num, file_prefix=""
|
|
# )
|
|
|
|
result = await image_processor.remove_background(img_path, index=file_num, file_prefix="")
|
|
|
|
print(f"처리 결과: {result}")
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main()) |