vkolasani commited on
Commit
20b752d
·
verified ·
1 Parent(s): 481f8f5

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +20 -0
main.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Defining the pipeline and the model
5
+ pipe_flan = pipeline("text-generation", model="gpt2")
6
+
7
+ # Text generation
8
+ def generator(input):
9
+ output = pipe_flan(input, max_length=50, num_return_sequences=1)
10
+ return output[0]["generated_text"]
11
+
12
+ # Creating the Gradio Interface
13
+ demo = gr.Interface(
14
+ fn=generator,
15
+ inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
16
+ outputs=gr.outputs.Textbox(label="Generated Text")
17
+ )
18
+
19
+ # Lauching the Gradio Interface
20
+ demo.launch(server_name="0.0.0.0", server_port=7860)