refactor: simplify to OCR-only output
Browse files- Remove LLM medication extraction step
- Show only raw OCR text output
- Simplify UI to single output panel
๐ค Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -172,20 +172,18 @@ def format_results(extracted_text: str, medications: List[str]) -> Tuple[str, st
|
|
| 172 |
|
| 173 |
|
| 174 |
def run_analysis(image: Optional[Image.Image], progress=gr.Progress()):
|
| 175 |
-
"""๋ฉ์ธ ๋ถ์ ํ์ดํ๋ผ์ธ: OCR
|
| 176 |
if image is None:
|
| 177 |
-
return "๐ท ์ฝ ๋ดํฌ๋ ์ฒ๋ฐฉ์ ์ฌ์ง์ ์
๋ก๋ํด์ฃผ์ธ์."
|
| 178 |
|
| 179 |
-
progress(0.
|
| 180 |
-
progress(0.6, desc="๐ค Stage 2: LLM ์ฝ๋ฌผ ๋ถ์ ์ค...")
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
return text_output, med_output
|
| 189 |
|
| 190 |
|
| 191 |
# ์ฌํํ CSS
|
|
@@ -283,31 +281,23 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
|
|
| 283 |
with gr.Column(elem_classes=["upload-section"]):
|
| 284 |
gr.Markdown("### ๐ธ ์ฌ์ง ์
๋ก๋")
|
| 285 |
image_input = gr.Image(type="pil", label="์ฝ๋ดํฌ ๋๋ ์ฒ๋ฐฉ์ ์ฌ์ง", height=350)
|
| 286 |
-
analyze_button = gr.Button("๐
|
| 287 |
|
| 288 |
-
with gr.
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
text_output = gr.Markdown("OCR๋ก ์ถ์ถ๋ ์ ์ฒด ํ
์คํธ๊ฐ ์ฌ๊ธฐ ํ์๋ฉ๋๋ค.")
|
| 292 |
-
|
| 293 |
-
with gr.Column(elem_classes=["result-section"]):
|
| 294 |
-
gr.Markdown("### ๐ Stage 2: LLM ๋ถ์ ๊ฒฐ๊ณผ")
|
| 295 |
-
med_output = gr.Markdown("LLM์ด ๋ถ์ํ ์ฝ๋ฌผ ๋ฆฌ์คํธ๊ฐ ์ฌ๊ธฐ ํ์๋ฉ๋๋ค.")
|
| 296 |
|
| 297 |
analyze_button.click(
|
| 298 |
run_analysis,
|
| 299 |
inputs=image_input,
|
| 300 |
-
outputs=
|
| 301 |
)
|
| 302 |
|
| 303 |
gr.Markdown("""
|
| 304 |
---
|
| 305 |
|
| 306 |
-
**โน๏ธ
|
| 307 |
-
-
|
| 308 |
-
- **Stage 2**: Qwen2.5 7B (LLM) - ์ถ์ถ๋ ํ
์คํธ์์ ์ฝ ์ด๋ฆ๋ง ์๋ณ
|
| 309 |
-
|
| 310 |
-
์ค์ ๋ณต์ฝ์ ์์ฌยท์ฝ์ฌ์ ์ง์๋ฅผ ๋ฐ๋ฅด์ธ์.
|
| 311 |
""")
|
| 312 |
|
| 313 |
if __name__ == "__main__":
|
|
|
|
| 172 |
|
| 173 |
|
| 174 |
def run_analysis(image: Optional[Image.Image], progress=gr.Progress()):
|
| 175 |
+
"""๋ฉ์ธ ๋ถ์ ํ์ดํ๋ผ์ธ: OCR๋ง ์คํ"""
|
| 176 |
if image is None:
|
| 177 |
+
return "๐ท ์ฝ ๋ดํฌ๋ ์ฒ๋ฐฉ์ ์ฌ์ง์ ์
๋ก๋ํด์ฃผ์ธ์."
|
| 178 |
|
| 179 |
+
progress(0.5, desc="๐ธ OCR ํ
์คํธ ์ถ์ถ ์ค...")
|
|
|
|
| 180 |
|
| 181 |
+
try:
|
| 182 |
+
extracted_text = extract_text_from_image(image)
|
| 183 |
+
progress(1.0, desc="โ
์๋ฃ!")
|
| 184 |
+
return f"### ๐ OCR ์ถ์ถ ๊ฒฐ๊ณผ\n\n```\n{extracted_text}\n```"
|
| 185 |
+
except Exception as e:
|
| 186 |
+
return f"### โ ๏ธ ์ค๋ฅ ๋ฐ์\n\n{str(e)}"
|
|
|
|
| 187 |
|
| 188 |
|
| 189 |
# ์ฌํํ CSS
|
|
|
|
| 281 |
with gr.Column(elem_classes=["upload-section"]):
|
| 282 |
gr.Markdown("### ๐ธ ์ฌ์ง ์
๋ก๋")
|
| 283 |
image_input = gr.Image(type="pil", label="์ฝ๋ดํฌ ๋๋ ์ฒ๋ฐฉ์ ์ฌ์ง", height=350)
|
| 284 |
+
analyze_button = gr.Button("๐ OCR ํ
์คํธ ์ถ์ถ", elem_classes=["analyze-btn"], size="lg")
|
| 285 |
|
| 286 |
+
with gr.Column(elem_classes=["result-section"]):
|
| 287 |
+
gr.Markdown("### ๐ OCR ์ถ์ถ ๊ฒฐ๊ณผ")
|
| 288 |
+
text_output = gr.Markdown("OCR๋ก ์ถ์ถ๋ ์ ์ฒด ํ
์คํธ๊ฐ ์ฌ๊ธฐ ํ์๋ฉ๋๋ค.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
analyze_button.click(
|
| 291 |
run_analysis,
|
| 292 |
inputs=image_input,
|
| 293 |
+
outputs=text_output,
|
| 294 |
)
|
| 295 |
|
| 296 |
gr.Markdown("""
|
| 297 |
---
|
| 298 |
|
| 299 |
+
**โน๏ธ OCR ๋ชจ๋ธ**
|
| 300 |
+
- Korean TrOCR (ddobokki/ko-trocr) - ํ๊ตญ์ด ํ
์คํธ ์ธ์์ ์ต์ ํ๋ ๋ชจ๋ธ
|
|
|
|
|
|
|
|
|
|
| 301 |
""")
|
| 302 |
|
| 303 |
if __name__ == "__main__":
|