Addaci commited on
Commit
0809a5a
·
verified ·
1 Parent(s): e2e0d9a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+
4
+ # Load your model and tokenizer from Hugging Face
5
+ model_name = "Addaci/byt5-small-finetuned-yiddish-experiment-10"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
+
9
+ def correct_yiddish_transcription(input_text):
10
+ inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
11
+ outputs = model.generate(**inputs)
12
+ corrected_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
13
+ return corrected_text
14
+
15
+ # Create Gradio Interface
16
+ interface = gr.Interface(
17
+ fn=correct_yiddish_transcription,
18
+ inputs=gr.Textbox(lines=5, label="Input Yiddish Text"),
19
+ outputs=gr.Textbox(label="Corrected Text"),
20
+ title="Yiddish Transcription Correction",
21
+ description="Corrects raw Yiddish machine transcription using a fine-tuned ByT5 model."
22
+ )
23
+
24
+ interface.launch()