malper commited on
Commit
14388f0
1 Parent(s): 3d3f4ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -15,22 +15,18 @@ def normalize(text):
15
 
16
  with st.spinner('Loading TaatikNet framework...'):
17
  pipe = pipeline("text2text-generation", model='malper/taatiknet', device_map="auto")
18
-
19
  st.success('Loaded!')
20
 
21
  text = st.text_area('Enter text and press ctrl/command+enter:')
22
-
23
  if text:
24
-
25
  words = [normalize(x) for x in text.split() if contains_text(x)]
26
- outputs = pipe(words, max_length=200, num_beams=5, num_return_sequences=5)
27
-
28
- texts = [
29
- ' '.join(x['generated_text'] for x in option)
30
- for option in zip(*outputs)
31
- ]
32
-
33
- st.write(texts[0])
34
- st.write('Other options:')
35
- for option in texts[1:]:
36
- st.write(option)
 
15
 
16
  with st.spinner('Loading TaatikNet framework...'):
17
  pipe = pipeline("text2text-generation", model='malper/taatiknet', device_map="auto")
 
18
  st.success('Loaded!')
19
 
20
  text = st.text_area('Enter text and press ctrl/command+enter:')
 
21
  if text:
 
22
  words = [normalize(x) for x in text.split() if contains_text(x)]
23
+ if len(words) > 0:
24
+ outputs = pipe(words, max_length=200, num_beams=5, num_return_sequences=5)
25
+ texts = [
26
+ ' '.join(x['generated_text'] for x in option)
27
+ for option in zip(*outputs)
28
+ ]
29
+ st.write(texts[0])
30
+ st.write('Other options:')
31
+ for option in texts[1:]:
32
+ st.write(option)