Cynthiaaaaaaaa commited on
Commit
30d4d06
1 Parent(s): 0b3461a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -3,8 +3,8 @@ from transformers import pipeline
3
 
4
  # Summarization
5
  def summarization(text):
6
- image_to_text_model = pipeline("text-generation", model="ainize/bart-base-cnn")
7
- summary = image_to_text_model(text, max_length=100, do_sample=False)[0]["generated_text"]
8
  return summary
9
 
10
  # Sentiment Classification
@@ -14,18 +14,14 @@ def sentiment_classification(summary):
14
  return result
15
 
16
  def main():
17
- st.set_page_config(page_title="Your Image to Text Analysis", page_icon="🦜")
18
  st.header("Tell me your comments!")
19
- uploaded_file = st.file_uploader("Select an Image...")
20
-
21
- if uploaded_file is not None:
22
- with open(uploaded_file.name, "wb") as file:
23
- file.write(uploaded_file.getbuffer())
24
- st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
25
 
 
26
  # Stage 1: Summarization
27
- st.text('Processing image to text...')
28
- summary = summarization(uploaded_file.name)
29
  st.write(summary)
30
 
31
  # Stage 2: Sentiment Classification
 
3
 
4
  # Summarization
5
  def summarization(text):
6
+ text_model = pipeline("text-generation", model="ainize/bart-base-cnn")
7
+ summary = text_model(text, max_length=100, do_sample=False)[0]["generated_text"]
8
  return summary
9
 
10
  # Sentiment Classification
 
14
  return result
15
 
16
  def main():
17
+ st.set_page_config(page_title="Your Text Analysis", page_icon="🦜")
18
  st.header("Tell me your comments!")
19
+ text_input = st.text_input("Enter your text here:")
 
 
 
 
 
20
 
21
+ if text_input:
22
  # Stage 1: Summarization
23
+ st.text('Processing text...')
24
+ summary = summarization(text_input)
25
  st.write(summary)
26
 
27
  # Stage 2: Sentiment Classification