-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
279 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ from learning_loop_node/learning_loop_node | |
|
||
Detector Nodes are normally deployed on edge devices like robots or machinery but can also run in the cloud to provide backend services for an app or similar. These nodes register themself at the Learning Loop. They provide REST and Socket.io APIs to run inference on images. The processed images can automatically be used for active learning: e.g. uncertain predictions will be send to the Learning Loop. | ||
|
||
### Running Inference | ||
|
||
Images can be send to the detector node via socketio or rest. | ||
The later approach can be used via curl, | ||
|
||
|
@@ -62,6 +64,26 @@ The detector also has a sio **upload endpoint** that can be used to upload image | |
|
||
The endpoint returns None if the upload was successful and an error message otherwise. | ||
|
||
### Changing the outbox mode | ||
|
||
If the autoupload is set to `all` or `filtered` (selected) images and the corresponding detections are saved on HDD (the outbox). A background thread will upload the images and detections to the Learning Loop. The outbox is located in the `outbox` folder in the root directory of the node. The outbox can be cleared by deleting the files in the folder. | ||
|
||
The continuous upload can be stopped/started via a REST enpoint: | ||
|
||
Example Usage: | ||
|
||
- Enable upload: `curl -X PUT -d "continuous_upload" http://localhost/outbox_mode` | ||
- Disable upload: `curl -X PUT -d "stopped" http://localhost/outbox_mode` | ||
|
||
The current state can be queried via a GET request: | ||
`curl http://localhost/outbox_mode` | ||
|
||
### Explicit upload | ||
|
||
The detector has a REST endpoint to upload images (and detections) to the Learning Loop. The endpoint takes a POST request with the image and optionally the detections. The image is expected to be in jpg format. The detections are expected to be a json dictionary. Example: | ||
|
||
`curl -X POST -F '[email protected]' "http://localhost:/upload"` | ||
|
||
## Trainer Node | ||
|
||
Trainers fetch the images and anntoations from the Learning Loop to train new models. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from fastapi import APIRouter, HTTPException, Request | ||
from fastapi.responses import PlainTextResponse | ||
|
||
from ..outbox import Outbox | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/outbox_mode") | ||
async def get_outbox_mode(request: Request): | ||
''' | ||
Example Usage | ||
curl http://localhost/outbox_mode | ||
''' | ||
outbox: Outbox = request.app.outbox | ||
return PlainTextResponse(outbox.get_mode().value) | ||
|
||
|
||
@router.put("/outbox_mode") | ||
async def put_outbox_mode(request: Request): | ||
''' | ||
Example Usage | ||
curl -X PUT -d "continuous_upload" http://localhost/outbox_mode | ||
curl -X PUT -d "stopped" http://localhost/outbox_mode | ||
''' | ||
outbox: Outbox = request.app.outbox | ||
content = str(await request.body(), 'utf-8') | ||
try: | ||
outbox.set_mode(content) | ||
except TimeoutError as e: | ||
raise HTTPException(202, 'Setting has not completed, yet: ' + str(e)) from e | ||
except ValueError as e: | ||
raise HTTPException(422, 'Could not set outbox mode: ' + str(e)) from e | ||
|
||
return "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
from typing import List | ||
from typing import TYPE_CHECKING, List | ||
|
||
from fastapi import APIRouter, File, Request, UploadFile | ||
|
||
if TYPE_CHECKING: | ||
from ..detector_node import DetectorNode | ||
|
||
router = APIRouter() | ||
|
||
|
||
|
@@ -13,5 +16,6 @@ async def upload_image(request: Request, files: List[UploadFile] = File(...)): | |
curl -X POST -F '[email protected]' "http://localhost:/upload" | ||
""" | ||
raw_files = [await file.read() for file in files] | ||
await request.app.upload_images(raw_files) | ||
node: DetectorNode = request.app | ||
await node.upload_images(raw_files) | ||
return 200, "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.