yirmibesogluz commited on
Commit
a4a0e50
·
1 Parent(s): 117e979

Fixed set page config location

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. apps/summarization.py +9 -6
app.py CHANGED
@@ -4,14 +4,14 @@ from transformers import pipeline
4
 
5
  import apps.summarization
6
 
7
- API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/TURNA"
8
-
9
  st.set_page_config(
10
  page_title="Turna",
11
  page_icon="📖",
12
  layout='wide'
13
  )
14
 
 
 
15
  PAGES = {
16
  "Text Summarization": apps.summarization
17
  }
 
4
 
5
  import apps.summarization
6
 
 
 
7
  st.set_page_config(
8
  page_title="Turna",
9
  page_icon="📖",
10
  layout='wide'
11
  )
12
 
13
+ API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/TURNA"
14
+
15
  PAGES = {
16
  "Text Summarization": apps.summarization
17
  }
apps/summarization.py CHANGED
@@ -4,11 +4,13 @@ import time
4
  from transformers import pipeline
5
  import os
6
 
 
 
 
 
 
 
7
  def write():
8
- st.set_page_config(page_title="Text Summarization", page_icon="📈")
9
- API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/turna_summarization_mlsum"
10
- HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN')
11
- headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"}
12
 
13
  st.markdown("# Text Summarization")
14
  st.sidebar.header("Text Summarization")
@@ -17,7 +19,7 @@ def write():
17
  )
18
 
19
  input_text = st.text_area(label='Enter a text: ', height=200,
20
- value="Kalp krizi geçirenlerin yaklaşık üçte birinin kısa bir süre önce grip atlattığı düşünülüyor. Peki grip virüsü ne yapıyor da kalp krizine yol açıyor? Karpuz şöyle açıkladı: Grip virüsü kanın yapışkanlığını veya pıhtılaşmasını artırıyor. Pıhtılaşma ise vücudun bağışıklık tepkisinden kaynaklanan iltihaplanmayla birlikte damarlardaki yağlı plakları zayıflatabilir. Plağın yırtılmasıyla da kan pıhtısı oluşarak kalp krizine neden olabiliyor.")
21
  if st.button("Generate"):
22
  with st.spinner('Generating...'):
23
  output = query(input_text)
@@ -25,13 +27,14 @@ def write():
25
 
26
 
27
  def query(payload):
28
- data = {"inputs": payload, "parameters": {"length_penalty": 2.0, "no_repeat_ngram_size": 3}}
29
  while True:
30
  response = requests.post(API_URL, headers=headers, json=data)
31
  if 'error' not in response.json():
32
  output = response.json()[0]["generated_text"]
33
  return output
34
  else:
 
35
  time.sleep(15)
36
  print('Sending request again', flush=True)
37
 
 
4
  from transformers import pipeline
5
  import os
6
 
7
+ st.set_page_config(page_title="Text Summarization", page_icon="📈")
8
+
9
+ API_URL = "https://api-inference.huggingface.co/models/boun-tabi-LMG/turna_summarization_mlsum"
10
+ HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN')
11
+ headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"}
12
+
13
  def write():
 
 
 
 
14
 
15
  st.markdown("# Text Summarization")
16
  st.sidebar.header("Text Summarization")
 
19
  )
20
 
21
  input_text = st.text_area(label='Enter a text: ', height=200,
22
+ value="Kalp krizi geçirenlerin yaklaşık üçte birinin kısa bir süre önce grip atlattığı düşünülüyor. Peki grip virüsü ne yapıyor da kalp krizine yol açıyor? Karpuz şöyle açıkladı: Grip virüsü kanın yapışkanlığını veya pıhtılaşmasını artırıyor.")
23
  if st.button("Generate"):
24
  with st.spinner('Generating...'):
25
  output = query(input_text)
 
27
 
28
 
29
  def query(payload):
30
+ data = {"inputs": payload, "parameters": {"length_penalty": 2.0, "no_repeat_ngram_size": 3, "max_length":128}}
31
  while True:
32
  response = requests.post(API_URL, headers=headers, json=data)
33
  if 'error' not in response.json():
34
  output = response.json()[0]["generated_text"]
35
  return output
36
  else:
37
+ print(response.json())
38
  time.sleep(15)
39
  print('Sending request again', flush=True)
40