jknebel commited on
Commit
1dbc1fe
1 Parent(s): f980909

add new features

Browse files
Files changed (3) hide show
  1. .github/workflows/main.yml +1 -1
  2. app.py +27 -5
  3. flagged/log.csv +4 -0
.github/workflows/main.yml CHANGED
@@ -1,6 +1,6 @@
1
  name: Sync to Hugging Face hub
2
  on:
3
- pull_request:
4
  branches: [main]
5
 
6
  # to run this workflow manually from the Actions tab
 
1
  name: Sync to Hugging Face hub
2
  on:
3
+ push:
4
  branches: [main]
5
 
6
  # to run this workflow manually from the Actions tab
app.py CHANGED
@@ -1,14 +1,36 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- model = pipeline("summarization")
5
-
6
- def predict(prompt):
7
- summary = model(prompt)[0]["summary_text"]
 
 
 
 
 
 
 
 
 
 
 
8
  return summary
9
 
 
 
 
 
 
 
 
 
 
10
  with gr.Blocks() as demo:
 
11
  textbox = gr.Textbox(placeholder = "Enter text block to summarize", lines = 4)
12
- gr.Interface(fn=predict, inputs=textbox, outputs="text")
 
13
 
14
  demo.launch()
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ model_name_converter = {"bart_large":"juliosocher/bart-large-cnn-finetuned-scientific-articles",
5
+ "mt5-small-finetuned-mt5":"jacks392/mt5-small-finetuned-mt5",
6
+ "facebook": "facebook/bart-large-cnn",
7
+ "google" : "google/pegasus-xsum"
8
+ }
9
+ def predict(prompt,model_name, max_length):
10
+ if model_name ==None:
11
+ model_name = "google/pegasus-xsum"
12
+ else:
13
+ model_name = model_name_converter[model_name]
14
+ print('la')
15
+ print(model_name)
16
+ print(max_length)
17
+ model = pipeline("summarization",model = model_name)
18
+ summary = model(prompt,max_length)[0]["summary_text"]
19
  return summary
20
 
21
+ def extract_model(option):
22
+ if option ==None:
23
+ model_name = "google/pegasus-xsum"
24
+ else:
25
+ model_name = model_name_converter[option]
26
+
27
+ return print(model_name)
28
+
29
+ options_1 = model_name_converter.keys()
30
  with gr.Blocks() as demo:
31
+ drop_down = gr.Dropdown(choices=options_1, label="model")
32
  textbox = gr.Textbox(placeholder = "Enter text block to summarize", lines = 4)
33
+ length=gr.Number(value = 200, label="the max number of characher for summerized")
34
+ gr.Interface(fn=predict, inputs=[textbox, drop_down, length], outputs = "text")
35
 
36
  demo.launch()
flagged/log.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ prompt,output,flag,username,timestamp
2
+ ,a fff f s . fs ft fd fn fl .,,,2024-06-08 11:22:28.177838
3
+ ,a fff f s . fs ft fd fn fl .,,,2024-06-08 11:22:30.198869
4
+ ,bart_large,200,,,,2024-06-08 11:50:37.097705