|
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) |