Spaces:
Runtime error
Runtime error
File size: 1,002 Bytes
ca94011 f29b441 ca94011 f29b441 d68e3e5 bb41ef4 ca94011 ceafc2c c114350 ca94011 2fb602c ca94011 |
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 |
import streamlit as st
from transformers import AutoTokenizer, AutoModelForCausalLM
import tensorflow as tf
#maximum number of words in output text
# MAX_LEN = 30
title = st.text_input('Enter the seed words', ' ')
input_sequence = title
number = st.number_input('Insert how many words', 1)
MAX_LEN = number
if st.button('Submit'):
tokenizer = AutoTokenizer.from_pretrained("ml6team/gpt-2-medium-conditional-quote-generator")
model = AutoModelForCausalLM.from_pretrained("ml6team/gpt-2-medium-conditional-quote-generator",args={'fp16': False}))
inputs = tokenizer.encode(input_sequence, return_tensors='pt')
# generate text until the output length (which includes the context length) reaches 50
#greedy_output = GPT2.generate(input_ids, max_length = MAX_LEN)
outputs = model(**inputs)
print("Output:\n" + 100 * '-')
print(outputs)
else:
st.write(' ')
# print("Output:\n" + 100 * '-')
# print(tokenizer.decode(sample_output[0], skip_special_tokens = True), '...') |