Summarization / app.py
Mr-Vicky-01's picture
Update app.py
3af16c6 verified
from langchain import HuggingFaceHub
import gradio as gr
import os
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.getenv("HF_TOKEN")
checkpoint = "Mr-Vicky-01/Bart-Finetuned-conversational-summarization"
model = HuggingFaceHub(repo_id=checkpoint,
# huggingfacehub_api_token = os.getenv("HF_TOKEN"),
model_kwargs={"temperature":0.1,
"max_new_tokens":100,
"do_sample":False
})
def generate_summary(text):
summary = model(text)
return summary
examples = [
["""The Industrial Revolution, often regarded as one of the most transformative periods in human history, commenced in Britain during the latter part of the 18th century and gradually spread across the globe. Its impact was profound and multifaceted, reshaping nearly every aspect of society, economy, and daily life. At its core was the rapid development and adoption of new technologies, such as steam power, mechanization, and the factory system. These innovations revolutionized traditional industries, enabling mass production on an unprecedented scale and significantly increasing efficiency and productivity. As a result, goods once crafted painstakingly by hand could now be manufactured swiftly and in large quantities, leading to an explosion in consumer markets and a surge in global trade. Concurrently, the revolution spurred urbanization as rural populations flocked to burgeoning industrial centers in search of employment opportunities, fundamentally altering the demographic landscape and giving rise to sprawling cities teeming with people and activity.
However, the Industrial Revolution was not without its drawbacks and challenges. While it brought about undeniable economic growth and prosperity for many, it also engendered profound social inequalities and labor exploitation. Factory workers, including men, women, and children, toiled for long hours in hazardous conditions for meager wages, often subjected to harsh treatment by factory owners and overseers. Moreover, the relentless pursuit of profit and industrial expansion exacted a heavy toll on the environment, as factories spewed pollutants into the air and waterways, and deforestation accelerated to meet the insatiable demand for timber and resources.
Despite these drawbacks, the Industrial Revolution fundamentally transformed the fabric of society and laid the groundwork for the modern world. It fueled technological innovation, spurred scientific inquiry, and catalyzed advancements in transportation, communication, and medicine. Moreover, it set the stage for the rise of capitalism and the development of modern economic systems, shaping the dynamics of global commerce and trade for centuries to come. Today, its legacy endures in the form of industrial infrastructure, urban landscapes, and societal norms, serving as a testament to humanity's capacity for innovation and adaptation in the face of profound change."""]
]
demo = gr.Interface(fn=generate_summary, inputs='text',outputs='text',title='Text Summarization', examples=examples)
demo.launch(debug=True,share=True)