yartyjung commited on
Commit
775c87e
1 Parent(s): 46796af

Upload 4 files

Browse files
Files changed (2) hide show
  1. app.py +17 -14
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,18 +1,21 @@
1
  import streamlit as st
2
  from transformers import pipeline
 
3
 
4
  pipe = pipeline(task="text-classification",model="yartyjung/Fake-Review-Detector")
5
-
6
- st.title("Review-Detector")
7
- text = st.text_input("your :red[suspicious] review here :sunglasses:",value="")
8
-
9
- if text is not None:
10
- predictions = pipe(text)
11
- st.text(predictions)
12
- if predictions[0]['label'] == 'fake':
13
- for p in predictions:
14
- st.subheader(f":red[FAKE] :blue[{ round(p['score'] * 100, 1)} %]")
15
- elif predictions[0]['label'] == 'real':
16
- for p in predictions:
17
- st.subheader(f":green[REAL] :blue[{ round(p['score'] * 100, 1)} %]")
18
- st.markdown(":red[***disclaimer*** This is a prediction by an _AI_, which might turn out incorrect.]")
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ st.cache_resource(ttl=300)
4
 
5
  pipe = pipeline(task="text-classification",model="yartyjung/Fake-Review-Detector")
6
+ st.title(":rainbow[Review-Detector]")
7
+ st.divider()
8
+ text = st.text_input("Your :red[suspicious] review here :sunglasses:",value="")
9
+ if st.button("predict"):
10
+ if text is not None:
11
+ predictions = pipe(text)
12
+ if predictions[0]['label'] == 'fake':
13
+ for p in predictions:
14
+ st.subheader(f":red[FAKE] :blue[{ round(p['score'] * 100, 1)} %]")
15
+ elif predictions[0]['label'] == 'real':
16
+ for p in predictions:
17
+ st.subheader(f":green[REAL] :blue[{ round(p['score'] * 100, 1)} %]")
18
+ st.divider()
19
+ st.markdown(":red[***disclaimer*** This is a prediction by an _AI_, which might turn out incorrect.]")
20
+ url = "https://huggingface.co/yartyjung/Fake-Review-Detector"
21
+ st.markdown(":yellow[check out model at this [link](%s)]" % url)
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- transformers
2
  torch
 
1
+ transformers
2
  torch