Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
import galai as gal
|
| 5 |
+
|
| 6 |
+
model = gal.load_model("base", num_gpus = 0, dtype='float16')
|
| 7 |
+
|
| 8 |
+
def predict(text):
|
| 9 |
+
text = text.strip()
|
| 10 |
+
out_text = model.generate(text)
|
| 11 |
+
out_text = "<p>" + out_text + "</p>"
|
| 12 |
+
out_text = out_text.replace(text, text + "<b><span style='background-color: #ffffcc;'>")
|
| 13 |
+
out_text = out_text + "</span></b>"
|
| 14 |
+
out_text = out_text.replace("\n", "<br>")
|
| 15 |
+
return out_text
|
| 16 |
+
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
+
fn=predict,
|
| 19 |
+
inputs=gr.Textbox(lines=10),
|
| 20 |
+
outputs=gr.HTML(),
|
| 21 |
+
description="Galactica",
|
| 22 |
+
examples=[["Abstractive Generation of Scientific Slides from Academic Articles"]]
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
iface.launch(share=True)
|