-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge only inference with cloud training #101
Conversation
…dge-endpoint into edge-with-training
…dge-endpoint into edge-with-training
…edge-endpoint into edge-with-training
…dge-endpoint into edge-with-training
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great overall! Awesome functionality to have. I just left a few comments about making sure things aren't confusing if external users are going to be using the edge-only modes.
As an additional thought, I wonder if we should change the default refresh_rate
so that it looks for new model binaries for frequently - the current default of 120 seconds is pretty slow, and users might want to see improvements more quickly if they're sending a lot of queries.
@@ -50,23 +50,32 @@ print(f"The answer is {image_query.result}") | |||
See the [SDK's getting started guide](https://code.groundlight.ai/python-sdk/docs/getting-started) for more info. | |||
|
|||
### Experimental: getting only edge model answers | |||
If you only want to receive answers from the edge model for a detector, you can enable edge-only mode for it. To do this, edit the detector's configuration in the [edge config file](./configs/edge-config.yaml) like so: | |||
If you only want to receive answers from the edge model for a detector, you can enable edge-only mode for it. This will prevent the edge endpoint from sending image queries to the cloud API. If you want fast edge answers regardless of confidence but still want the edge model to improve, you can enable edge-only inference for that detector. This mode will always return the edge model's answer, but it will also submit low confidence image queries to the cloud API for training. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a different naming we could have for these different modes - I worry that the difference between "edge-only mode" and "edge-only inference" would be unclear to anyone external. Depending on how experimental/temporary these are, this might not matter, but if we expect external customers to use these at some point I think having more clear names might be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it's confusing. Maybe I could change them to edge_only_no_training
and edge_only_cloud_training
? That gets a little wordy, but might be more clear. Definitely open to naming suggestions, wasn't sure what to call it.
README.md
Outdated
- detector_id: 'det_abc' | ||
motion_detection_template: "default" | ||
local_inference_template: "default" | ||
``` | ||
In this example, `det_xyz` will have edge-only mode enabled because `edge_only` is set to `true`. If `edge_only` is not specified, it defaults to false, so `det_abc` will have edge-only mode disabled. | ||
In this example, `det_xyz` will have edge-only mode enabled because `edge_only` is set to `true`. `det_ijk` will have edge-only inference enabled because `edge_only_inference` is set to `true`. If `edge_only` or `edge_only_inference` are not specified, they defaults to false, so `det_abc` will have edge-only mode disabled. Only one of `edge_only` or `edge_only_inference` can be set to `true` for a detector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny typo but this says "they defaults to false".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops thank you!
README.md
Outdated
|
||
With edge-only mode enabled for a detector, when you make requests to it, you will only receive answers from the edge model (regardless of the confidence). Additionally, note that no image queries submitted this way will show up in the web app or be used to train the model. This option should therefore only be used if you don't need the model to improve and only want fast answers from the edge model. | ||
|
||
If edge-only mode is enabled on a detector and the edge inference model for that detector is not available, attempting to send image queries to that detector will return a 500 error response. | ||
With edge-only inference enabled for a detector, when you make requests to it, you will only receive answers from the edge model (regardless of the confidence). However, image queries submitted this way with confidences below the threshold will be used to train the model. This option should be used when you want fast edge answers regardless of confidence but still want the model to improve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to be more clear this should say something like, "However, when the edge model makes a prediction with confidence below the threshold, that image query will also be escalated to the cloud and used to train the model"?
test/core/test_configs.py
Outdated
from app.core.configs import DetectorConfig | ||
|
||
|
||
def test_detector_config(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome to have this test, maybe it would be good to name it something more specific like "test_detector_config_with_both_edge_modes" in case we want to add more detector config tests in the future?
if edge_only_inference and not _is_confident_enough( | ||
confidence=confidence, | ||
confidence_threshold=confidence_threshold, | ||
): | ||
logger.info("Escalating to the cloud API server for future training due to low confidence.") | ||
background_tasks.add_task(safe_call_sdk, gl.ask_async, detector=detector_id, image=image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Love how simple this is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I do think deduping the images will become important in the near future, but for internal demos this should be great
…dge-endpoint into edge-with-training
[COM-1567] This PR adds an
edge_only_inference
mode which allows the model to escalate to the cloud for future training, while still always returning the edge inference answer for fast results.Tested with 3 binary detectors with
edge_only
enabled -- nothing escalated to cloudedge_only_inference
enabled -- low confidence IQs escalated to cloud, edge answer returnededge_only
noredge_only_inference
enabled -- low confidence edge IQs escalated to cloud and cloud answer returned.edge_only
andedge_only_inference
enabled -- pods do not launch, logs show the config validation errorCurrently not adding many unit tests as they aren't set up to test
post_image_query
, and we want to get this change out quickly (discussed with Tyler).This is a first step -- in the future we may want to add: