Spaces:
Sleeping
Sleeping
Patrik Stano commited on
Commit ·
52db785
1
Parent(s): f802847
include examples
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline, AutoTokenizer
|
| 3 |
# Load the Hugging Face model
|
| 4 |
-
model_path = "patrixtano/mt5-
|
| 5 |
model_pipeline = pipeline("text2text-generation", model=model_path)
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained("patrixtano/mt5-
|
| 7 |
def predict(text_input):
|
| 8 |
"""
|
| 9 |
Generate a prediction for the given input text using the Hugging Face model.
|
|
@@ -20,14 +20,21 @@ def predict(text_input):
|
|
| 20 |
except Exception as e:
|
| 21 |
return f"Error: {str(e)}"
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# Define the Gradio interface
|
| 24 |
interface = gr.Interface(
|
| 25 |
fn=predict,
|
| 26 |
inputs=gr.Textbox(lines=5, label="Input Text"),
|
| 27 |
outputs=gr.Textbox(label="Model Output"),
|
| 28 |
-
title="
|
| 29 |
-
description="Enter text into the
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
)
|
| 32 |
|
| 33 |
# Launch the Gradio app
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline, AutoTokenizer
|
| 3 |
# Load the Hugging Face model
|
| 4 |
+
model_path = "patrixtano/mt5-base-anaphora_czech_6e"
|
| 5 |
model_pipeline = pipeline("text2text-generation", model=model_path)
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("patrixtano/mt5-base-anaphora_czech_6e")
|
| 7 |
def predict(text_input):
|
| 8 |
"""
|
| 9 |
Generate a prediction for the given input text using the Hugging Face model.
|
|
|
|
| 20 |
except Exception as e:
|
| 21 |
return f"Error: {str(e)}"
|
| 22 |
|
| 23 |
+
examples = ["Miluji ženu s vařečkou, <ana>která</ana> umí vařit.", "Zřejmě to musel fotit nějaký chatař od
|
| 24 |
+
sousedství , nebo by to mohl taky fotit můj manžel, ale <ana>on</ana> se obyčejně k aparátu
|
| 25 |
+
moc neměl.", "Tomáš se domluvil s Jardou, že <ant>ho</ant> odveze na nádraží."]
|
| 26 |
+
|
| 27 |
# Define the Gradio interface
|
| 28 |
interface = gr.Interface(
|
| 29 |
fn=predict,
|
| 30 |
inputs=gr.Textbox(lines=5, label="Input Text"),
|
| 31 |
outputs=gr.Textbox(label="Model Output"),
|
| 32 |
+
title="Anaphora resolution demo",
|
| 33 |
+
description="Enter text into the "Input Text" box, include <ana> </ana> tags around the anaphora which
|
| 34 |
+
is to be resolved. The model generates a copy of the text with <ant> </ant> tags marking the predicted
|
| 35 |
+
antecedent",
|
| 36 |
+
theme="default",
|
| 37 |
+
examples=examples
|
| 38 |
)
|
| 39 |
|
| 40 |
# Launch the Gradio app
|