File size: 816 Bytes
abe5e7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
import os
os.system('pip install gpt-2-simple')
os.system('pip install tensorflow-estimator==1.15.1')

import gpt_2_simple as gpt2
import tensorflow as tf
import pandas as pd
import re
import gradio as gr

model_name = "124M"

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


file_name = 'resumen'
file_path = data_path+file_name

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

print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")

sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess,checkpoint_dir=checkpoint_dir,run_name='run1')





def greet(text):
    return gpt2.generate(sess,prefix=text,truncate=sufix,checkpoint_dir=checkpoint_dir,nsamples=1)




iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch(share=True)