hamza13444 For the first part of your question, I believe you want to use a CSV file which maps an image to an image path and a tag name. If this is correct, then there is no direct way to just upload this CSV file and get the images uploaded in your project. An easier way to get this accomplished is to store your images on a local path in folders based on the tag that needs to be added to them and then use the programmatic way to upload the images and add a tag. This can be done through any SDK client ex: python client as in this quickstart.
For example, here we are using an Images root directory and having the images related to the tags we want in our project in separate folders i.e Hemlock and Japanese Cherry.
The rest of the steps mentioned uses a list to read the images from the path and adds a tag to create a ImageFileCreateEntry
object list and uploads them with one go using trainer.create_images_from_files()
base_image_location = os.path.join (os.path.dirname(__file__), "Images")
print("Adding images...")
image_list = []
for image_num in range(1, 11):
file_name = "hemlock_{}.jpg".format(image_num)
with open(os.path.join (base_image_location, "Hemlock", file_name), "rb") as image_contents:
image_list.append(ImageFileCreateEntry(name=file_name, contents=image_contents.read(), tag_ids=[hemlock_tag.id]))
for image_num in range(1, 11):
file_name = "japanese_cherry_{}.jpg".format(image_num)
with open(os.path.join (base_image_location, "Japanese_Cherry", file_name), "rb") as image_contents:
image_list.append(ImageFileCreateEntry(name=file_name, contents=image_contents.read(), tag_ids=[cherry_tag.id]))
upload_result = trainer.create_images_from_files(project.id, ImageFileCreateBatch(images=image_list))
if not upload_result.is_batch_successful:
print("Image batch upload failed.")
for image in upload_result.images:
print("Image status: ", image.status)
exit(-1)
Secondly, tagging the images with file names should be avoided because you might end up with a lot of tags to manage. If your images belong to a certain class, tag them under a certain class by creating a tag using trainer.create_tag()
I hope this helps!!