Spaces:
Sleeping
Sleeping
File size: 760 Bytes
964d3aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from transformers import pipeline
# Load your Hugging Face model
model = pipeline('text-generation', model='gpt2') # Replace 'gpt2' with your model
def predict(input_text):
# Generate output using the model
output = model(input_text, max_length=50) # Adjust parameters as needed
return output[0]['generated_text']
# Create the Gradio interface
interface = gr.Interface(fn=predict,
inputs=gr.inputs.Textbox(lines=2, placeholder="Type something here..."),
outputs='text',
title="Hugging Face Model Inference",
description="Type in some text and see how the model responds!")
if __name__ == "__main__":
interface.launch() |