Spaces:
Sleeping
Sleeping
| #uploud neccessary libaries | |
| import gradio as gr | |
| from transformers import pipeline # to load a pre-trained model. | |
| # Load the text generation pipeline | |
| text_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B") | |
| # function that takes in a prompt and returns generated text | |
| def generate_text(prompt,temperature): | |
| result = text_generator(prompt, | |
| max_length=100, | |
| num_return_sequences=1, | |
| temperature=temperature, | |
| top_k=5, | |
| top_p=0.9 | |
| ) | |
| return result[0]['generated_text'] | |
| # Set up the Gradio interface | |
| iface = gr.Interface( | |
| fn=generate_text, # Function to process input | |
| inputs=[ | |
| gr.Textbox(label="Provide a query or idea that will serve as the basis for generating text"), | |
| gr.Slider(minimum=0.1,maximum=1.0,step=0.1,value=0.7,label="Temperature:Lower = More Focused, Higher = More Creative") | |
| ], # Input: Textbox for user to enter prompt | |
| outputs=gr.Textbox(label="Generated Text (Based on Your Input and Temperature Setting)"), # Output: Generated text | |
| title="Creative Text Generation", | |
| description="Adjust the parameters to achieve your desired text output", | |
| ) | |
| # Launch the interface | |
| iface.launch() |