Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import uvicorn
|
| 2 |
from fastapi import FastAPI, File, UploadFile
|
| 3 |
import gradio as gr
|
| 4 |
import pickle
|
|
@@ -128,21 +127,6 @@ def translate(text):
|
|
| 128 |
arabic = tokenizer.decode(out[0], skip_special_tokens=True)
|
| 129 |
return arabic
|
| 130 |
|
| 131 |
-
app = FastAPI()
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
@app.post("/text/")
|
| 135 |
-
def create_text(text: str):
|
| 136 |
-
return {"summary": translate(text)}
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
@app.post("/file/")
|
| 140 |
-
def create_upload_file(file: UploadFile = File(...)):
|
| 141 |
-
text = file.file.read().decode("utf-8")
|
| 142 |
-
return {"summary": translate(text)}
|
| 143 |
-
|
| 144 |
-
if __name__ == '__main__':
|
| 145 |
-
uvicorn.run(app, port=8080, host='0.0.0.0')
|
| 146 |
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|
| 147 |
demo.launch(share=True)
|
| 148 |
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, File, UploadFile
|
| 2 |
import gradio as gr
|
| 3 |
import pickle
|
|
|
|
| 127 |
arabic = tokenizer.decode(out[0], skip_special_tokens=True)
|
| 128 |
return arabic
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
|
| 131 |
demo.launch(share=True)
|
| 132 |
|