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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] #2178

Open
1 of 2 tasks
neyazbasheer opened this issue Feb 14, 2023 · 1 comment
Open
1 of 2 tasks

[FEATURE] #2178

neyazbasheer opened this issue Feb 14, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@neyazbasheer
Copy link

neyazbasheer commented Feb 14, 2023

馃毃馃毃 Feature Request

  • Related to an existing Issue
  • A new implementation (Improvement, Extension)

Is your feature request related to a problem?

@deeplake.compute
def resize(sample_in, sample_out, new_size):
    ## First two arguments are always default arguments containing:
    #     1st argument is an element of the input iterable (list, dataset, array,...)
    #     2nd argument is a dataset sample
    ## Third argument is the required size for the output images
    
    # Append the label and image to the output sample
    sample_out.labels.append(sample_in.labels.numpy())
    sample_out.images.append(np.array(Image.fromarray(sample_in.images.numpy()).resize(new_size)))
    sample_out.info.append(sample_in.info.dict())
    
    return sample_out

In the above example when new samples are computed we need to make sure all tensors are passed to the sample_out even if it's unmodified. It will be really helpful if we can pipe them directly without explicitly having to get them as numpy or dict.

Description of the possible solution

@deeplake.compute
def resize(sample_in, sample_out, new_size):

    
    # Append the label and image to the output sample
    sample_out.labels.append(sample_in.labels)
    sample_out.images.append(np.array(Image.fromarray(sample_in.images.numpy()).resize(new_size)))
    sample_out.info.append(sample_in.info)
    return sample_out

An alternative solution to the problem can look like

@deeplake.compute
def resize(sample_in, sample_out, new_size):

    
    # Append the label and image to the output sample
    sample_out.images.append(np.array(Image.fromarray(sample_in.images.numpy()).resize(new_size)))
    sample_out.pipe_missing(sample_in)
    return sample_out

it could also be an additional decorator or an option in the existing decorator.

@deeplake.compute(pipe_missing=True)
def resize(sample_in, sample_out, new_size):

    
    # Append the label and image to the output sample
    sample_out.images.append(np.array(Image.fromarray(sample_in.images.numpy()).resize(new_size)))
    return sample_out
@neyazbasheer neyazbasheer added the enhancement New feature or request label Feb 14, 2023
@istranic
Copy link
Contributor

Hey @neyazbasheer Thank you for raising the issue. Not sure if you noticed the skip_ok flag in .eval(..., skip_ok = True). This should produce the desired behavior. Can you try that out if you have a chance?

https://docs.deeplake.ai/en/latest/deeplake.html#deeplake.compute

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

No branches or pull requests

3 participants