YagndeepKukadiya commited on
Commit
a3a2414
Β·
verified Β·
1 Parent(s): dcbb32b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -77,18 +77,7 @@ model = AutoModel.from_pretrained(
77
  model = model.eval()
78
  print("βœ… Model loaded successfully.")
79
 
80
- # --- Helper function to find pre-generated result images ---
81
- def find_result_image(path):
82
- for filename in os.listdir(path):
83
- if "grounding" in filename or "result" in filename:
84
- try:
85
- image_path = os.path.join(path, filename)
86
- return Image.open(image_path)
87
- except Exception as e:
88
- print(f"Error opening result image {filename}: {e}")
89
- return None
90
-
91
- # --- 2. Main Processing Function (UPDATED for multi-bbox drawing) ---
92
  def process_ocr_task(image, model_size, task_type):
93
  """
94
  Processes an image with DeepSeek-OCR for all supported tasks.
@@ -149,7 +138,7 @@ def process_ocr_task(image, model_size, task_type):
149
  return text_result
150
 
151
  # --- 3. Build the Gradio Interface (UPDATED) ---
152
- with gr.Blocks(title="DeepSeek-OCR X (t)", theme=gr.themes.Soft()) as demo:
153
  gr.Markdown(
154
  """
155
  # DeepSeek-OCR X TUL
@@ -168,12 +157,11 @@ with gr.Blocks(title="DeepSeek-OCR X (t)", theme=gr.themes.Soft()) as demo:
168
  with gr.Column(scale=1):
169
  image_input = gr.Image(type="pil", label="πŸ–ΌοΈ Upload Image", sources=["upload", "clipboard"])
170
  model_size = gr.Dropdown(choices=["Tiny", "Small", "Base", "Large", "Gundam (Recommended)"], value="Gundam (Recommended)", label="βš™οΈ Resolution Size")
171
- task_type = gr.Dropdown(choices=["πŸ“ Free OCR", "πŸ“„ Convert to Markdown", "πŸ“ˆ Parse Figure"], value="πŸ“„ Convert to Markdown", label="πŸš€ Task Type")
172
  submit_btn = gr.Button("Process Image", variant="primary")
173
 
174
  with gr.Column(scale=2):
175
  output_text = gr.Textbox(label="πŸ“„ Text Result", lines=15, show_copy_button=True)
176
- output_image = gr.Image(label="πŸ–ΌοΈ Image Result (if any)", type="pil")
177
 
178
  submit_btn.click(fn=process_ocr_task, inputs=[image_input, model_size, task_type], outputs=[output_text])
179
 
 
77
  model = model.eval()
78
  print("βœ… Model loaded successfully.")
79
 
80
+ # --- 2. Main Processing Function (UPDATED) ---
 
 
 
 
 
 
 
 
 
 
 
81
  def process_ocr_task(image, model_size, task_type):
82
  """
83
  Processes an image with DeepSeek-OCR for all supported tasks.
 
138
  return text_result
139
 
140
  # --- 3. Build the Gradio Interface (UPDATED) ---
141
+ with gr.Blocks(title="DeepSeek-OCR X (t)", theme=gr.themes.Monochrome()) as demo:
142
  gr.Markdown(
143
  """
144
  # DeepSeek-OCR X TUL
 
157
  with gr.Column(scale=1):
158
  image_input = gr.Image(type="pil", label="πŸ–ΌοΈ Upload Image", sources=["upload", "clipboard"])
159
  model_size = gr.Dropdown(choices=["Tiny", "Small", "Base", "Large", "Gundam (Recommended)"], value="Gundam (Recommended)", label="βš™οΈ Resolution Size")
160
+ task_type = gr.Dropdown(choices=["πŸ“ Free OCR", "πŸ“„ Convert to Markdown", "πŸ“ˆ Parse Figure"], value="πŸ“ Free OCR", label="πŸš€ Task Type")
161
  submit_btn = gr.Button("Process Image", variant="primary")
162
 
163
  with gr.Column(scale=2):
164
  output_text = gr.Textbox(label="πŸ“„ Text Result", lines=15, show_copy_button=True)
 
165
 
166
  submit_btn.click(fn=process_ocr_task, inputs=[image_input, model_size, task_type], outputs=[output_text])
167