wealthcoders commited on
Commit
a080294
·
verified ·
1 Parent(s): 40c2ea5

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +12 -19
handler.py CHANGED
@@ -57,27 +57,20 @@ class EndpointHandler:
57
 
58
  # Define the prompt for Markdown conversion
59
  prompt = "<image>\n<|grounding|>Convert the document to markdown."
60
-
61
- # Run OCR inference
62
- with tempfile.TemporaryDirectory() as temp_dir:
63
- output_path = temp_dir # Now output_path is defined
64
-
65
- # Define the prompt for Markdown conversion
66
- prompt = "<image>\n<|grounding|>Convert the document to markdown."
67
 
68
- # Run OCR inference
69
- result = self.model.infer(
70
- self.tokenizer,
71
- prompt=prompt,
72
- image_file=image,
73
- output_path=output_path, # Use temporary directory
74
- base_size=1024,
75
- image_size=640,
76
- crop_mode=True,
77
- save_results=True # Save to temporary directory
78
- )
79
 
80
- return result
81
 
82
  except Exception as e:
83
  print(f"Error processing image: {e}")
 
57
 
58
  # Define the prompt for Markdown conversion
59
  prompt = "<image>\n<|grounding|>Convert the document to markdown."
 
 
 
 
 
 
 
60
 
61
+ # Run OCR inference
62
+ result = self.model.infer(
63
+ self.tokenizer,
64
+ prompt=prompt,
65
+ image_file=image,
66
+ output_path=None, # Use temporary directory
67
+ base_size=1024,
68
+ image_size=640,
69
+ crop_mode=True,
70
+ save_results=False # Save to temporary directory
71
+ )
72
 
73
+ return result
74
 
75
  except Exception as e:
76
  print(f"Error processing image: {e}")