Tonic commited on
Commit
07c16b4
Β·
verified Β·
1 Parent(s): e4e4366

adds MCP server

Browse files

descriptive how-to in docstring

Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -43,6 +43,22 @@ def image_to_base64(image):
43
 
44
  @spaces.GPU()
45
  def process_image(image, task, ocr_type=None, ocr_box=None, ocr_color=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  if image is None:
47
  return "Error: No image provided", None, None
48
 
@@ -290,4 +306,4 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
290
 
291
  if __name__ == "__main__":
292
  cleanup_old_files()
293
- demo.launch(ssr_mode = False)
 
43
 
44
  @spaces.GPU()
45
  def process_image(image, task, ocr_type=None, ocr_box=None, ocr_color=None):
46
+ """
47
+ Process an input image using the OCR model based on the specified task.
48
+
49
+ Args:
50
+ image (Union[dict, np.ndarray, str, PIL.Image]): Input image in various formats
51
+ task (str): Type of OCR task to perform
52
+ ocr_type (str, optional): Type of OCR processing ('ocr' or 'format')
53
+ ocr_box (str, optional): Bounding box coordinates for fine-grained OCR
54
+ ocr_color (str, optional): Color specification for fine-grained OCR
55
+
56
+ Returns:
57
+ tuple: (result_text, html_content, unique_id)
58
+ - result_text (str): OCR processing result or error message
59
+ - html_content (str): HTML content for visualization if applicable
60
+ - unique_id (str): Unique identifier for the processed image
61
+ """
62
  if image is None:
63
  return "Error: No image provided", None, None
64
 
 
306
 
307
  if __name__ == "__main__":
308
  cleanup_old_files()
309
+ demo.launch(ssr_mode = False, mcp_server=True)