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

Read image directly instead of image path #82

Open
Drake1601 opened this issue Feb 12, 2025 · 0 comments
Open

Read image directly instead of image path #82

Drake1601 opened this issue Feb 12, 2025 · 0 comments

Comments

@Drake1601
Copy link

Drake1601 commented Feb 12, 2025

Hi @tomas-gajarsky , I am integrating facetorch model into my system using API but facing a problems:
The API receives packets containing images compressed in base64 format. Therefore, I want to pass the image directly into the input for FaceAnalyzer.run instead of providing a path to the image. I tried converting the image to a torch.Tensor and passing it to the function via the tensor parameter, but it did not work.
img_tensor = torch.from_numpy(img_rgb).permute(2, 0, 1).float() # (H, W, C) -> (C, H, W)
print(type(img_tensor))
response = analyzer.run(
tensor = img_tensor,
batch_size=cfg.batch_size,
fix_img_size=cfg.fix_img_size,
return_img_data=cfg.return_img_data,
include_tensors=cfg.include_tensors,
path_output=path_img_output,
)
The error is File "/app/facetorch/analyzer/reader/core.py", line 141, in run
data.img = torchvision.io.read_image(
File "/usr/local/lib/python3.10/site-packages/torchvision/io/image.py", line 275, in read_image
data = read_file(path)
File "/usr/local/lib/python3.10/site-packages/torchvision/io/image.py", line 52, in read_file
data = torch.ops.image.read_file(str(path))
File "/usr/local/lib/python3.10/site-packages/torch/ops.py", line 854, in call
return self
._op(*args, **(kwargs or {}))
RuntimeError: [Errno 36] File name too long: 'tensor([[[134., 131., 136., ..., 199., 199., 199.],
[129., 130., 136., ..., 198., 198., 198.],
[127., 130., 135., ..., 198., 198., 198.],
Please help me solve this problem. Thanks you!

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

1 participant