Spaces:
Sleeping
Sleeping
seeded
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gc
|
2 |
import gradio as gr
|
3 |
-
from transformers import pipeline
|
4 |
|
5 |
pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
|
6 |
#gc.collect()
|
@@ -29,7 +29,8 @@ notes = """
|
|
29 |
- Feedback (Twitter): @akhooli (https://twitter.com/akhooli/status/1611025232201977859)
|
30 |
- Note/Disclaimer: may generate unaccepted or inappropriate content. Use at your own risk.
|
31 |
"""
|
32 |
-
def sayPoetry(prompt, temp=1.0, topk = 50, topp = 1.0, penalty=1.0):
|
|
|
33 |
gen = pipe(prompt, max_length=96, do_sample=True, temperature=temp, top_k=topk, top_p=topp, repetition_penalty=penalty,
|
34 |
min_length = 64, no_repeat_ngram_size = 3, return_full_text=True,
|
35 |
num_beams=5, num_return_sequences=1)[0]["generated_text"]
|
@@ -44,6 +45,7 @@ poetry = gr.Interface(fn=sayPoetry,
|
|
44 |
gr.Slider(25, 100, step=1,value=50, label='control top k'),
|
45 |
gr.Slider(0.80, 1.0, step=0.01,value=1.0, label='control top p'),
|
46 |
gr.Slider(0.90, 1.20, step=0.01,value=1.0, label='control penalty'),
|
|
|
47 |
],
|
48 |
outputs=[gr.Textbox(label="Generated Poetry:")],
|
49 |
|
|
|
1 |
import gc
|
2 |
import gradio as gr
|
3 |
+
from transformers import pipeline, set_seed
|
4 |
|
5 |
pipe = pipeline('text-generation', framework='pt', model='akhooli/ap2023', tokenizer='akhooli/ap2023')
|
6 |
#gc.collect()
|
|
|
29 |
- Feedback (Twitter): @akhooli (https://twitter.com/akhooli/status/1611025232201977859)
|
30 |
- Note/Disclaimer: may generate unaccepted or inappropriate content. Use at your own risk.
|
31 |
"""
|
32 |
+
def sayPoetry(prompt, temp=1.0, topk = 50, topp = 1.0, penalty=1.0, seed=114):
|
33 |
+
set_seed(seed)
|
34 |
gen = pipe(prompt, max_length=96, do_sample=True, temperature=temp, top_k=topk, top_p=topp, repetition_penalty=penalty,
|
35 |
min_length = 64, no_repeat_ngram_size = 3, return_full_text=True,
|
36 |
num_beams=5, num_return_sequences=1)[0]["generated_text"]
|
|
|
45 |
gr.Slider(25, 100, step=1,value=50, label='control top k'),
|
46 |
gr.Slider(0.80, 1.0, step=0.01,value=1.0, label='control top p'),
|
47 |
gr.Slider(0.90, 1.20, step=0.01,value=1.0, label='control penalty'),
|
48 |
+
gr.Number(default=139750, label='Seed'),
|
49 |
],
|
50 |
outputs=[gr.Textbox(label="Generated Poetry:")],
|
51 |
|