how to implement this: torchvision.transforms.functional.perspective
See original GitHub issueArea Select
react-native-pytorch-core (core package)
Description
Hello! thanks for contributions!
I have a problem while developing my project. I need a function like torchvision.transforms.functional.perspective
Could you add this implementation for torchvision.transforms.functional.perspective
?
or
Can i implement this function?
There is no implementation of perspective function in playtorch docs
Another solution that i proceed is making pytorch mobile model for this function. This idea came from @raedle of this issue. but it has a error at react-native app like this:
{"message": "Calling torch.linalg.lstsq on a CPU tensor requires compiling PyTorch with LAPACK. Please use PyTorch built with LAPACK support.
Debug info for handle(s): debug_handles:{-1}, was not found.
Exception raised from apply_lstsq at ../aten/src/ATen/native/BatchLinearAlgebraKernel.cpp:559 (most recent call first):
(no backtrace available)"}
Should i question to pytorch github about this error?
My perspective model is like this: This model is successful at python code.
import torch, torchvision
from typing import List, Dict
import torchvision.transforms.functional as F
class WrapPerspectiveCrop(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, inputs: torch.Tensor, points: List[List[int]]):
size_points = [[0,0], [inputs.shape[2],0] , [inputs.shape[2],inputs.shape[1]], [0,inputs.shape[1]]]
inputs = F.perspective(inputs, points, size_points)
return inputs
crop = WrapPerspectiveCrop()
scripted_model = torch.jit.script(crop)
scripted_model.save("wrap_perspective.pt")
import torch
from torch.utils.mobile_optimizer import optimize_for_mobile
optimized_scripted_module=optimize_for_mobile(scripted_model)
optimized_scripted_module._save_for_lite_interpreter("wrap_perspective.ptl")
How can i solve this problem? Many many thanks for anyone help!
Issue Analytics
- State:
- Created a year ago
- Comments:25 (8 by maintainers)
Top Results From Across the Web
perspective — Torchvision main documentation - PyTorch
Perform perspective transform of the given image. If the image is torch Tensor, it is expected to have […, H, W] shape, where...
Read more >PyTorch Functional Transforms for Computer Vision
The functional transforms can be accessed from the torchvision.transforms.functional module. A functional transform gives more control of the ...
Read more >vision/functional.py at main · pytorch/vision - torchvision - GitHub
"""Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms. In Perspective Transform each pixel...
Read more >TorchVision Transforms: Image Preprocessing in PyTorch
This post explains the torchvision.transforms module by describing the API and showing you how to create custom image transforms.
Read more >torchvision.transforms.functional.perspective - Program Talk
python code examples for torchvision.transforms.functional.perspective. Learn how to use python api torchvision.transforms.functional.perspective.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am not entirely sure. Let me get back to you on this. Also is this on ios or android?
@raedle, I figure out the blocklist was problem. When i removed this blocklist argument
optimization_blocklist
, the model output works fine as float output on react-native app. Thanks a lot for your help! I need to study more about this blocklist.