prithivMLmods commited on
Commit
29d805e
·
verified ·
1 Parent(s): 45fbf47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -22
app.py CHANGED
@@ -285,9 +285,9 @@ def generate_video(model_name: str, text: str, video_path: str,
285
 
286
  # Define examples for image and video inference
287
  image_examples = [
288
- ["Convert this page to docling", "images/1.png", "SmolDocling-256M-preview"],
289
- ["OCR the image", "images/2.jpg", "Nanonets-OCR-s"],
290
- ["Convert this page to docling", "images/3.png", "SmolDocling-256M-preview"],
291
  ]
292
 
293
  video_examples = [
@@ -307,7 +307,7 @@ css = """
307
 
308
  # Create the Gradio Interface
309
  with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
310
- gr.Markdown("# **[core OCR](https://huggingface.co/collections/prithivMLmods/core-and-docscope-ocr-models-6816d7f1bde3f911c6c852bc)**")
311
  with gr.Row():
312
  with gr.Column():
313
  with gr.Tabs():
@@ -315,38 +315,32 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
315
  image_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
316
  image_upload = gr.Image(type="pil", label="Image")
317
  image_submit = gr.Button("Submit", elem_classes="submit-btn")
 
 
 
 
318
  with gr.TabItem("Video Inference"):
319
  video_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
320
  video_upload = gr.Video(label="Video")
321
  video_submit = gr.Button("Submit", elem_classes="submit-btn")
 
 
 
 
322
  with gr.Accordion("Advanced options", open=False):
323
  max_new_tokens = gr.Slider(label="Max new tokens", minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS)
324
  temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, step=0.1, value=0.6)
325
  top_p = gr.Slider(label="Top-p (nucleus sampling)", minimum=0.05, maximum=1.0, step=0.05, value=0.9)
326
  top_k = gr.Slider(label="Top-k", minimum=1, maximum=1000, step=1, value=50)
327
  repetition_penalty = gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.2)
328
-
329
  with gr.Column():
330
- output = gr.Textbox(label="Output", interactive=False, lines=15, scale=2)
331
  model_choice = gr.Radio(
332
- choices=["Nanonets-OCR-s", "MonkeyOCR-Recognition", "SmolDocling-256M-preview"],
333
  label="Select Model",
334
  value="Nanonets-OCR-s"
335
  )
336
- with gr.Tabs():
337
- with gr.TabItem("Image Examples"):
338
- gr.Examples(
339
- examples=image_examples,
340
- inputs=[image_query, image_upload, model_choice],
341
- label="Click on an example to run"
342
- )
343
- with gr.TabItem("Video Examples"):
344
- gr.Examples(
345
- examples=video_examples,
346
- inputs=[video_query, video_upload, model_choice],
347
- label="Click on an example to run"
348
- )
349
-
350
  image_submit.click(
351
  fn=generate_image,
352
  inputs=[model_choice, image_query, image_upload, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
@@ -359,4 +353,4 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
359
  )
360
 
361
  if __name__ == "__main__":
362
- demo.queue(max_size=30).launch(share=True, ssr_mode=False, show_error=True)
 
285
 
286
  # Define examples for image and video inference
287
  image_examples = [
288
+ ["Convert this page to docling", "images/1.png"],
289
+ ["OCR the image", "images/2.jpg"],
290
+ ["Convert this page to docling", "images/3.png"],
291
  ]
292
 
293
  video_examples = [
 
307
 
308
  # Create the Gradio Interface
309
  with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
310
+ gr.Markdown("# **[OCR Net 4x](https://huggingface.co/collections/prithivMLmods/multimodal-implementations-67c9982ea04b39f0608badb0)**")
311
  with gr.Row():
312
  with gr.Column():
313
  with gr.Tabs():
 
315
  image_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
316
  image_upload = gr.Image(type="pil", label="Image")
317
  image_submit = gr.Button("Submit", elem_classes="submit-btn")
318
+ gr.Examples(
319
+ examples=image_examples,
320
+ inputs=[image_query, image_upload, model_choice]
321
+ )
322
  with gr.TabItem("Video Inference"):
323
  video_query = gr.Textbox(label="Query Input", placeholder="Enter your query here...")
324
  video_upload = gr.Video(label="Video")
325
  video_submit = gr.Button("Submit", elem_classes="submit-btn")
326
+ gr.Examples(
327
+ examples=video_examples,
328
+ inputs=[video_query, video_upload]
329
+ )
330
  with gr.Accordion("Advanced options", open=False):
331
  max_new_tokens = gr.Slider(label="Max new tokens", minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS)
332
  temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, step=0.1, value=0.6)
333
  top_p = gr.Slider(label="Top-p (nucleus sampling)", minimum=0.05, maximum=1.0, step=0.05, value=0.9)
334
  top_k = gr.Slider(label="Top-k", minimum=1, maximum=1000, step=1, value=50)
335
  repetition_penalty = gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.2)
 
336
  with gr.Column():
337
+ output = gr.Textbox(label="Output", interactive=False, lines=3, scale=2)
338
  model_choice = gr.Radio(
339
+ choices=["Nanonets-OCR-s", "SmolDocling-256M-preview", "MonkeyOCR-Recognition"],
340
  label="Select Model",
341
  value="Nanonets-OCR-s"
342
  )
343
+
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  image_submit.click(
345
  fn=generate_image,
346
  inputs=[model_choice, image_query, image_upload, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
 
353
  )
354
 
355
  if __name__ == "__main__":
356
+ demo.queue(max_size=30).launch(share=True, mcp_server=True, ssr_mode=False, show_error=True)