Seif-Yasser
commited on
Commit
•
be9e49a
1
Parent(s):
4305c0a
Upload HuggingFace.py
Browse files- HuggingFace.py +13 -0
HuggingFace.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import transformers
|
2 |
+
from transformers import pipeline
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
model = pipeline("text-generation", model="gpt2", tokenizer="gpt2")
|
6 |
+
|
7 |
+
|
8 |
+
def generate_text(input_text):
|
9 |
+
return model(input_text)[0]['generated_text']
|
10 |
+
|
11 |
+
|
12 |
+
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
13 |
+
iface.launch(share=True)
|