spuun commited on
Commit
a19ef58
·
1 Parent(s): 0733346

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -1,33 +1,33 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- model_id = "knkarthick/TOPIC-DIALOGSUM"
4
 
5
  generator = pipeline(task="text2text-generation", model=model_id)
6
 
7
- def split_paragraph(paragraph, max_chunk_size=1024):
8
- words = paragraph.split()
9
- chunks = []
10
- current_chunk = []
11
- current_chunk_size = 0
12
 
13
- for word in words:
14
- word_len = len(word) + 1 # Add 1 for the space
15
- if current_chunk_size + word_len <= max_chunk_size:
16
- current_chunk.append(word)
17
- current_chunk_size += word_len
18
- else:
19
- chunks.append(' '.join(current_chunk))
20
- current_chunk = [word]
21
- current_chunk_size = word_len
22
 
23
- if current_chunk:
24
- chunks.append(' '.join(current_chunk))
25
 
26
- return chunks
27
 
28
  def launch(input):
29
- if len(input) > 1024:
30
- return " ".join([res["generated_text"] for res in generator(split_paragraph(input))])
31
  return generator(input)[0]["generated_text"]
32
 
33
  iface = gr.Interface(launch, inputs="text", outputs="text")
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ model_id = "knkarthick/MEETING_SUMMARY"
4
 
5
  generator = pipeline(task="text2text-generation", model=model_id)
6
 
7
+ #def split_paragraph(paragraph, max_chunk_size=1024):
8
+ # words = paragraph.split()
9
+ # chunks = []
10
+ # current_chunk = []
11
+ # current_chunk_size = 0
12
 
13
+ # for word in words:
14
+ # word_len = len(word) + 1 # Add 1 for the space
15
+ # if current_chunk_size + word_len <= max_chunk_size:
16
+ # current_chunk.append(word)
17
+ # current_chunk_size += word_len
18
+ # else:
19
+ # chunks.append(' '.join(current_chunk))
20
+ # current_chunk = [word]
21
+ # current_chunk_size = word_len
22
 
23
+ # if current_chunk:
24
+ # chunks.append(' '.join(current_chunk))
25
 
26
+ # return chunks
27
 
28
  def launch(input):
29
+ # if len(input) > 1024:
30
+ # return " ".join([res["generated_text"] for res in generator(split_paragraph(input))])
31
  return generator(input)[0]["generated_text"]
32
 
33
  iface = gr.Interface(launch, inputs="text", outputs="text")