LLDDWW Claude commited on
Commit
c74ab95
ยท
1 Parent(s): e4a5da6

fix: match input dtype to model dtype for TrOCR

Browse files

๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -70,7 +70,8 @@ def extract_text_from_image(image: Image.Image) -> str:
70
  """Stage 1: TrOCR๋กœ ์ด๋ฏธ์ง€์—์„œ ํ…์ŠคํŠธ ์ถ”์ถœ (OCR)"""
71
  try:
72
  # TrOCR์€ ์ด๋ฏธ์ง€ ์ „์ฒด๋ฅผ ํ•œ ๋ฒˆ์— ์ฒ˜๋ฆฌ
73
- pixel_values = OCR_PROCESSOR(image, return_tensors="pt").pixel_values.to(OCR_MODEL.device)
 
74
 
75
  with torch.no_grad():
76
  generated_ids = OCR_MODEL.generate(pixel_values)
 
70
  """Stage 1: TrOCR๋กœ ์ด๋ฏธ์ง€์—์„œ ํ…์ŠคํŠธ ์ถ”์ถœ (OCR)"""
71
  try:
72
  # TrOCR์€ ์ด๋ฏธ์ง€ ์ „์ฒด๋ฅผ ํ•œ ๋ฒˆ์— ์ฒ˜๋ฆฌ
73
+ pixel_values = OCR_PROCESSOR(image, return_tensors="pt").pixel_values
74
+ pixel_values = pixel_values.to(device=OCR_MODEL.device, dtype=OCR_MODEL.dtype)
75
 
76
  with torch.no_grad():
77
  generated_ids = OCR_MODEL.generate(pixel_values)