dmahata commited on
Commit
fca122e
·
1 Parent(s): fd40c9d

Upload huggingface_app.py

Browse files
Files changed (1) hide show
  1. huggingface_app.py +66 -0
huggingface_app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from run_eval import run_generate
4
+
5
+ st.write("# GupShup")
6
+ st.write("## Summarizing Open-Domain Code-Switched Conversations")
7
+ task_type = st.sidebar.selectbox(
8
+ "Task type", ["Hinglish to English", "English to English"]
9
+ )
10
+ model_name = st.sidebar.selectbox(
11
+ "Model", ["Pegasus", "mBart", "Bart", "GPT", "T5", "T5_MTL"]
12
+ )
13
+
14
+
15
+ default_value = "summarize: Debanjan: Hi! kya tum EMNLP attend kar rahein ho? Anish: nehi I will skip this year. what about you? Debanjan: mein virtually attend kar raha hu Debanjan: hopefully can attend the conference in person from next year... Anish: haan dekhtey hain, in person attend karney mein alaag hi maaza hain Debanjan: but I also like this hybrid mode allows to attend the sessions in case you do not make it Anish: right Anish: if you are attending to mujhe interesting papers kuch bhej dena Debanjan: sure"
16
+
17
+ conv_form = st.sidebar.form(key="conv_form")
18
+ conv_ip = conv_form.text_input(label="Please enter the conversastion", value=default_value)
19
+ conv_submit_button = conv_form.form_submit_button(label="Submit")
20
+
21
+ # sent = st.text_area("Text", default_value, height=275)
22
+
23
+ st.write("### Task Type:", task_type)
24
+ st.write("### Model:", model_name)
25
+ x = "fg"
26
+
27
+ src_file = None
28
+ tar_file = None
29
+ gen_file = "generated_summary.txt"
30
+ score_file = None
31
+
32
+ if conv_submit_button:
33
+ if conv_ip == "":
34
+ st.write("Pls enter non empty conversastion")
35
+ else:
36
+ st.write("### Summarizing below Conversastion")
37
+ st.write(conv_ip)
38
+ src_file = "conversastion.txt"
39
+ src_fp = open(src_file, "w")
40
+ src_fp.write(conv_ip)
41
+ src_fp.close()
42
+
43
+ tt = "h2e"
44
+ if task_type == "English to English":
45
+ tt = "e2e"
46
+ elif task_type == "Hinglish to English":
47
+ tt = "h2e"
48
+ model_name_path = "midas/gupshup_" + str(tt) + "_" + str(model_name).lower()
49
+
50
+
51
+ result = run_generate(
52
+ verbose=True,
53
+ model_name_path=model_name_path,
54
+ src_txt=src_file,
55
+ tar_txt=tar_file,
56
+ gen_path=gen_file,
57
+ scor_path=score_file,
58
+ batch_size=8,
59
+ )
60
+
61
+ if conv_submit_button:
62
+ st.write("summary:")
63
+ fp = open(gen_file, "r")
64
+ summary = fp.readlines()
65
+ fp.close()
66
+ st.write(summary)