From e9936daad8183956967dc911fc1ddfb51f940c21 Mon Sep 17 00:00:00 2001 From: chan Date: Wed, 3 Sep 2025 17:56:05 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EC=9D=84=20=EC=83=9D=EC=84=B1=ED=95=98=EA=B3=A0=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index db0c30d..1046f3f 100644 --- a/app.py +++ b/app.py @@ -5,6 +5,7 @@ from PIL import Image import json import os import uuid +import numpy as np # 페이지 설정 st.set_page_config(page_title="PaddleOCR 이미지 분석", layout="wide") @@ -56,16 +57,9 @@ if uploaded_file is not None: # 분석 시작 버튼 if st.button("분석 시작하기", use_container_width=True): with st.spinner("이미지를 분석하고 있습니다..."): - # PIL 이미지를 바이트로 변환하여 예측 - # PPStructureV3는 파일 경로 또는 numpy 배열을 입력으로 받습니다. - # 업로드된 파일을 임시 저장하여 경로를 전달합니다. - temp_image_path = output_dir / f"temp_{unique_id}_{uploaded_file.name}" - - # 변환된 이미지를 임시 파일로 저장 - image.save(temp_image_path) - - # PPStructureV3로 예측 수행 - output = structure.predict(input=str(temp_image_path)) + # PIL 이미지를 numpy 배열로 변환하여 예측 + img_array = np.array(image) + output = structure.predict(input=img_array) if not output: st.warning("이미지에서 구조를 감지하지 못했습니다.") @@ -165,9 +159,9 @@ if uploaded_file is not None: with st.expander(f"`{json_path.name}` 전체 내용 보기"): st.json(json_data) - # 임시 파일 삭제 - if temp_image_path.exists(): - os.remove(temp_image_path) + # 임시 파일 삭제 (이제 필요 없음) + # if temp_image_path.exists(): + # os.remove(temp_image_path) except Exception as e: st.error(f"이미지 처리 중 예상치 못한 오류가 발생했습니다: {e}")