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

REST API incomplete image urls paths + search functions cant get uploaded image ID for hardcode URL #256

Open
Kyewn opened this issue May 19, 2024 · 4 comments
Assignees

Comments

@Kyewn
Copy link

Kyewn commented May 19, 2024

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.

@yeldarby
Copy link
Contributor

Hi thanks for reporting; could you provide the code snippet used where you got these URLs?

@yeldarby yeldarby self-assigned this May 20, 2024
@Kyewn
Copy link
Author

Kyewn commented May 22, 2024

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

@Kyewn
Copy link
Author

Kyewn commented May 22, 2024

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:
image

I'm not sure whether I specified the right arguments or if the upload result is not immediately available yet

@Kyewn Kyewn changed the title REST API incomplete image urls paths REST API incomplete image urls paths + search functions cant get uploaded data May 22, 2024
@Kyewn Kyewn changed the title REST API incomplete image urls paths + search functions cant get uploaded data REST API incomplete image urls paths + search functions cant get uploaded data for hardcode URL May 22, 2024
@Kyewn Kyewn changed the title REST API incomplete image urls paths + search functions cant get uploaded data for hardcode URL REST API incomplete image urls paths + search functions cant get uploaded data ID for hardcode URL May 22, 2024
@Kyewn Kyewn changed the title REST API incomplete image urls paths + search functions cant get uploaded data ID for hardcode URL REST API incomplete image urls paths + search functions cant get uploaded image ID for hardcode URL May 22, 2024
@Kyewn
Copy link
Author

Kyewn commented May 22, 2024

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.
image
image

I assume upload is async, but I'm new to Python in general and I don't know how to wait for the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants