Spaces:
Sleeping
Sleeping
Commit
·
64af2ae
1
Parent(s):
34b369f
added the app.py file
Browse files- app.py +5 -46
- app_fast_api.py +49 -0
app.py
CHANGED
@@ -1,49 +1,8 @@
|
|
1 |
-
import
|
2 |
|
3 |
-
import uvicorn
|
4 |
-
from fastapi import FastAPI
|
5 |
-
from fastapi.responses import Response
|
6 |
-
from starlette.responses import RedirectResponse
|
7 |
-
from textSummarizer.pipeline.prediction import PredictionPipeline
|
8 |
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
@app.get("/", tags=["authentication"])
|
14 |
-
async def index():
|
15 |
-
"""
|
16 |
-
The main page.
|
17 |
-
"""
|
18 |
-
return "The API is UP and running."
|
19 |
-
|
20 |
-
|
21 |
-
@app.get("/train")
|
22 |
-
async def training():
|
23 |
-
"""
|
24 |
-
The training page.
|
25 |
-
"""
|
26 |
-
try:
|
27 |
-
os.system("python main.py")
|
28 |
-
return Response("Training successful !!")
|
29 |
-
|
30 |
-
except Exception as e:
|
31 |
-
return Response(f"Error Occurred! {e}")
|
32 |
-
|
33 |
-
|
34 |
-
@app.post("/predict")
|
35 |
-
async def predict_route(text):
|
36 |
-
"""
|
37 |
-
The prediction api call.
|
38 |
-
"""
|
39 |
-
try:
|
40 |
-
|
41 |
-
obj = PredictionPipeline()
|
42 |
-
text = obj.predict(text)
|
43 |
-
return text
|
44 |
-
except Exception as e:
|
45 |
-
raise e
|
46 |
-
|
47 |
-
|
48 |
-
if __name__=="__main__":
|
49 |
-
uvicorn.run(app, host="0.0.0.0", port=8080)
|
|
|
1 |
+
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
def greet(name):
|
5 |
+
return "Hello " + name + "!!"
|
6 |
|
7 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
8 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app_fast_api.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
import uvicorn
|
4 |
+
from fastapi import FastAPI
|
5 |
+
from fastapi.responses import Response
|
6 |
+
from starlette.responses import RedirectResponse
|
7 |
+
from textSummarizer.pipeline.prediction import PredictionPipeline
|
8 |
+
|
9 |
+
text:str = "What is Text Summarization?"
|
10 |
+
|
11 |
+
app = FastAPI()
|
12 |
+
|
13 |
+
@app.get("/", tags=["authentication"])
|
14 |
+
async def index():
|
15 |
+
"""
|
16 |
+
The main page.
|
17 |
+
"""
|
18 |
+
return "The API is UP and running."
|
19 |
+
|
20 |
+
|
21 |
+
@app.get("/train")
|
22 |
+
async def training():
|
23 |
+
"""
|
24 |
+
The training page.
|
25 |
+
"""
|
26 |
+
try:
|
27 |
+
os.system("python main.py")
|
28 |
+
return Response("Training successful !!")
|
29 |
+
|
30 |
+
except Exception as e:
|
31 |
+
return Response(f"Error Occurred! {e}")
|
32 |
+
|
33 |
+
|
34 |
+
@app.post("/predict")
|
35 |
+
async def predict_route(text):
|
36 |
+
"""
|
37 |
+
The prediction api call.
|
38 |
+
"""
|
39 |
+
try:
|
40 |
+
|
41 |
+
obj = PredictionPipeline()
|
42 |
+
text = obj.predict(text)
|
43 |
+
return text
|
44 |
+
except Exception as e:
|
45 |
+
raise e
|
46 |
+
|
47 |
+
|
48 |
+
if __name__=="__main__":
|
49 |
+
uvicorn.run(app, host="0.0.0.0", port=8080)
|