Spaces:
Sleeping
Sleeping
DutchNomadCode
commited on
Commit
•
62c4079
1
Parent(s):
dd13ee8
Test with getting first sentence
Browse files
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
def greet(
|
5 |
-
generator = pipeline("text-generation")
|
6 |
-
|
|
|
|
|
|
|
7 |
|
8 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
9 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
def greet(input):
|
5 |
+
generator = pipeline("text-generation", model="distilgpt2")
|
6 |
+
generated_text = generator(input)[0]['generated_text']
|
7 |
+
# Extract the first sentence and format it
|
8 |
+
first_sentence = generated_text.split('.')[0].strip()
|
9 |
+
return f"'{first_sentence}'"
|
10 |
|
11 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
12 |
iface.launch()
|