Commit
·
809abd3
1
Parent(s):
afad651
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
mport gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Create the fill-mask pipeline
|
5 |
+
fill_mask_pipe = pipeline("fill-mask", model="ayoubkirouane/FILL-MAsk-RoBERTa-base")
|
6 |
+
|
7 |
+
def fill_mask(text):
|
8 |
+
# Make a prediction using the fill-mask pipeline
|
9 |
+
results = fill_mask_pipe(text)
|
10 |
+
return results[0]["sequence"]
|
11 |
+
|
12 |
+
example = ["The capital of Algeria is <mask>."]
|
13 |
+
# Create a Gradio interface
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=fill_mask,
|
16 |
+
inputs="text",
|
17 |
+
outputs="text",
|
18 |
+
examples=example,
|
19 |
+
title="FILL-MAsk-RoBERTa-base Demo",
|
20 |
+
description="Enter a sentence with a masked token, and the model will predict the missing word.",
|
21 |
+
)
|
22 |
+
|
23 |
+
# Launch the Gradio app
|
24 |
+
iface.launch()
|