Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,17 @@ models = {
|
|
21 |
"Pegasus": "google/pegasus-xsum"
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
# Streamlit app layout
|
25 |
st.title("Summarization with Multiple Models")
|
26 |
|
@@ -30,6 +41,13 @@ model_choice = st.selectbox("Select a model for summarization", models.keys())
|
|
30 |
# Text area for input
|
31 |
input_text = st.text_area("Enter the long text you want to summarize", height=300)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Button to generate the summary
|
34 |
if st.button("Generate Summary"):
|
35 |
# Show a spinner while generating the summary
|
@@ -40,6 +58,10 @@ if st.button("Generate Summary"):
|
|
40 |
# Log the model choice
|
41 |
st.write(f"Using model: **{model_choice}** for summarization.")
|
42 |
|
|
|
|
|
|
|
|
|
43 |
if input_text:
|
44 |
# Generate the summary
|
45 |
summary = summarizer(input_text, max_length=350, min_length=30, do_sample=False)
|
|
|
21 |
"Pegasus": "google/pegasus-xsum"
|
22 |
}
|
23 |
|
24 |
+
# Example texts
|
25 |
+
example_texts = {
|
26 |
+
"Example 1": "net product sales may be periodically impacted by adjustments made to the company 's sales allowance and marketing support accrual to record unanticipated customer deductions from accounts receivable or to reduce the accrual by any amounts which were accrued in the past but not taken by customers through deductions from accounts receivable within a certain time period . in the aggregate , these adjustments had the effect of increasing net product sales and operating income by approximately $ 16,000 and $ 195,000 for fiscal 2019 and fiscal 2018 , respectively . net product sales are comprised primarily of the sales of houseware and audio products which bear the emerson ยฎ brand name . the major elements which contributed to the overall decrease in net product sales were as follows : i ) houseware product net sales decreased $ 6.5 million , or 64.5 % , to $ 3.6 million in fiscal 2019 as compared to $ 10.1 million in fiscal 2018 , principally driven by a decrease in sales of microwave ovens , compact refrigerators and wine products partially offset by an increase in toaster ovens . the year-over-year decreases were driven by lower year-over-year retail sell through on existing models and competitive pricing activity . ii ) audio product net sales were $ 5.0 million in fiscal 2019 compared to $ 4.3 million in fiscal 2018 , an increase of $ 0.7 million , or 16.8 % , resulting from increased net sales of clock radios . business operations โ the company expects to continue to expand its existing distribution channels and to develop and promote new products to regain shelf spaces with retailers in the usa . the company is also investing in products and marketing activities to expand its sales through internet and ecommerce channels . these efforts require investments in appropriate human resources , media marketing and development of products in various categories in addition to the traditional home appliances and audio products on which the company has historically focused . the company also is continuing its efforts to identify strategic courses of action related to its licensing activities , including seeking new licensing relationships . the company has engaged lmca as an agent to assist in identifying and procuring potential licensees . emerson 's success is dependent on its ability to anticipate and respond to changing consumer demands and trends in a timely manner , as well as expanding into new markets and sourcing new products that are profitable to the company . geo-political factors 18 may also affect demand for the company 's products , which are subject to customs requirements and to tariffs and quotas set by governments through mutual agr eements and bilateral actions . the company expects that the recently announced u.s. tariffs on certain imported goods from china , which tariffs were increased from 10 % to 25 % in may 2019 , and the current u.s. administration 's public support for additional tariffs on imported goods from china , and china 's retaliatory tariffs on certain goods imported from the united states , as well as modifications to international trade policy , may affect its product costs going forward , which could require the company to t ake pricing action to offset the increasing costs ; however , at this time the company is unable to quantify this possible effect on its costs . although the company is monitoring the trade environment and working to mitigate the possible effect of tariffs th rough pricing and sourcing strategies , including drawing down inventory built up in advance of the recent tariff increase , the company can not be certain how its customers and competitors will react to the actions taken , and some costs may be passed through to the company 's customers as product price increases in the future . for more information on risks associated with the company 's operations , including tariffs , please see the risk factors within part i , item 1a , โ risk factors โ in this annual report on for m 10-k. emerson has taken active steps to further streamline its operations to reduce and control its operating costs . the operating costs for fiscal 2019 were reduced to $ 3.8 million , which included $ 346,000 in legal fees related to a trademark infringement suit initiated by the company , as compared to $ 4.9 million for fiscal 2018 which included $ 489,000 in legal fees related to a trademark infringement suit initiated by the company . licensing revenue โ licensing revenue in fiscal 2019 was $ 0.4 million as compared to $ 0.7 million for fiscal 2018 , a decrease of $ 0.3 million , or 38.5 % , driven by lower year-over-year sales by the company 's licensees of emerson ยฎ branded product . one of the company 's licensees chose not renew its agreement when it expired on december 31 , 2018. net revenues โ as a result of the foregoing factors , the company 's net revenues were $ 9.0 million for fiscal 2019 as compared to $ 15.0 million for fiscal 2018 , a decrease of $ 6.0 million , or 40.2 % . cost of sales โ cost of sales includes those components as described in note 1 โ cost of sales โ of the notes to the consolidated financial statements . in absolute terms , cost of sales decreased $ 5.1 million , or 37.1 % , to $ 8.8 million in fiscal 2019 as compared to $ 13.9 million in fiscal 2018. the decrease in absolute terms for fiscal 2019 as compared to fiscal 2018 was primarily related to the reduced net product sales and lower year-over-year gross cost of sales as a percentage of grosssales . story_separator_special_tag management analyzes historical returns , current economic trends and changes in customer demand for our products when evaluating the adequacy of the reserve for sales returns . management judgments and estimates must be made and used in connection with establishing the sales return reserves in any accounting period . additional reserves may be required if actual sales returns increase above the historical return rates . conversely , the sales return reserve could be decreased if the actual return rates are less than the historical return rates , which were used to establish the reserve . sales allowance and marketing support accruals . sales allowances , marketing support programs , promotions and other volume-based incentives which are provided to retailers and distributors are accounted for on an accrual basis as a reduction to net revenues in the period in which the related sales are recognized in accordance with asc topic 606 , โ revenue from contracts with customers โ . at the time of sale , the company reduces recognized gross revenue by allowances to cover , in addition to estimated sales returns as required by asc topic 606 , โ revenue from contracts with customers . โ ( i ) sales incentives offered to customers that meet the criteria for accrual under asc topic 606 ( ii ) under sab 's 101 and 104 , an estimated amount to recognize additional non-offered deductions it anticipates and can reasonably estimate will be taken by customers which it does not expect to recover . accruals for the estimated amount of future non-offered deductions are required to be made as contra-revenue items because that percentage of shipped revenue fails to meet the collectability criteria within sab 104 's and 101 's four revenue recognition criteria , all of which are required to be met in order to recognize revenue . if additional marketing support programs , promotions and other volume-based incentives are required to promote the company 's products subsequent to the initial sale , then additional reserves may be required and are accrued for when such support is offered . recently adopted accounting pronouncements 21 accounting standards update 2014-09 โ revenue from contracts wi th customers โ ( issued may 2014 ) in may 2014 , the fasb issued asu 2014-09 `` revenue from contracts with customers `` , subsequently amended and collectively topic 606. the standard replaced almost all existing revenue recognition guidance in u.s. gaap , with the intention to improve and converge with international standards the financial reporting requirements for revenue from contracts with customers . the core principle of asc 606 is that an entity should recognize revenue for the transfer of goods or services equal to the amount that it expects to be entitled to receive for those goods or services . asc 606 allows for adoption either on a full retrospective basis to each prior reporting period presented or on a modified retrospective basis with the cumulative effect of initially applying the new guidance recognized at the date of initial application , which became effective for the company beginning april 1 , 2018. the company adopted asc 606 in the first quarter of fiscal 2019 on a modified retrospective basis with no changes recognized in the prior year comparative financial statements . the adoption of this standard did not have a material impact on the company 's financial statements . the company has enhanced its disclosures of revenue to comply with the new guidance . recently-issued financial accounting pronouncements the following accounting standards updates ( โ asus โ ) were issued by the financial accounting standards board during the twelve months ended march 31 , 2019 or during the interim period between march 31 , 2019 and june 26 , 2019 which relate to or could relate to the company as concerns the company 's normal ongoing operations or the industry in which the company operates : accounting standards update 2016-13 โ financial instruments โ credit losses โ ( issued june 2016 ) in june 2016 , the fasb issued asu 2016-13 `` financial instruments - credit losses `` to introduce new guidance for the accounting for credit losses on instruments within its scope . asu 2016-13 requires among other things , the measurement of all expected credit losses for financial assets held at the reporting date based on historical experience , current conditions , and reasonable supportable forecasts . many of the loss estimation techniques applied today will still be permitted , although the inputs to those techniques will change to reflect the full amount of expected credit losses . in addition , the asu 2016-13 amends the accounting for credit losses on available-for-sale debt securities and purchased financial assets with credit deterioration . asu 2016-13 is effective for fiscal years and interim periods beginning after december 15 , 2019. early adoption is permitted . the company does not expect these amendments to have a material impact on its financial statements . accounting standards update 2016-02 โ leases โ ( issued february 2016 ) in february 2016 , the fasb issued asu 2016-02 โ leases โ , which requires lease assets and liabilities to be recorded on the balance sheet . this update is effective for public entities in fiscal years beginning after december 15 , 2018 , including interim reporting periods within those fiscal years , and certain qualitative and quantitative disclosures are also required . the company will adopt this asu and related amendments as of the beginning of the first quarter of the year ending march 31 , 2020 on a modified retrospective basis . early adoption is permitted . the company will apply the modified retrospective approach by recording a cumulative effect adjustment as of the date of adoption , whereby prior comparative periods will not be retrospectively presented in the consolidated financial statements . the company will also be electing certain practical expedients permitted under the transition guidance , including to retain the historical lease classification as well as relief",
|
27 |
+
"Example 2": "Machine learning algorithms are becoming more sophisticated, allowing for better data analysis.",
|
28 |
+
"Example 3": "Natural language processing enables machines to understand and respond to human language.",
|
29 |
+
}
|
30 |
+
|
31 |
+
# Function to count words in the input text
|
32 |
+
def count_words(text):
|
33 |
+
return len(text.split())
|
34 |
+
|
35 |
# Streamlit app layout
|
36 |
st.title("Summarization with Multiple Models")
|
37 |
|
|
|
41 |
# Text area for input
|
42 |
input_text = st.text_area("Enter the long text you want to summarize", height=300)
|
43 |
|
44 |
+
# Buttons for example texts
|
45 |
+
st.subheader("Example Texts")
|
46 |
+
for label, example in example_texts.items():
|
47 |
+
if st.button(label):
|
48 |
+
st.session_state.input_text = example # Store the example in the session state
|
49 |
+
st.text_area("Enter the long text you want to summarize", value=example, height=300) # Update the text area
|
50 |
+
|
51 |
# Button to generate the summary
|
52 |
if st.button("Generate Summary"):
|
53 |
# Show a spinner while generating the summary
|
|
|
58 |
# Log the model choice
|
59 |
st.write(f"Using model: **{model_choice}** for summarization.")
|
60 |
|
61 |
+
# Count and log the number of words in the input text
|
62 |
+
word_count = count_words(input_text)
|
63 |
+
st.write(f"Number of words in input: **{word_count}**")
|
64 |
+
|
65 |
if input_text:
|
66 |
# Generate the summary
|
67 |
summary = summarizer(input_text, max_length=350, min_length=30, do_sample=False)
|