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