Skip to content
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

new upload parameter for overwriting annotations #216

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions roboflow/adapters/rfapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def save_annotation(
image_id: str,
is_prediction: bool = False,
annotation_labelmap=None,
overwrite: bool = False,
):
"""
Upload an annotation to a specific project.
Expand All @@ -95,7 +96,7 @@ def save_annotation(
"""

upload_url = _save_annotation_url(
api_key, project_url, annotation_name, image_id, is_prediction
api_key, project_url, annotation_name, image_id, is_prediction, overwrite
)

response = requests.post(
Expand Down Expand Up @@ -126,13 +127,17 @@ def save_annotation(
return responsejson


def _save_annotation_url(api_key, project_url, name, image_id, is_prediction):
def _save_annotation_url(
api_key, project_url, name, image_id, is_prediction, overwrite=False
):
url = (
f"{API_URL}/dataset/{project_url}/annotate/{image_id}?api_key={api_key}"
f"&name={name}"
)
if is_prediction:
url += "&prediction=true"
if overwrite:
url += "&overwrite=true"
return url


Expand Down
2 changes: 2 additions & 0 deletions roboflow/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def single_upload(
image_path=None,
annotation_path=None,
annotation_labelmap=None,
annotation_overwrite=False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move to the end of the parameters list so as to keep backwards compatible with previous versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SolomonLake I accidentally closed the issue before actually merging. I think you need to approve a second time. Sorry for the inconvenience.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to build due to styling -- running make style in the root directory should fix the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope the styling checks out now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, i'll merge the PR now!

hosted_image=False,
image_id=None,
split="train",
Expand Down Expand Up @@ -513,6 +514,7 @@ def single_upload(
image_id,
is_prediction=is_prediction,
annotation_labelmap=annotation_labelmap,
overwrite=annotation_overwrite,
)
except BaseException as e:
uploaded_annotation = {"error": e}
Expand Down