Spaces:
Runtime error
Runtime error
alirani
commited on
Commit
•
076a158
1
Parent(s):
6d3bd4e
feat: add synopsis processing
Browse files
app.py
CHANGED
@@ -11,7 +11,8 @@ def generate_synopsis(model, tokenizer, title):
|
|
11 |
input_ids = tokenizer(title, return_tensors="tf")
|
12 |
output = model.generate(input_ids['input_ids'], max_length=150, num_beams=5, no_repeat_ngram_size=2, top_k=50, attention_mask=input_ids['attention_mask'])
|
13 |
synopsis = tokenizer.decode(output[0], skip_special_tokens=True)
|
14 |
-
|
|
|
15 |
|
16 |
favicon = "https://i.ibb.co/JRdhFZg/favicon-32x32.png"
|
17 |
|
@@ -28,6 +29,6 @@ button_synopsis = st.button('Get synopsis')
|
|
28 |
if button_synopsis:
|
29 |
if len(prod_title.split(' ')) > 0:
|
30 |
gen_synopsis = generate_synopsis(model, tokenizer, f"{prod_title} : ")
|
31 |
-
st.text_area(gen_synopsis, disabled=True)
|
32 |
else:
|
33 |
st.write('Write a title for the generator to work !')
|
|
|
11 |
input_ids = tokenizer(title, return_tensors="tf")
|
12 |
output = model.generate(input_ids['input_ids'], max_length=150, num_beams=5, no_repeat_ngram_size=2, top_k=50, attention_mask=input_ids['attention_mask'])
|
13 |
synopsis = tokenizer.decode(output[0], skip_special_tokens=True)
|
14 |
+
processed_synopsis = "".join(synopsis.split(':')[1].rpartition('.')[:2]).strip()
|
15 |
+
return processed_synopsis
|
16 |
|
17 |
favicon = "https://i.ibb.co/JRdhFZg/favicon-32x32.png"
|
18 |
|
|
|
29 |
if button_synopsis:
|
30 |
if len(prod_title.split(' ')) > 0:
|
31 |
gen_synopsis = generate_synopsis(model, tokenizer, f"{prod_title} : ")
|
32 |
+
st.text_area('Generated synopsis', value=gen_synopsis, disabled=True)
|
33 |
else:
|
34 |
st.write('Write a title for the generator to work !')
|