Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
import torch | |
import numpy as np | |
generator = pipeline('text-generation', model='sshleifer/tiny-gpt2') | |
def generate_text(prompt): | |
try: | |
result = generator(prompt, max_length=50, num_return_sequences=1) | |
return result[0]['generated_text'] | |
except Exception as e: | |
return f"Error: {str(e)}" | |
if __name__ == "__main__": | |
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="AI Code Generator") | |
interface.launch(share=True) # This line makes it public |