Faizan Azizahmed Shaikh commited on
Commit
56ba709
1 Parent(s): 562bcf4

Upload 2 files

Browse files
Files changed (2) hide show
  1. summarizer.ipynb +57 -0
  2. summarizer.py +30 -0
summarizer.ipynb ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "bba55a7d-5acf-4732-8f1a-6c2015eda632",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from transformers import pipeline\n",
11
+ "import gradio as gr\n",
12
+ "from gradio.mix import Parallel, Series\n",
13
+ "\n",
14
+ "intro = \"\"\"BART Summarizer ~ Facebook\"\"\"\n",
15
+ "\n",
16
+ "i = \"\"\"In the bustling heart of the city, a new technological marvel was taking shape. Engineers and scientists, working around the clock, were on the brink of a discovery that would redefine humanity's relationship with energy. The invention, a renewable power source, promised to make fossil fuels a thing of the past, illuminating a path towards a sustainable future.\"\"\"\n",
17
+ "\n",
18
+ "j = \"\"\"In a small village untouched by modern civilization, the wisdom of the elders was passed down from generation to generation through stories and rituals. These tales, rich with symbolism and moral lessons, served as a compass for the community, nurturing values of respect, compassion, and humility. The young would gather around the fire, eyes wide with wonder, absorbing lessons that would guide them throughout their lives.\"\"\"\n",
19
+ "\n",
20
+ "k = \"\"\"In the technologically advanced city of Futura, a groundbreaking innovation has taken flight. Robotic bees, the creation of a visionary team of young engineers, are pollinating urban gardens. The concept emerged from the need to find a solution to the decline in bee populations and the rise of urban farming. These mechanical marvels mimic the behavior of real bees, flying from flower to flower and transferring pollen. Equipped with AI-driven sensors and lightweight materials, they are capable of performing delicate tasks. City dwellers have embraced the technology, and the buzzing of robotic bees is now a common sound over the rooftops of Futura, giving rise to lush green spaces amidst the concrete jungle.\"\"\"\n",
21
+ "\n",
22
+ "sample = [[i],[j],[k]]\n",
23
+ "\n",
24
+ "io = gr.Interface.load(\"huggingface/facebook/bart-large-cnn\")\n",
25
+ "iface = Parallel(io,\n",
26
+ " theme='huggingface', \n",
27
+ " title= 'BART Summarizer', \n",
28
+ " description = intro,\n",
29
+ " examples=sample,\n",
30
+ " inputs = gr.inputs.Textbox(lines = 10, label=\"Text\"))\n",
31
+ "\n",
32
+ "iface.launch(inline = False, enable_queue = True, show_api = False)"
33
+ ]
34
+ }
35
+ ],
36
+ "metadata": {
37
+ "kernelspec": {
38
+ "display_name": "Python 3 (ipykernel)",
39
+ "language": "python",
40
+ "name": "python3"
41
+ },
42
+ "language_info": {
43
+ "codemirror_mode": {
44
+ "name": "ipython",
45
+ "version": 3
46
+ },
47
+ "file_extension": ".py",
48
+ "mimetype": "text/x-python",
49
+ "name": "python",
50
+ "nbconvert_exporter": "python",
51
+ "pygments_lexer": "ipython3",
52
+ "version": "3.11.4"
53
+ }
54
+ },
55
+ "nbformat": 4,
56
+ "nbformat_minor": 5
57
+ }
summarizer.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[ ]:
5
+
6
+
7
+ from transformers import pipeline
8
+ import gradio as gr
9
+ from gradio.mix import Parallel, Series
10
+
11
+ intro = """BART Summarizer ~ Facebook"""
12
+
13
+ i = """In the bustling heart of the city, a new technological marvel was taking shape. Engineers and scientists, working around the clock, were on the brink of a discovery that would redefine humanity's relationship with energy. The invention, a renewable power source, promised to make fossil fuels a thing of the past, illuminating a path towards a sustainable future."""
14
+
15
+ j = """In a small village untouched by modern civilization, the wisdom of the elders was passed down from generation to generation through stories and rituals. These tales, rich with symbolism and moral lessons, served as a compass for the community, nurturing values of respect, compassion, and humility. The young would gather around the fire, eyes wide with wonder, absorbing lessons that would guide them throughout their lives."""
16
+
17
+ k = """In the technologically advanced city of Futura, a groundbreaking innovation has taken flight. Robotic bees, the creation of a visionary team of young engineers, are pollinating urban gardens. The concept emerged from the need to find a solution to the decline in bee populations and the rise of urban farming. These mechanical marvels mimic the behavior of real bees, flying from flower to flower and transferring pollen. Equipped with AI-driven sensors and lightweight materials, they are capable of performing delicate tasks. City dwellers have embraced the technology, and the buzzing of robotic bees is now a common sound over the rooftops of Futura, giving rise to lush green spaces amidst the concrete jungle."""
18
+
19
+ sample = [[i],[j],[k]]
20
+
21
+ io = gr.Interface.load("huggingface/facebook/bart-large-cnn")
22
+ iface = Parallel(io,
23
+ theme='huggingface',
24
+ title= 'BART Summarizer',
25
+ description = intro,
26
+ examples=sample,
27
+ inputs = gr.inputs.Textbox(lines = 10, label="Text"))
28
+
29
+ iface.launch(inline = False, enable_queue = True, show_api = False)
30
+