Spaces:
Runtime error
Runtime error
=
commited on
Commit
·
00d7354
1
Parent(s):
82aa82e
initial gradio app for hf space
Browse files- app.py +18 -3
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,7 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
generator = pipeline(model="cactusfriend/nightmare-invokeai-prompts",
|
5 |
+
tokenizer="cactusfriend/nightmare-invokeai-prompts",
|
6 |
+
task="text-generation")
|
7 |
|
8 |
+
def makePrompts(prompt: str, temp: float = 1.8):
|
9 |
+
outputs = generator(prompt, max_new_tokens=100,
|
10 |
+
temperature=temp, do_sample=True,
|
11 |
+
top_p=0.9, top_k=40, num_return_sequences=5)
|
12 |
+
items = set([i['generated_text'] for i in outputs])
|
13 |
+
return "\n --- \n".join(items)
|
14 |
+
|
15 |
+
|
16 |
+
iface = gr.Interface(fn=makePrompts,
|
17 |
+
inputs=[gr.Textbox(lines=1, label="Prompt", info="the start of the prompts", placeholder="a photograph of"),
|
18 |
+
gr.Slider(0.5, 3.0, value=1.8, label="Temperature", info="higher = crazier")],
|
19 |
+
outputs=gr.Textbox(lines=10, label="Five prompts"),
|
20 |
+
title="Nightmare InvokeAI Prompts",
|
21 |
+
allow_flagging="never")
|
22 |
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|