berito commited on
Commit
0818c3c
·
1 Parent(s): 5a17a45

model upload and included some instructions

Browse files
Files changed (1) hide show
  1. app.py +38 -10
app.py CHANGED
@@ -1,31 +1,59 @@
1
  import streamlit as st
2
  from PIL import Image
 
3
  # Streamlit UI
4
  # Left column: Text input and summary
5
  st.title("Amharic Text Summarizer")
6
- st.write("Paste your Amharic text below and click 'Summarize' to generate a concise summary.")
7
  st.write("This app uses a trained FastText model to summarize your input text.")
8
- col1, col2 = st.columns([6, 1]) # Wider column on the left
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  # Layout with two columns
10
  # with col1:
11
  # Text input area
12
- input_text = st.text_area("Input Text", placeholder="Paste your Amharic text here...",height=200)
13
- summarized_text=""
 
14
  # Summarize button
15
  if st.button("Summarize"):
16
  if input_text.strip():
17
  with st.spinner("Summarizing..."):
18
- summarized_text = "summarize_text(input_text, model)"
19
- st.success("Summarization complete!")
 
 
20
  else:
21
  summarized_text = "Please enter text to summarize."
22
 
23
- # Output text area for summary
24
- st.text_area("Summarized Text", value=summarized_text, height=200)
25
  # Right column: Display the image
26
  # with col2:
27
- st.write("### Average Loss by Epoch")
28
-
 
 
 
 
 
 
 
29
  # Load and display the image
30
  image = Image.open("avgllose_epoch.png") # Replace with the actual path to your image
31
  st.image(image, caption="Epoch vs Average Loss", use_container_width=True)
 
1
  import streamlit as st
2
  from PIL import Image
3
+ from fast_text_summarizer import FastTextSummarizer
4
  # Streamlit UI
5
  # Left column: Text input and summary
6
  st.title("Amharic Text Summarizer")
 
7
  st.write("This app uses a trained FastText model to summarize your input text.")
8
+ st.markdown(
9
+ """
10
+ <p style="font-size:16px; color:gray;">
11
+ Summarization is performed by vectorizing the words in the input sentences, calculating cosine similarity for each sentence, and selecting the most relevant sentences based on their similarity to the overall document.
12
+ </p>
13
+ <p style="font-size:16px; color:gray;">
14
+ The FastText word embedding model used in this project achieved an average loss of 0.3215. It was trained with a dimensionality of 50 and 30 epochs on the GPAC Amharic dataset, which contains 82 million words and 534,123 unique words.
15
+ For more details, you can refer to the orginal paper of the dataset used in this project:
16
+ [Click here to access the paper](https://doi.org/10.3390/info12010020).
17
+ </p>
18
+
19
+ <p>
20
+ Note: The dimensionality of the model was reduced to minimize its size, making it suitable for upload to Hugging Face, which has a maximum file size limit of 1GB. This reduction successfully decreased the model size from 1.4GB to 598.53MB.To view code for this project please click Files in the platform
21
+ </p
22
+ """,
23
+ unsafe_allow_html=True
24
+ )
25
+ st.write("Paste your Amharic text below and click 'Summarize' to generate a concise summary.")
26
+ # Load the model (ensure the path to your model file is correct)
27
+ model_file = "model.bin" # Replace with your actual model file path
28
+ summarizer = FastTextSummarizer(model_file)
29
  # Layout with two columns
30
  # with col1:
31
  # Text input area
32
+ input_text = st.text_area("Input Text", placeholder="Paste your Amharic text here and select number of sentence summary.then click summarize button,then wait .result will be displayed below ...",height=200)
33
+ num_sentences = st.slider("Number of Sentences in Summary", min_value=1, max_value=10, value=3)
34
+ # summarized_text=""
35
  # Summarize button
36
  if st.button("Summarize"):
37
  if input_text.strip():
38
  with st.spinner("Summarizing..."):
39
+ summarized_text = summarizer.summarize(input_text, num_sentences=num_sentences)
40
+ st.success("Summarization complete!")
41
+ # Output text area for summary
42
+ st.text_area("Summarized Text", value=summarized_text, height=200)
43
  else:
44
  summarized_text = "Please enter text to summarize."
45
 
 
 
46
  # Right column: Display the image
47
  # with col2:
48
+ st.write("#### Average Loss by Epoch")
49
+ st.markdown(
50
+ """
51
+ <p style="font-size:16px; color:gray;">
52
+ This is the result of training a FastText word embedding model with a dimensionality of 100, a learning rate of 0.05, and 30 epochs, achieving an average loss of 0.541634. However, the resulting model size is 1.4GB.
53
+ </p>
54
+ """,
55
+ unsafe_allow_html=True
56
+ )
57
  # Load and display the image
58
  image = Image.open("avgllose_epoch.png") # Replace with the actual path to your image
59
  st.image(image, caption="Epoch vs Average Loss", use_container_width=True)