Spaces:
Runtime error
Runtime error
[ADD] Application, requirements and an updated readmen
Browse files- README.md +3 -0
- app.py +40 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -8,6 +8,9 @@ sdk_version: 4.0.2
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
+
models : [EasyTerms/etsummerizer_v2]
|
12 |
+
datasets : [EasyTerms/Manuel_dataset]
|
13 |
+
tags : [Summerization]
|
14 |
---
|
15 |
|
16 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline,AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
|
4 |
+
def easyterms(text:str)->str:
|
5 |
+
print("In summerizing function of easyterms")
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("EasyTerms/etsummerizer_v2")
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("EasyTerms/etsummerizer_v2")
|
8 |
+
|
9 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
|
10 |
+
summary_ids = model.generate(inputs['input_ids'], attention_mask=inputs['attention_mask'], max_length=128, num_beams=4)
|
11 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
12 |
+
return summary
|
13 |
+
|
14 |
+
def summerize(Option:str, Text:str)-> str:
|
15 |
+
print(Option)
|
16 |
+
if Option == "text":
|
17 |
+
return easyterms(Text)
|
18 |
+
else:
|
19 |
+
return "Input is a URL string"
|
20 |
+
intro = gr.Markdown(
|
21 |
+
'''
|
22 |
+
<center><h1>A Legal document summerizer.</h1></span>
|
23 |
+
|
24 |
+
If you want to better understand legal text or document, this platform is for you. By choosing the url option you submit a url whose content will in turn be summerized for you.
|
25 |
+
Otherwhise you can choose the text option and submit your own text to be summerized.
|
26 |
+
|
27 |
+
'''
|
28 |
+
)
|
29 |
+
|
30 |
+
interface = gr.Interface(
|
31 |
+
fn=summerize,
|
32 |
+
inputs=[gr.Radio(["url", "text"]),"text"],
|
33 |
+
outputs=["text"]
|
34 |
+
)
|
35 |
+
|
36 |
+
interface.launch()
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
requests
|
3 |
+
transformers[torch]
|