First Commit
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from streamlit_tags import st_tags, st_tags_sidebar
|
| 3 |
+
from keytotext import pipeline
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
############
|
| 7 |
+
## Main page
|
| 8 |
+
############
|
| 9 |
+
st.write("# Code for Keywords to Text")
|
| 10 |
+
|
| 11 |
+
st.markdown("***Idea is to build a model which will take keywords as inputs and generate sentences as outputs.***")
|
| 12 |
+
image = Image.open('1.png')
|
| 13 |
+
st.image(image)
|
| 14 |
+
|
| 15 |
+
st.sidebar.write("# Parameter Selection")
|
| 16 |
+
maxtags_sidebar = st.sidebar.slider('Number of tags allowed?', 1, 10, 3, key='ehikwegrjifbwreuk')
|
| 17 |
+
keywords = st_tags(
|
| 18 |
+
label='# Enter Keywords:',
|
| 19 |
+
text='Press enter to add more',
|
| 20 |
+
value=['Summer', 'Shoes', 'Sports'],
|
| 21 |
+
suggestions=['five', 'six', 'seven', 'eight', 'nine', 'three', 'eleven', 'ten', 'four'],
|
| 22 |
+
maxtags=maxtags_sidebar,
|
| 23 |
+
key="aljnf")
|
| 24 |
+
|
| 25 |
+
# Add selectbox in streamlit
|
| 26 |
+
option = st.sidebar.selectbox(
|
| 27 |
+
'Which model would you like to be selected?',
|
| 28 |
+
('k2t', 'k2t-base', 'mrm8488/t5-base-finetuned-common_gen'))
|
| 29 |
+
|
| 30 |
+
#if st.sidebar.button('Load Model'):
|
| 31 |
+
# nlp=pipeline(option)
|
| 32 |
+
# st.sidebar.success("Load Successfully!")
|
| 33 |
+
nlp=pipeline(option)
|
| 34 |
+
st.sidebar.success("Load Successfully!")
|
| 35 |
+
|
| 36 |
+
st.write("## Results:")
|
| 37 |
+
if st.button('Generate Text'):
|
| 38 |
+
out=nlp(keywords)
|
| 39 |
+
st.success(out)
|