Spaces:
Runtime error
Runtime error
added app
Browse files- app.py +27 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
pipe = pipeline('text-generation', model='daspartho/prompt-extend', device=0)
|
| 5 |
+
|
| 6 |
+
def extend_prompt(prompt):
|
| 7 |
+
return pipe(prompt+',', num_return_sequences=1)[0]["generated_text"]
|
| 8 |
+
|
| 9 |
+
examples = [
|
| 10 |
+
['elon musk as thor'],
|
| 11 |
+
["giant dragon flying in the sky"],
|
| 12 |
+
['psychedelic liquids space'],
|
| 13 |
+
["a coconut laying on the beach"],
|
| 14 |
+
["peaceful village landscape"],
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
+
description = "Enter a main idea for a prompt, and the model will attempt to add appropriate style cues.",
|
| 19 |
+
article = "<p style='text-align: center'><a href='https://github.com/daspartho/prompt-extend' target='_blank'>Github</a></p>",
|
| 20 |
+
fn=extend_prompt,
|
| 21 |
+
inputs=gr.Text(label="Type the prompt here"),
|
| 22 |
+
outputs=gr.TextArea(label='Extended prompt'),
|
| 23 |
+
examples=examples,
|
| 24 |
+
title="Prompt Extend"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|
| 3 |
+
gradio
|