Alassea commited on
Commit
2f7bbc4
1 Parent(s): 688995b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+
5
+ @st.cache(allow_output_mutation=True, show_spinner=False)
6
+ def load_pipe():
7
+ pipe = pipeline("text2text-generation", model="maximedb/reviews-generator")
8
+ return pipe
9
+
10
+
11
+ st.title("Reviews Generator")
12
+ st.subheader("Pick a rating")
13
+
14
+ st.sidebar.header("Settings")
15
+ st.sidebar.subheader("Edit generate settings")
16
+ max_length = st.sidebar.slider("Max Length", min_value=10, max_value=64, value=32)
17
+ temperature = st.sidebar.slider("Temperature", value=1.0, min_value=0.0, max_value=1.0, step=0.05)
18
+ top_k = st.sidebar.slider("Top-k", min_value=10, max_value=500, value=50)
19
+ top_p = st.sidebar.slider("Top-p", min_value=0.0, max_value=1.0, step=0.05, value=1.0)
20
+
21
+ # Loading model
22
+ with st.spinner('Loading model...'):
23
+ pipe = load_pipe()
24
+
25
+ rating = st.slider("Rating", min_value=1, max_value=5, value=3)
26
+
27
+ if st.button("Generate"):
28
+ with st.spinner('Generating...'):
29
+ generated = pipe(str(rating), do_sample=True, max_length=max_length, temperature=temperature, top_k=top_k, top_p=top_p)[0]["generated_text"]
30
+ st.success(generated)