Create handler.py
Browse files- handler.py +11 -0
handler.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load your model
|
| 5 |
+
pipe = pipeline("text-generation", model="./")
|
| 6 |
+
|
| 7 |
+
def generate_text(prompt):
|
| 8 |
+
return pipe(prompt, max_length=100)[0]['generated_text']
|
| 9 |
+
|
| 10 |
+
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
| 11 |
+
iface.launch()
|