Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
model_ckpt = "HenryAI/KerasBERTv1"
|
| 6 |
+
fill_mask = pipeline("fill-mask", model=model_ckpt)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def cloze_task(text):
|
| 10 |
+
preds = fill_mask(text)
|
| 11 |
+
return preds
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
answer = []
|
| 15 |
+
description="Let's see if BERT has learnt how to write Keras!"
|
| 16 |
+
title="Keras BERT v1",
|
| 17 |
+
gradio_ui = gr.Interface(fn= cloze_task,
|
| 18 |
+
title= title, description = description,
|
| 19 |
+
inputs=[gr.inputs.Textbox(lines=3)],
|
| 20 |
+
outputs=[gr.outputs.Textbox(label="Answer"),],
|
| 21 |
+
examples=[["from tensorflow.keras import [MASK]"],],
|
| 22 |
+
enable_queue=True
|
| 23 |
+
)
|
| 24 |
+
gradio_ui.launch(debug=True)
|
| 25 |
+
|
| 26 |
+
|