Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
subprocess.run(["pip", "install", "./textgen.zip"])
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
from textgen import TextGenerator
|
6 |
+
|
7 |
+
textgen = TextGenerator()
|
8 |
+
textgen.train("""Hello, world! This is a test.""")
|
9 |
+
|
10 |
+
def generate(text, length=100):
|
11 |
+
return textgen.generate(text, length=length)
|
12 |
+
|
13 |
+
def main():
|
14 |
+
with gr.Blocks(title="🦊 textgen") as demo:
|
15 |
+
gr.Markdown("# 🦊 textgen")
|
16 |
+
with gr.Group():
|
17 |
+
text = gr.Textbox(label="Text", lines=8)
|
18 |
+
length = gr.Number(label="Length")
|
19 |
+
with gr.Row():
|
20 |
+
btn = gr.Button("Generate", variant="primary")
|
21 |
+
clear = gr.ClearButton([text])
|
22 |
+
btn.click(generate, [text, length], [text])
|
23 |
+
demo.queue().launch(debug=True)
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
# Launch interface
|
27 |
+
main()
|