Update main.py
Browse files
main.py
CHANGED
@@ -8,12 +8,12 @@ import gradio as gr
|
|
8 |
|
9 |
#app = FastAPI()
|
10 |
|
11 |
-
|
12 |
|
13 |
#@app.get("/infer_gpt2")
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
# return {"output": output[0]["generated_text"]}
|
18 |
|
19 |
#app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
@@ -22,4 +22,11 @@ import gradio as gr
|
|
22 |
#def index() -> FileResponse:
|
23 |
# return FileResponse(path="/app/static/index.html", media_type="text/html")
|
24 |
|
25 |
-
gr.Interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
#app = FastAPI()
|
10 |
|
11 |
+
pipe_flan = pipeline("text-generation", model="gpt2")
|
12 |
|
13 |
#@app.get("/infer_gpt2")
|
14 |
+
def gpt2(input):
|
15 |
+
output = pipe_flan(input, max_length=130, num_return_sequences=1)
|
16 |
+
return {"output": output[0]["generated_text"]}
|
17 |
# return {"output": output[0]["generated_text"]}
|
18 |
|
19 |
#app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
22 |
#def index() -> FileResponse:
|
23 |
# return FileResponse(path="/app/static/index.html", media_type="text/html")
|
24 |
|
25 |
+
demo = gr.Interface(
|
26 |
+
fn=gpt2,
|
27 |
+
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
|
28 |
+
outputs=gr.outputs.Textbox(label="Generated Text")
|
29 |
+
)
|
30 |
+
|
31 |
+
|
32 |
+
demo.launch()
|