OmarAbualrob commited on
Commit
a039eef
·
verified ·
1 Parent(s): 60ec4f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -19,7 +19,7 @@ app = FastAPI(title="Mixed-Content OCR API", description="An API to extract text
19
  try:
20
  logger.info("Loading model and processor...")
21
  # Use the large model for better accuracy
22
- model_id = "microsoft/Florence-2-base"
23
  # NOTE: We need to trust remote code for Florence-2
24
  model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
25
  processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
@@ -55,6 +55,7 @@ def run_ocr(image: Image.Image) -> str:
55
  pixel_values=inputs["pixel_values"],
56
  max_new_tokens=4096, # Increased token limit for long documents
57
  do_sample=False, # Use greedy decoding for deterministic output
 
58
  )
59
 
60
  # Decode the generated IDs to a string
 
19
  try:
20
  logger.info("Loading model and processor...")
21
  # Use the large model for better accuracy
22
+ model_id = "microsoft/Florence-2-large"
23
  # NOTE: We need to trust remote code for Florence-2
24
  model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
25
  processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
 
55
  pixel_values=inputs["pixel_values"],
56
  max_new_tokens=4096, # Increased token limit for long documents
57
  do_sample=False, # Use greedy decoding for deterministic output
58
+ num_beams=3
59
  )
60
 
61
  # Decode the generated IDs to a string