Spaces:
Sleeping
Sleeping
alyxx commited on
Commit ·
ae81574
1
Parent(s): 93cd8cf
adding app.py and requirements.txt
Browse files- app.py +27 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#app.py
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# the text generation pipeline
|
| 6 |
+
pipe = pipeline("text-generation", model="kaiku03/wildchat2")
|
| 7 |
+
|
| 8 |
+
examples = [
|
| 9 |
+
"her lips touches mine and she continues to",
|
| 10 |
+
"In a world where magic is real,",
|
| 11 |
+
"The sun sets over the horizon as",
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
# function for the gradio app
|
| 15 |
+
def fn_textgen(prompt):
|
| 16 |
+
return pipe(prompt, max_length=100)[0]['generated_text']
|
| 17 |
+
|
| 18 |
+
# create a Gradio interface
|
| 19 |
+
gr.Interface(fn=fn_textgen,
|
| 20 |
+
inputs="textbox",
|
| 21 |
+
outputs=gr.Textbox(label="Generated text"),
|
| 22 |
+
examples=examples,
|
| 23 |
+
title="WildChat Text Generation",
|
| 24 |
+
description="Enter a prompt and watch WildChat generate a response!",
|
| 25 |
+
article='This model was trained on 20% only of the wildchat dataset')
|
| 26 |
+
|
| 27 |
+
gr.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|