wldmr johnnyfivefingers commited on
Commit
abd582a
0 Parent(s):

Duplicate from johnnyfivefingers/summarymachine

Browse files

Co-authored-by: JH <johnnyfivefingers@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +27 -0
  2. README.md +13 -0
  3. app.py +31 -0
  4. input.csv +0 -0
  5. requirements.txt +3 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Summarymachine
3
+ emoji: 🌖
4
+ colorFrom: pink
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 3.0.2
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: johnnyfivefingers/summarymachine
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import pipeline
4
+ import csv
5
+
6
+ model_id = "philschmid/bart-large-cnn-samsum"
7
+
8
+ summarizer = pipeline("summarization", model=model_id)
9
+
10
+ def summarize(text):
11
+ text = str(text)
12
+ if text == "showdata":
13
+ lines = "(lines)"
14
+ with open('input.csv',"r") as f:
15
+ lines = f.readlines()
16
+ return str(lines)
17
+
18
+
19
+ generated_summary_short = summarizer(text, max_length=40, min_length=10)[0]['summary_text']
20
+ generated_summary = summarizer(text, max_length=80, min_length=20)[0]['summary_text']
21
+ generated_summary_long = summarizer(text, max_length=200, min_length=40)[0]['summary_text']
22
+
23
+ fields = [str(text), str(generated_summary)]
24
+ with open('input.csv','a', newline='') as f:
25
+ writer = csv.writer(f)
26
+ writer.writerow(fields)
27
+
28
+ return "Summary: " + str(generated_summary) + "\n\n" + "shorter: " + str(generated_summary_short)+ "\n\n" + "Longer: " + str(generated_summary_long)
29
+
30
+ iface = gr.Interface(fn=summarize, inputs="text", outputs="text")
31
+ iface.launch()
input.csv ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ tensorflow
3
+ torch