Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ model = model.to(device)
|
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
-
# In[
|
| 23 |
|
| 24 |
|
| 25 |
def title_gen(keywords, diversity, temp):
|
|
@@ -50,11 +50,11 @@ def title_gen(keywords, diversity, temp):
|
|
| 50 |
#top_p = 0.60,
|
| 51 |
)
|
| 52 |
|
| 53 |
-
titles = ""
|
| 54 |
|
| 55 |
for i in range(len(beam_outputs)):
|
| 56 |
result = tokenizer.decode(beam_outputs[i], skip_special_tokens=True)
|
| 57 |
-
titles += f"<p align=center><b>{result}</b></p>" #Create string with titles and <br> tag for html reading in gradio html
|
| 58 |
|
| 59 |
return titles
|
| 60 |
|
|
@@ -65,7 +65,7 @@ def title_gen(keywords, diversity, temp):
|
|
| 65 |
import gradio as gr
|
| 66 |
|
| 67 |
|
| 68 |
-
# In[
|
| 69 |
|
| 70 |
|
| 71 |
iface = gr.Interface(fn=title_gen,
|
|
@@ -74,7 +74,14 @@ iface = gr.Interface(fn=title_gen,
|
|
| 74 |
title="AI Keywords to Title Generator",
|
| 75 |
#description="Turn keywords into creative suggestions",
|
| 76 |
article="<div align=left><h1>AI Creative Title Generator</h1><li>With just keywords, generate a list of creative titles.</li><li>Click on Submit to generate more title options.</li><li>Tweak slider for less or more creative titles</li><li>Check 'diversity' to turn on diversity beam search</li><p>AI Model:<br><li>T5 Model trained on a dataset of titles and related keywords</li><li>Original model id: EnglishVoice/t5-base-keywords-to-headline by English Voice AI Labs</li></p><p>Default parameter details:<br><li>Temperature = 1.2, no_repeat_ngram_size=3, top_k = 15, penalty_alpha = 0.8, max_new_tokens = 30</li><p>Diversity beam search params:<br><li>num_beams=20, diversity_penalty=0.8, num_beam_groups=20</li></div>",
|
| 77 |
-
flagging_mode='never'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
iface.launch()
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
+
# In[45]:
|
| 23 |
|
| 24 |
|
| 25 |
def title_gen(keywords, diversity, temp):
|
|
|
|
| 50 |
#top_p = 0.60,
|
| 51 |
)
|
| 52 |
|
| 53 |
+
titles = "<p align=center>Title Suggestions:</p>"
|
| 54 |
|
| 55 |
for i in range(len(beam_outputs)):
|
| 56 |
result = tokenizer.decode(beam_outputs[i], skip_special_tokens=True)
|
| 57 |
+
titles += f"<p align=center><b>{result}</b></p></p>" #Create string with titles and <br> tag for html reading in gradio html
|
| 58 |
|
| 59 |
return titles
|
| 60 |
|
|
|
|
| 65 |
import gradio as gr
|
| 66 |
|
| 67 |
|
| 68 |
+
# In[48]:
|
| 69 |
|
| 70 |
|
| 71 |
iface = gr.Interface(fn=title_gen,
|
|
|
|
| 74 |
title="AI Keywords to Title Generator",
|
| 75 |
#description="Turn keywords into creative suggestions",
|
| 76 |
article="<div align=left><h1>AI Creative Title Generator</h1><li>With just keywords, generate a list of creative titles.</li><li>Click on Submit to generate more title options.</li><li>Tweak slider for less or more creative titles</li><li>Check 'diversity' to turn on diversity beam search</li><p>AI Model:<br><li>T5 Model trained on a dataset of titles and related keywords</li><li>Original model id: EnglishVoice/t5-base-keywords-to-headline by English Voice AI Labs</li></p><p>Default parameter details:<br><li>Temperature = 1.2, no_repeat_ngram_size=3, top_k = 15, penalty_alpha = 0.8, max_new_tokens = 30</li><p>Diversity beam search params:<br><li>num_beams=20, diversity_penalty=0.8, num_beam_groups=20</li></div>",
|
| 77 |
+
flagging_mode='never',
|
| 78 |
+
examples=[
|
| 79 |
+
["new, weight loss, lifestyle"],
|
| 80 |
+
["launch, free, dating, app"],
|
| 81 |
+
["AI, text to video, app"],
|
| 82 |
+
["new movie, watch, free streaming"],
|
| 83 |
+
],
|
| 84 |
+
cache_examples=True,
|
| 85 |
)
|
| 86 |
|
| 87 |
iface.launch()
|