Hwilner commited on
Commit
64eca7c
·
verified ·
1 Parent(s): ac9bb28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -23
app.py CHANGED
@@ -1,33 +1,23 @@
1
  import torch
2
  import gradio as gr
3
-
4
- # Use a pipeline as a high-level helper
5
  from transformers import pipeline
6
 
7
- # text_summary = pipeline("summarization", model="dicta-il/dictalm2.0", torch_dtype=torch.bfloat16)
8
  text_summary = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum", torch_dtype=torch.bfloat16)
9
 
10
-
11
-
12
-
13
- # text='''Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971) is a businessman and investor.
14
- # He is the founder, chairman, CEO, and CTO of SpaceX; angel investor, CEO, product architect,
15
- # and former chairman of Tesla, Inc.; owner, executive chairman, and CTO of X Corp.;
16
- # founder of the Boring Company and xAI; co-founder of Neuralink and OpenAI; and president
17
- # of the Musk Foundation. He is one of the wealthiest people in the world; as of April 2024,
18
- # Forbes estimates his net worth to be $178 billion.[4]'''
19
- # print(text_summary(text));
20
-
21
- def summary (input):
22
- output = text_summary(input)
23
  return output[0]['summary_text']
24
 
25
  gr.close_all()
26
 
27
- # demo = gr.Interface(fn=summary, inputs="text",outputs="text")
28
- demo = gr.Interface(fn=summary,
29
- inputs=[gr.Textbox(label="Input text to summarize",lines=6)],
30
- outputs=[gr.Textbox(label="Summarized text",lines=4)],
31
- title="Hebrew Text Summarizer",
32
- description="This application will summarize Hebrew text.")
33
- demo.launch()
 
 
 
1
  import torch
2
  import gradio as gr
 
 
3
  from transformers import pipeline
4
 
5
+ # Use the mT5 model for multilingual summarization, including Hebrew
6
  text_summary = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum", torch_dtype=torch.bfloat16)
7
 
8
+ def summary(input):
9
+ # Increase max_length and set max_new_tokens to avoid input length issues
10
+ output = text_summary(input, max_length=512, min_length=30, do_sample=False)
 
 
 
 
 
 
 
 
 
 
11
  return output[0]['summary_text']
12
 
13
  gr.close_all()
14
 
15
+ demo = gr.Interface(
16
+ fn=summary,
17
+ inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
18
+ outputs=[gr.Textbox(label="Summarized text", lines=4)],
19
+ title="Hebrew Text Summarizer",
20
+ description="This application will summarize Hebrew text."
21
+ )
22
+
23
+ demo.launch()