Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
title = "Συμπλήρωση κειμένου με το μοντέλο GPT2"
|
4 |
+
description = "Ένα απλό gradio demo για να δούμε πως φτιάχνουμε εύκολα A.I. εφαρμογές με την χρήση των Pipelines"
|
5 |
+
examples = [
|
6 |
+
["Mike was the famous space mouse"],
|
7 |
+
["The Earth's perimeter is"],
|
8 |
+
["You will never believe what happened yesterday on my way back home."],
|
9 |
+
]
|
10 |
+
|
11 |
+
model = pipeline("text-generation" , model="gpt2")
|
12 |
+
|
13 |
+
|
14 |
+
def predict(prompt):
|
15 |
+
completion = model(prompt)[0]["generated_text"]
|
16 |
+
return completion
|
17 |
+
|
18 |
+
gr.Interface(
|
19 |
+
fn=predict,
|
20 |
+
inputs="text",
|
21 |
+
outputs="text",
|
22 |
+
title=title,
|
23 |
+
description=description,
|
24 |
+
examples=examples,
|
25 |
+
enable_queue=True,
|
26 |
+
).launch()
|