Awakening the AI
commited on
Commit
•
38c936b
1
Parent(s):
2f7322b
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#pip install fastapi
|
2 |
+
#uvicorn main:app --reload
|
3 |
+
#import gradio as gr
|
4 |
+
|
5 |
+
from transformers import pipeline
|
6 |
+
from fastapi import FastAPI
|
7 |
+
|
8 |
+
app = FastAPI()
|
9 |
+
|
10 |
+
generator = pipeline('text-generation',model='gpt2')
|
11 |
+
|
12 |
+
@app.get("/")
|
13 |
+
async def root():
|
14 |
+
return {"message": "Hello World"}
|
15 |
+
#return generator('What is love',max_length=100, num_return_sequences=1)
|
16 |
+
|
17 |
+
@app.post("/predict")
|
18 |
+
async def root(text):
|
19 |
+
#return {"message": "Hello World"}
|
20 |
+
return generator(text,max_length=100, num_return_sequences=1)
|