merterbak commited on
Commit
670b31b
·
verified ·
1 Parent(s): 143986a
Files changed (1) hide show
  1. app.py +4 -29
app.py CHANGED
@@ -96,33 +96,8 @@ def do_ocr(input_type, url, file, api_key):
96
  return extracted_text.strip(), rendered_markdown.strip(), images
97
 
98
 
99
- custom_css = """
100
- body {font-family: 'Helvetica Neue', Helvetica;}
101
- .gr-button {
102
- background-color: #4CAF50;
103
- color: white;
104
- border: none;
105
- padding: 10px 15px;
106
- border-radius: 5px;
107
- }
108
- .gr-button:hover {
109
- background-color: #45a049;
110
- }
111
- .gr-textbox {margin-bottom: 15px;}
112
- .tall-radio .gr-radio-item {
113
- padding: 15px 0;
114
- min-height: 50px;
115
- display: flex;
116
- align-items: center;
117
- }
118
- .tall-radio label {font-size: 16px;}
119
- """
120
-
121
- with gr.Blocks(
122
- title="Mistral OCR Demo",
123
- css=custom_css,
124
- theme=gr.themes.Soft()
125
- ) as demo:
126
  gr.Markdown("<h1 style='text-align: center;'>Mistral OCR Demo</h1>")
127
  gr.Markdown("<p style='text-align: center;'>Extract text and images from PDFs or images using Mistral's latest OCR model, Mistral OCR 3 (mistral-ocr-2512). You can also see markdown live.</p>")
128
  gr.Markdown("<p style='text-align: center;'>Provide your Mistral API key below or set the `MISTRAL` environment variable. Visit <a href='https://console.mistral.ai/'>Mistral AI Console</a> to manage your API key.</p>")
@@ -158,7 +133,7 @@ with gr.Blocks(
158
  pdf_example = gr.Button("PDF")
159
  img_example = gr.Button("Image")
160
  with gr.Column(scale=2):
161
- cleaned_output = gr.Textbox(label="Extracted Plain Text", lines=10, show_copy_button=True)
162
  markdown_output = gr.Markdown(label="Rendered Markdown Text")
163
  image_output = gr.Gallery(label="OCR Extracted Images", columns=2, height="auto")
164
 
@@ -186,4 +161,4 @@ with gr.Blocks(
186
  )
187
 
188
  if __name__ == "__main__":
189
- demo.launch()
 
96
  return extracted_text.strip(), rendered_markdown.strip(), images
97
 
98
 
99
+
100
+ with gr.Blocks(title="Mistral OCR Demo") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  gr.Markdown("<h1 style='text-align: center;'>Mistral OCR Demo</h1>")
102
  gr.Markdown("<p style='text-align: center;'>Extract text and images from PDFs or images using Mistral's latest OCR model, Mistral OCR 3 (mistral-ocr-2512). You can also see markdown live.</p>")
103
  gr.Markdown("<p style='text-align: center;'>Provide your Mistral API key below or set the `MISTRAL` environment variable. Visit <a href='https://console.mistral.ai/'>Mistral AI Console</a> to manage your API key.</p>")
 
133
  pdf_example = gr.Button("PDF")
134
  img_example = gr.Button("Image")
135
  with gr.Column(scale=2):
136
+ cleaned_output = gr.Textbox(label="Extracted Plain Text", lines=10, buttons=["copy"])
137
  markdown_output = gr.Markdown(label="Rendered Markdown Text")
138
  image_output = gr.Gallery(label="OCR Extracted Images", columns=2, height="auto")
139
 
 
161
  )
162
 
163
  if __name__ == "__main__":
164
+ demo.launch(theme=gr.themes.Soft())