Upload folder using huggingface_hub
Browse files- .ipynb_checkpoints/Untitled-checkpoint.ipynb +140 -0
- .ipynb_checkpoints/app-checkpoint.py +14 -0
- README.md +2 -8
- Untitled.ipynb +135 -0
- app.py +14 -0
- flagged/log.csv +3 -0
.ipynb_checkpoints/Untitled-checkpoint.ipynb
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "dfabe234-2b6b-4164-a1be-1a48598d0ec3",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from transformers import pipeline"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 4,
|
16 |
+
"id": "6477dded-2991-4c8e-8eab-5f74f2ed9315",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"text/plain": [
|
22 |
+
"[{'summary_text': ' Apple trees are cultivated worldwide and are the most widely grown species in the genus Malus . The tree originated in Central Asia, where its'}]"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
"execution_count": 4,
|
26 |
+
"metadata": {},
|
27 |
+
"output_type": "execute_result"
|
28 |
+
}
|
29 |
+
],
|
30 |
+
"source": [
|
31 |
+
"summarization=pipeline(task=\"summarization\", model=\"sshleifer/distilbart-cnn-12-6\")\n",
|
32 |
+
"text=\"An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica). Apple trees are cultivated worldwide and are the most widely grown species in the genus Malus. The tree originated in Central Asia, where its wild ancestor, Malus sieversii, is still found. Apples have been grown for thousands of years in Eurasia and were introduced to North America by European colonists. Apples have religious and mythological significance in many cultures, including Norse, Greek, and European Christian tradition.\"\n",
|
33 |
+
"summarization(text,min_length=5, max_length=30)"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
{
|
37 |
+
"cell_type": "code",
|
38 |
+
"execution_count": 14,
|
39 |
+
"id": "535a7d70-c469-4472-af1a-e0eab7221285",
|
40 |
+
"metadata": {
|
41 |
+
"scrolled": true
|
42 |
+
},
|
43 |
+
"outputs": [
|
44 |
+
{
|
45 |
+
"name": "stdout",
|
46 |
+
"output_type": "stream",
|
47 |
+
"text": [
|
48 |
+
"Running on local URL: http://127.0.0.1:7866\n",
|
49 |
+
"\n",
|
50 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
51 |
+
]
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"data": {
|
55 |
+
"text/html": [
|
56 |
+
"<div><iframe src=\"http://127.0.0.1:7866/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
57 |
+
],
|
58 |
+
"text/plain": [
|
59 |
+
"<IPython.core.display.HTML object>"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
"metadata": {},
|
63 |
+
"output_type": "display_data"
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"data": {
|
67 |
+
"text/plain": []
|
68 |
+
},
|
69 |
+
"execution_count": 14,
|
70 |
+
"metadata": {},
|
71 |
+
"output_type": "execute_result"
|
72 |
+
},
|
73 |
+
{
|
74 |
+
"name": "stderr",
|
75 |
+
"output_type": "stream",
|
76 |
+
"text": [
|
77 |
+
"Traceback (most recent call last):\n",
|
78 |
+
" File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio/queueing.py\", line 532, in process_events\n",
|
79 |
+
" response = await route_utils.call_process_api(\n",
|
80 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
81 |
+
" File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio/route_utils.py\", line 276, in call_process_api\n",
|
82 |
+
" output = await app.get_blocks().process_api(\n",
|
83 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
84 |
+
" File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio/blocks.py\", line 1924, in process_api\n",
|
85 |
+
" inputs = await self.preprocess_data(\n",
|
86 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
87 |
+
" File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio/blocks.py\", line 1656, in preprocess_data\n",
|
88 |
+
" processed_input.append(block.preprocess(inputs_cached))\n",
|
89 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
90 |
+
" File \"/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio/components/number.py\", line 119, in preprocess\n",
|
91 |
+
" raise Error(f\"Value {payload} is less than minimum value {self.minimum}.\")\n",
|
92 |
+
"gradio.exceptions.Error: 'Value 1 is less than minimum value 10.'\n"
|
93 |
+
]
|
94 |
+
}
|
95 |
+
],
|
96 |
+
"source": [
|
97 |
+
"import gradio as gr\n",
|
98 |
+
"def summarize(text:str, max_length:int):\n",
|
99 |
+
" if max_length<10:\n",
|
100 |
+
" raise gr.Error()\n",
|
101 |
+
" summary=summarization(text,min_length=10,max_length=max_length)\n",
|
102 |
+
" return summary[0]['summary_text']\n",
|
103 |
+
"\n",
|
104 |
+
"demo = gr.Interface(fn=summarize, inputs=[gr.TextArea(label=\"Text\",placeholder=\"Enter any long text to be summarized\"),\n",
|
105 |
+
" gr.Number(label=\"Words\",info=\"Enter the max word of the summary\",minimum=10)], \n",
|
106 |
+
" outputs=gr.TextArea(label=\"Summary\"), title=\"Summarization App using AI\", description=\"This app uses AI to summarize long text into your given number of words.\")\n",
|
107 |
+
"demo.launch()"
|
108 |
+
]
|
109 |
+
},
|
110 |
+
{
|
111 |
+
"cell_type": "code",
|
112 |
+
"execution_count": null,
|
113 |
+
"id": "e2523f88-bdf0-49b3-a66c-910f2394ebde",
|
114 |
+
"metadata": {},
|
115 |
+
"outputs": [],
|
116 |
+
"source": []
|
117 |
+
}
|
118 |
+
],
|
119 |
+
"metadata": {
|
120 |
+
"kernelspec": {
|
121 |
+
"display_name": "Python 3 (ipykernel)",
|
122 |
+
"language": "python",
|
123 |
+
"name": "python3"
|
124 |
+
},
|
125 |
+
"language_info": {
|
126 |
+
"codemirror_mode": {
|
127 |
+
"name": "ipython",
|
128 |
+
"version": 3
|
129 |
+
},
|
130 |
+
"file_extension": ".py",
|
131 |
+
"mimetype": "text/x-python",
|
132 |
+
"name": "python",
|
133 |
+
"nbconvert_exporter": "python",
|
134 |
+
"pygments_lexer": "ipython3",
|
135 |
+
"version": "3.11.4"
|
136 |
+
}
|
137 |
+
},
|
138 |
+
"nbformat": 4,
|
139 |
+
"nbformat_minor": 5
|
140 |
+
}
|
.ipynb_checkpoints/app-checkpoint.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
def summarize(text:str, max_length:int):
|
4 |
+
if max_length<10:
|
5 |
+
raise gr.Error()
|
6 |
+
if text=="":
|
7 |
+
raise gr.Error("Text field is empty. Please enter some text")
|
8 |
+
summary=summarization(text,min_length=10,max_length=max_length)
|
9 |
+
return summary[0]['summary_text']
|
10 |
+
|
11 |
+
demo = gr.Interface(fn=summarize, inputs=[gr.TextArea(label="Text",placeholder="Enter any long text to be summarized"),
|
12 |
+
gr.Number(label="Words",info="Enter the max word of the summary. Min 10",minimum=10)],
|
13 |
+
outputs=gr.TextArea(label="Summary"), title="Summarization App using AI", description="This app uses AI to summarize long text into your given number of words.")
|
14 |
+
demo.launch(share=True)
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.36.1
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: summarization-app
|
3 |
+
app_file: app.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 4.36.1
|
|
|
|
|
6 |
---
|
|
|
|
Untitled.ipynb
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "dfabe234-2b6b-4164-a1be-1a48598d0ec3",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from transformers import pipeline"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 4,
|
16 |
+
"id": "6477dded-2991-4c8e-8eab-5f74f2ed9315",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"text/plain": [
|
22 |
+
"[{'summary_text': ' Apple trees are cultivated worldwide and are the most widely grown species in the genus Malus . The tree originated in Central Asia, where its'}]"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
"execution_count": 4,
|
26 |
+
"metadata": {},
|
27 |
+
"output_type": "execute_result"
|
28 |
+
}
|
29 |
+
],
|
30 |
+
"source": [
|
31 |
+
"summarization=pipeline(task=\"summarization\", model=\"sshleifer/distilbart-cnn-12-6\")\n",
|
32 |
+
"text=\"An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica). Apple trees are cultivated worldwide and are the most widely grown species in the genus Malus. The tree originated in Central Asia, where its wild ancestor, Malus sieversii, is still found. Apples have been grown for thousands of years in Eurasia and were introduced to North America by European colonists. Apples have religious and mythological significance in many cultures, including Norse, Greek, and European Christian tradition.\"\n",
|
33 |
+
"summarization(text,min_length=5, max_length=30)"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
{
|
37 |
+
"cell_type": "code",
|
38 |
+
"execution_count": 20,
|
39 |
+
"id": "535a7d70-c469-4472-af1a-e0eab7221285",
|
40 |
+
"metadata": {},
|
41 |
+
"outputs": [
|
42 |
+
{
|
43 |
+
"name": "stdout",
|
44 |
+
"output_type": "stream",
|
45 |
+
"text": [
|
46 |
+
"Running on local URL: http://127.0.0.1:7871\n"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"name": "stderr",
|
51 |
+
"output_type": "stream",
|
52 |
+
"text": [
|
53 |
+
"huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
|
54 |
+
"To disable this warning, you can either:\n",
|
55 |
+
"\t- Avoid using `tokenizers` before the fork if possible\n",
|
56 |
+
"\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
|
57 |
+
]
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"name": "stdout",
|
61 |
+
"output_type": "stream",
|
62 |
+
"text": [
|
63 |
+
"Running on public URL: https://58f21d56efaf52342f.gradio.live\n",
|
64 |
+
"\n",
|
65 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
66 |
+
]
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"data": {
|
70 |
+
"text/html": [
|
71 |
+
"<div><iframe src=\"https://58f21d56efaf52342f.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
72 |
+
],
|
73 |
+
"text/plain": [
|
74 |
+
"<IPython.core.display.HTML object>"
|
75 |
+
]
|
76 |
+
},
|
77 |
+
"metadata": {},
|
78 |
+
"output_type": "display_data"
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"data": {
|
82 |
+
"text/plain": []
|
83 |
+
},
|
84 |
+
"execution_count": 20,
|
85 |
+
"metadata": {},
|
86 |
+
"output_type": "execute_result"
|
87 |
+
}
|
88 |
+
],
|
89 |
+
"source": [
|
90 |
+
"import gradio as gr\n",
|
91 |
+
"def summarize(text:str, max_length:int):\n",
|
92 |
+
" if max_length<10:\n",
|
93 |
+
" raise gr.Error()\n",
|
94 |
+
" if text==\"\":\n",
|
95 |
+
" raise gr.Error(\"Text field is empty. Please enter some text\")\n",
|
96 |
+
" summary=summarization(text,min_length=10,max_length=max_length)\n",
|
97 |
+
" return summary[0]['summary_text']\n",
|
98 |
+
"\n",
|
99 |
+
"demo = gr.Interface(fn=summarize, inputs=[gr.TextArea(label=\"Text\",placeholder=\"Enter any long text to be summarized\"),\n",
|
100 |
+
" gr.Number(label=\"Words\",info=\"Enter the max word of the summary. Min 10\",minimum=10)], \n",
|
101 |
+
" outputs=gr.TextArea(label=\"Summary\"), title=\"Summarization App using AI\", description=\"This app uses AI to summarize long text into your given number of words.\")\n",
|
102 |
+
"demo.launch(share=True)"
|
103 |
+
]
|
104 |
+
},
|
105 |
+
{
|
106 |
+
"cell_type": "code",
|
107 |
+
"execution_count": null,
|
108 |
+
"id": "e2523f88-bdf0-49b3-a66c-910f2394ebde",
|
109 |
+
"metadata": {},
|
110 |
+
"outputs": [],
|
111 |
+
"source": []
|
112 |
+
}
|
113 |
+
],
|
114 |
+
"metadata": {
|
115 |
+
"kernelspec": {
|
116 |
+
"display_name": "Python 3 (ipykernel)",
|
117 |
+
"language": "python",
|
118 |
+
"name": "python3"
|
119 |
+
},
|
120 |
+
"language_info": {
|
121 |
+
"codemirror_mode": {
|
122 |
+
"name": "ipython",
|
123 |
+
"version": 3
|
124 |
+
},
|
125 |
+
"file_extension": ".py",
|
126 |
+
"mimetype": "text/x-python",
|
127 |
+
"name": "python",
|
128 |
+
"nbconvert_exporter": "python",
|
129 |
+
"pygments_lexer": "ipython3",
|
130 |
+
"version": "3.11.4"
|
131 |
+
}
|
132 |
+
},
|
133 |
+
"nbformat": 4,
|
134 |
+
"nbformat_minor": 5
|
135 |
+
}
|
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
def summarize(text:str, max_length:int):
|
4 |
+
if max_length<10:
|
5 |
+
raise gr.Error()
|
6 |
+
if text=="":
|
7 |
+
raise gr.Error("Text field is empty. Please enter some text")
|
8 |
+
summary=summarization(text,min_length=10,max_length=max_length)
|
9 |
+
return summary[0]['summary_text']
|
10 |
+
|
11 |
+
demo = gr.Interface(fn=summarize, inputs=[gr.TextArea(label="Text",placeholder="Enter any long text to be summarized"),
|
12 |
+
gr.Number(label="Words",info="Enter the max word of the summary. Min 10",minimum=10)],
|
13 |
+
outputs=gr.TextArea(label="Summary"), title="Summarization App using AI", description="This app uses AI to summarize long text into your given number of words.")
|
14 |
+
demo.launch(share=True)
|
flagged/log.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
Text,Words,Summary,flag,username,timestamp
|
2 |
+
Hi,0,,,,2024-06-22 18:39:17.598058
|
3 |
+
Hi,0,,,,2024-06-22 18:42:11.064495
|