Skip to content

Commit

Permalink
Merge pull request #114 from roboflow/upload-with-tag
Browse files Browse the repository at this point in the history
added tag_name on upload
  • Loading branch information
bigbitbus authored Feb 17, 2023
2 parents 57b7aa7 + 02ebfd4 commit c0b6bf0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
43 changes: 30 additions & 13 deletions roboflow/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def __image_upload(
hosted_image=False,
split="train",
batch_name=DEFAULT_BATCH_NAME,
tag_names=[],
**kwargs,
):
"""function to upload image to the specific project
Expand Down Expand Up @@ -296,6 +297,9 @@ def __image_upload(
for key, value in kwargs.items():
self.image_upload_url += "&" + str(key) + "=" + str(value)

for tag in tag_names:
self.image_upload_url = self.image_upload_url + f"&tag={tag}"

# Convert to PIL Image
img = cv2.imread(image_path)
image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
Expand Down Expand Up @@ -376,21 +380,30 @@ def check_valid_image(self, image_path):

def upload(
self,
image_path=None,
annotation_path=None,
hosted_image=False,
image_id=None,
split="train",
num_retry_uploads=0,
batch_name=DEFAULT_BATCH_NAME,
image_path: str = None,
annotation_path: str = None,
hosted_image: bool = False,
image_id: int = None,
split: str = "train",
num_retry_uploads: int = 0,
batch_name: str = DEFAULT_BATCH_NAME,
tag_names: list = [],
**kwargs,
):
"""upload function
:param image_path: path to image you'd like to upload
:param annotation_path: if you're upload annotation, path to it
:param hosted_image: whether the image is hosted
:param image_id: id of the image
:param split: split to upload the image to
"""Upload image function based on the RESTful API
Args:
image_path (str) - path to image you'd like to upload
annotation_path (str) - if you're upload annotation, path to it
hosted_image (bool) - whether the image is hosted
image_id (int) - id of the image
split (str) - to upload the image to
num_retry_uploads (int) - how many times to retry upload on failure
batch_name (str) - name of batch to upload to within project
tag_names (list[str]) - tags to be applied to an image
Returns:
None - returns nothing
"""

is_hosted = image_path.startswith("http://") or image_path.startswith(
Expand Down Expand Up @@ -425,6 +438,7 @@ def upload(
split=split,
num_retry_uploads=num_retry_uploads,
batch_name=batch_name,
tag_names=tag_names,
**kwargs,
)
else:
Expand All @@ -440,6 +454,7 @@ def upload(
split=split,
num_retry_uploads=num_retry_uploads,
batch_name=batch_name,
tag_names=tag_names,
**kwargs,
)
print("[ " + path + " ] was uploaded succesfully.")
Expand All @@ -456,6 +471,7 @@ def single_upload(
split="train",
num_retry_uploads=0,
batch_name=DEFAULT_BATCH_NAME,
tag_names=[],
**kwargs,
):
success = False
Expand All @@ -468,6 +484,7 @@ def single_upload(
hosted_image=hosted_image,
split=split,
batch_name=batch_name,
tag_names=tag_names,
**kwargs,
)
# Get JSON response values
Expand Down
1 change: 0 additions & 1 deletion roboflow/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def active_learning(
and prediction["confidence"] * 100
<= conditionals["confidence_interval"][1]
):

# filter out non-target_class uploads if enabled
if (
len(conditionals["target_classes"]) > 0
Expand Down
1 change: 0 additions & 1 deletion roboflow/models/object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def __generate_url(
labels=None,
format=None,
):

# Reassign parameters if any parameters are changed
if local is not None:
if not local:
Expand Down
1 change: 0 additions & 1 deletion roboflow/util/two_stage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


def ocr_infer(image):

# Convert to JPEG Buffer
buffered = io.BytesIO()
image.save(buffered, quality=90, format="PNG")
Expand Down
2 changes: 1 addition & 1 deletion roboflow/util/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def print_warn_for_wrong_dependencies_versions(
dependencies_versions: List[Tuple[str, str, str]]
):
wrong_dependencies_versions = get_wrong_dependencies_versions(dependencies_versions)
for (dependency, order, version, module_version) in wrong_dependencies_versions:
for dependency, order, version, module_version in wrong_dependencies_versions:
print(
f"Dependency {dependency}{order}{version} is required but found version={module_version}, to fix: `pip install {dependency}{order}{version}`"
)
Expand Down

0 comments on commit c0b6bf0

Please sign in to comment.