REST API incomplete image urls paths + search functions cant get uploaded image ID for hardcode URL
Image URL paths returned from image detail REST API is:
https://source.roboflow.com/[owner_id]/undefined/original.jpg
Image URL paths only working if follow this format:
https://source.roboflow.com/[owner_id]/[image_id]/original.jpg
Do excuse me If this is out of scope as I don't see other repos to report this issue.
Hi thanks for reporting; could you provide the code snippet used where you got these URLs?
Was just testing out the API in the browser and no code written. I browsed using this form of URL https://api.roboflow.com/my-workspace/my-project-name/images/image-id?api_key=ROBOFLOW_API_KEY
I can hardcode the URL format because I'm also planning to query for them in my Python server. I have a route for uploading new data to my Roboflow workspace:
@register.route('/register', methods=['POST'])
def register_user():
data = request.get_json()
id = data["id"]
name = data["name"]
images = list(data["images"])
# Save images locally first to get path
# Create folders on init
# TODO Relocate dir create commands to respective functions
pathlib.Path('./images').mkdir(parents=True, exist_ok=True)
pathlib.Path('./images/new_faces').mkdir(parents=True, exist_ok=True)
pathlib.Path('./images/new_items').mkdir(parents=True, exist_ok=True)
# Temporarily write image files locally for upload later
imageIds = []
for (i, image) in enumerate(images):
filePath = f"./images/new_faces/{id}_{name}_{i}.jpg"
bImage = base64.b64decode(image)
with open(filePath, "wb") as image:
image.write(bImage)
image.close()
# Send image to roboflow
rfLabretProject.upload(filePath, tag_names=[id])
# Get image URL
# Case 1: When using search_all
for page in rfLabretProject.search_all(tag=id, batch=True, fields=["id", "owner"]):
imageIds.extend(page)
# Case 2: When using search
for page in rfLabretProject.search(tag=id, batch=True, fields=["id", "owner"]):
imageIds.append(page)
return jsonify({'message': 'User registered successfully', 'imageIds': imageIds})
The problem is, I tried using search_all and search functions and set it to check results from batches since I just uploaded them. both search and search_all doesn't return any results:
I'm not sure whether I specified the right arguments or if the upload result is not immediately available yet
When i put search functions in the for (i, image) in enumerate(images): loop, final result show relevant image ids but is inconsistent and different between attempts.
e.g. Here I uploaded 5 images. for loop iterates and appends new result item over upload count, and the latest result show all 5 images, but in another attempt and most cases, I get nothing.
I assume upload is async, but I'm new to Python in general and I don't know how to wait for the function.