flask
Robin Cole 2019-09-17 06:20:34 +01:00
parent d250c30d29
commit 84f6edac01
4 changed files with 28 additions and 3 deletions

View File

@ -1,6 +1,16 @@
# deepstack-web-ui
Unofficial web UI for working with Deepstack.
Run the app:
Run deepstack object detection:
```
$ docker run -e VISION-DETECTION=True -d \
-v localstorage:/datastore -p 5000:5000 \
-e API-KEY="Mysecretkey" \
--name deepstack deepquestai/deepstack:noavx
```
Edit the deepstack credentials in `app/server.py` and run the app:
```
$ python3 app/server.py serve
```

View File

@ -5,6 +5,7 @@ import uvicorn
from pathlib import Path
import sys
from io import BytesIO
import deepstack.core as ds
from starlette.applications import Starlette
from starlette.middleware.cors import CORSMiddleware
from starlette.responses import HTMLResponse, JSONResponse
@ -20,6 +21,13 @@ app.add_middleware(
)
app.mount("/static", StaticFiles(directory="app/static"))
## Depstack setup
DEEPSTACK_IP_ADDRESS = 'localhost'
DEEPSTACK_PORT = '5000'
DEEPSTACK_API_KEY = "Mysecretkey"
DEEPSTACK_TIMEOUT = 20 # Default is 10
dsobject = ds.DeepstackObject(DEEPSTACK_IP_ADDRESS, DEEPSTACK_PORT, DEEPSTACK_API_KEY, DEEPSTACK_TIMEOUT)
@app.route("/")
async def homepage(request):
@ -31,8 +39,13 @@ async def homepage(request):
async def analyze(request):
img_data = await request.form()
img_bytes = await (img_data["file"].read())
img = open_image(BytesIO(img_bytes))
prediction = learn.predict(img)[0]
try:
dsobject.detect(img_bytes)
except ds.DeepstackException as exc:
print(exc)
prediction = dsobject.predictions[0]
return JSONResponse({"result": str(prediction)})

View File

@ -5,3 +5,5 @@ numpy==1.16.3
starlette==0.12.0
uvicorn==0.7.1
python-multipart==0.0.5
deepstack-python==0.4
pillow

BIN
usage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB