File size: 2,071 Bytes
1ecf838
 
 
5eabf2c
70d6376
 
1ecf838
70d6376
 
1ecf838
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import streamlit as st
import pandas as pd
import numpy as np
#from transformers import pipeline, AutoModelWithLMHead, AutoTokenizer
#import torch 
#import boto3

#s3 = boto3.resource('s3')
#s3_object = s3.Bucket('nlp-gpt-models').Object('mod_v1.pth').get()



st.title('Patent Context Generation Tool-Development Stage..')
model_path = s3_object
#model_path = 'https://nlp-gpt-models.s3.amazonaws.com/mod_v1.pth'
#model_path = 'https://drive.google.com/file/d/1-Dqk6fZzDiFKTqnnQ2yqW48uJk-CPqrB/view?usp=sharing'
propmt_title = st.text_input('Enter Your Title....', 'Biology...')

f1 = st.button('Generate')
if f1: 
    try:
        saved_model = torch.load(model_path)
        tokenizer = AutoTokenizer.from_pretrained("gpt2")
        generator = pipeline('text-generation', model = saved_model , tokenizer = tokenizer)
        def paraphrase(propmt_title):
            p = generator('<s>' + propmt_title + '</s>>>>><p>')
            return p[0]['generated_text'].split('</s>>>>>><p>')[0].split('</p>')[0].split('<p>')[1]    
        output= paraphrase(propmt_title) 
        st.text_area('paraphrased_titless', output ,False)
    except Exception as e:
        st.exception("Exception: %s\n" % e)    
        st.text_area('paraphrased_titless', st.exception("Exception: %s\n" % e) ,False)
           
propmt_title = st.text_input('Enter Your Paraphrased Title....', 'title context...')
f2 = st.form("my_form2")
f2.form_submit_button("Submit")

st.text_area('Generated Fields', '',False)


propmt_title = st.text_input('Enter Your Generated Field ....', 'Field context...')
f3 = st.form("my_form3")
f3.form_submit_button("Submit")

st.text_area('Generated Abstract', '',False)


propmt_title = st.text_input('Enter Your Generated Abstract ....', 'Abstract context...')
f4 = st.form("my_form4")
f4.form_submit_button("Submit")

st.text_area('Generated Background', '',False)



st.download_button(label="Download Full Patent (PDF file)",
                    data=propmt_title,
                    file_name="test.pdf",
                    mime='application/octet-stream')