File size: 873 Bytes
4974498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d23bde
 
 
4974498
 
 
 
 
 
 
 
3d23bde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gpt_2_simple as gpt2
import tensorflow as tf
import gradio as gr

model_name = "124M"

path = 'AbstractGenerator/'
checkpoint_dir =path+'weights/'
data_path = path+'Tokenized_data/'


prefix= '<|startoftext|>'
sufix ='<|endoftext|>'



def generateAbstract(text):
   # with tf.compat.v1.variable_scope("weight", reuse = True):
    #sess = tf.compat.v1.get_variable('sess',gpt2.start_tf_sess())
    tf.compat.v1.reset_default_graph()
    sess = gpt2.start_tf_sess()
    gpt2.load_gpt2(sess,checkpoint_dir=checkpoint_dir,run_name='run1')
    txt = gpt2.generate(sess,prefix=str(text)+"\nABSTRACT", return_as_list=True,truncate=sufix,checkpoint_dir=checkpoint_dir,nsamples=1)[0]
    return str(txt[txt.find('ABSTRACT'):])



iface = gr.Interface(fn=generateAbstract, inputs=gr.inputs.Textbox(lines=10, placeholder="text"), outputs="textbox")
iface.launch(debug = True )