Skip to content

feat: add instagram OCR fallback extraction#17

Merged
1000hyehyang merged 2 commits into
devfrom
feat/16-instagram-ocr-fallback
May 27, 2026
Merged

feat: add instagram OCR fallback extraction#17
1000hyehyang merged 2 commits into
devfrom
feat/16-instagram-ocr-fallback

Conversation

@KyungminPark-steck

Copy link
Copy Markdown
Contributor

✨ 무엇을 바꿨나요?

Instagram 게시글(/p/...)에서 caption-only 장소 추출이 실패했을 때, 게시글 이미지 carousel을 크롤링하고 HF OCR로 이미지 내 텍스트를 추출한 뒤 기존 Qwen/Kakao 파이프라인으로 다시 장소 후보를 추출하도록 fallback 흐름을 추가했습니다.

🔗 관련 이슈

Closes #16

💡 왜 바꿨나요?

일부 Instagram 게시글은 상호명과 주소가 caption이 아니라 이미지 안에 포함되어 있습니다. 기존에는 caption만 content_text로 사용해서 이런 게시글에서 장소 후보가 비거나 직접 검색 fallback에 의존하는 문제가 있었습니다.

📝 주요 변경 사항

  • Instagram 게시글 이미지 URL 수집 로직 추가
    • 현재 shortcode의 media JSON payload를 우선 파싱
    • 프로필/추천 썸네일 제외
    • 이미지 수집 timeout, max image count, carousel 순회 제한 설정 추가
  • HFOCRClient 추가
    • 기존 Qwen 추출용 HFExtractionClient와 분리
    • OCR 전용 HF 설정이 없으면 기존 HF router endpoint/token 재사용
  • JobProcessor에 OCR fallback 연결
    • caption-only Qwen 추출 먼저 실행
    • 결과가 없거나 places가 비어 있으면 Instagram post에 한해 이미지 OCR fallback 실행
    • caption + OCR text augmented content로 Qwen 추출 재실행
    • fallback 사용 시 최종 content_text도 augmented content로 저장
    • raw_metadata.instagram.ocr_fallback에 fallback 실행 정보 기록
  • 관련 unit test 및 live opt-in test 추가

👀 리뷰어가 보면 좋은 부분

  • JobProcessor._extract_result()의 fallback 조건이 의도대로 좁게 잡혔는지
    • caption-only 추출 실패 시에만 OCR fallback 실행
  • Instagram 이미지 수집 로직이 게시글 이미지와 썸네일/추천 이미지를 잘 구분하는지 (해당 url 에 들어가면 그 게시글 이미지만 가져와야 하는데, 다른 추천 게시글의 이미지도 있고, 이걸 안가져오도록 해둠.)
  • OCR 모델 기본값(google/gemma-3-27b-it)과 HF router 설정 재사용 방식이 적절한지
  • fallback 실행 후 저장되는 content_textraw_metadata 구조가 API/DB 관점에서 괜찮은지

🧪 테스트

방식

  • 로컬 환경에서 확인
  • 운영 환경에서 확인
  • 단위 / 통합 테스트
  • 해당 없음

메모

  • 기본 테스트:
    .\.venv\Scripts\python.exe -m pytest tests/test_config.py tests/test_hf_extraction_client.py tests/test_playwright_service.py tests/test_content_extractors.py tests/test_crawl_analyzer.py tests/test_worker_processor.py tests/test_worker_runner.py tests/test_instagram_ocr_fallback_live.py
    

@1000hyehyang 1000hyehyang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오늘 (5/27) 회의한 내용 바탕으로 다시 설계해주세요! (혹시, 설계가 너무 복잡하고 비효율적인 것 같으면 말씀해주세요! 집 돌아와서 생각해보니까 비효율적인 것 같기도 하고..ㅠㅠ 더 좋은 설계, UX가 있으면 공유 부탁드립니다~~)

@1000hyehyang 1000hyehyang merged commit 7f3bb76 into dev May 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] Instagram 게시글 이미지 OCR fallback 기반 장소 추출 추가

2 participants