Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ from transformers import T5ForConditionalGeneration, T5Tokenizer
|
|
| 3 |
from difflib import SequenceMatcher
|
| 4 |
import gradio as gr
|
| 5 |
|
|
|
|
|
|
|
| 6 |
# Load the model and tokenizer
|
| 7 |
model = T5ForConditionalGeneration.from_pretrained("./finetuned_t5_ocr_ppm_v2")
|
| 8 |
tokenizer = T5Tokenizer.from_pretrained("./finetuned_t5_ocr_ppm_v2")
|
|
@@ -41,7 +43,7 @@ def process_text(ocr_input):
|
|
| 41 |
# Gradio UI
|
| 42 |
demo = gr.Interface(
|
| 43 |
fn=process_text,
|
| 44 |
-
inputs=gr.Textbox(lines=10, label="Paste Noisy OCR Text"),
|
| 45 |
outputs=[
|
| 46 |
gr.Textbox(label="Cleaned (Corrected) Text"),
|
| 47 |
gr.HTML(label="Highlighted Corrections (Red = original, Green = correction)")
|
|
|
|
| 3 |
from difflib import SequenceMatcher
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
# Sample Input
|
| 7 |
+
sample_input = '''BRILLAT SAVARIN - Physilogie du go没t ou m茅ditations de gastronomie tarnscendante : ouvrage th茅0r1qu3, historique et 脿 l聮order du jour, d茅id茅 aux g45tr00m35 parisiens par un professeur. - 4e 茅d. - Paris, Just Tessire, 1834. - 2 vol., 384 p. ; 403 p. ; 22 cm. R35 XIX 260 y'''
|
| 8 |
# Load the model and tokenizer
|
| 9 |
model = T5ForConditionalGeneration.from_pretrained("./finetuned_t5_ocr_ppm_v2")
|
| 10 |
tokenizer = T5Tokenizer.from_pretrained("./finetuned_t5_ocr_ppm_v2")
|
|
|
|
| 43 |
# Gradio UI
|
| 44 |
demo = gr.Interface(
|
| 45 |
fn=process_text,
|
| 46 |
+
inputs=gr.Textbox(lines=10, label="Paste Noisy OCR Text",value = sample_input),
|
| 47 |
outputs=[
|
| 48 |
gr.Textbox(label="Cleaned (Corrected) Text"),
|
| 49 |
gr.HTML(label="Highlighted Corrections (Red = original, Green = correction)")
|