franz96521 commited on
Commit
a44f406
·
1 Parent(s): abe5e7f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system('pip install gpt-2-simple')
3
+ os.system('pip install tensorflow-estimator==1.15.1')
4
+
5
+ import gpt_2_simple as gpt2
6
+ import tensorflow as tf
7
+ import pandas as pd
8
+ import re
9
+ import gradio as gr
10
+
11
+ model_name = "124M"
12
+
13
+ path = 'AbstractGenerator/'
14
+ checkpoint_dir =path+'weights/'
15
+ data_path = path+'Tokenized_data/'
16
+
17
+
18
+ file_name = 'resumen'
19
+ file_path = data_path+file_name
20
+
21
+ prefix= '<|startoftext|>'
22
+ sufix ='<|endoftext|>'
23
+
24
+ print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
25
+
26
+ sess = gpt2.start_tf_sess()
27
+ gpt2.load_gpt2(sess,checkpoint_dir=checkpoint_dir,run_name='run1')
28
+
29
+
30
+
31
+
32
+
33
+ def greet(text):
34
+ return gpt2.generate(sess,prefix=text,truncate=sufix,checkpoint_dir=checkpoint_dir,nsamples=1)
35
+
36
+
37
+
38
+
39
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
40
+ iface.launch(share=True)