initial app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the TinyLlama text generation pipeline
|
| 5 |
+
pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0")
|
| 6 |
+
|
| 7 |
+
# Define the inference function
|
| 8 |
+
def generate_text(prompt):
|
| 9 |
+
results = pipe(prompt, max_length=50, num_return_sequences=1)
|
| 10 |
+
return results[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
# Create a Gradio interface
|
| 13 |
+
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="TinyLlama Text Generation")
|
| 14 |
+
|
| 15 |
+
# Launch the interface
|
| 16 |
+
iface.launch()
|