- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Shahid Akhtar Khan has Published 216 Articles
Shahid Akhtar Khan
22K+ Views
A torch tensor defined on CPU can be moved to GPU and vice versa. For high-dimensional tensor computation, the GPU utilizes the power of parallel computing to reduce the compute time.High-dimensional tensors such as images are highly computation-intensive and takes too much time if run over the CPU. So, we ... Read More
Shahid Akhtar Khan
22K+ Views
A tensor in PyTorch can be normalized using the normalize() function provided in the torch.nn.functional module. This is a non-linear activation function.It performs Lp normalization of a given tensor over a specified dimension.It returns a tensor of normalized value of the elements of original tensor.A 1D tensor can be normalized ... Read More
Shahid Akhtar Khan
27K+ Views
We can join two or more tensors using torch.cat(), and torch.stack(). torch.cat() is used to concatenate two or more tensors, whereas torch.stack() is used to stack the tensors. We can join the tensors in different dimensions such as 0 dimension, -1 dimension.Both torch.cat() and torch.stack() are used to join the ... Read More
Shahid Akhtar Khan
29K+ Views
A PyTorch tensor is like numpy.ndarray. The difference between these two is that a tensor utilizes the GPUs to accelerate numeric computation. We convert a numpy.ndarray to a PyTorch tensor using the function torch.from_numpy(). And a tensor is converted to numpy.ndarray using the .numpy() method.StepsImport the required libraries. Here, the ... Read More
Shahid Akhtar Khan
34K+ Views
The ToPILImage() transform converts a torch tensor to PIL image. The torchvision.transforms module provides many important transforms that can be used to perform different types of manipulations on the image data. ToPILImage() accepts torch tensors of shape [C, H, W] where C, H, and W are the number of channels, ... Read More
Shahid Akhtar Khan
22K+ Views
The bounding rectangle of an object is a rectangle drawn around an object in the image. There are two methods to find the bounding rectangle in OpenCV − Straight Bounding Rectangle It is a straight rectangle as it does not consider the rotation of an object. It can be computed ... Read More
Shahid Akhtar Khan
25K+ Views
OpenCV provides us the function cv.rotate() to rotate an image (NumPy array) in multiples of 90 degrees. This function rotates an image in three possible ways: 90, 180, and 270 degrees clockwise. We use the following syntax − Syntax cv2.rotate(img, rotateCode) rotateCode is a rotate flag specifying how to ... Read More
Shahid Akhtar Khan
31K+ Views
To detect a rectangle and square in an image, we first detect all the contours in the image. Then Loop over all contours. Find the approximate contour for each of the contours. If the number of vertex points in the approximate contour is 4 then we compute the aspect ratio ... Read More
Shahid Akhtar Khan
34K+ Views
In OpenCV, to change the contrast and brightness of an image we could use cv2.convertScaleAbs(). The syntax we use for this method is as follows − cv2.convertScaleAbs(image, alpha, beta) Where image is the original input image. alpha is the contrast value. To lower the contrast, use 0 < ... Read More
Shahid Akhtar Khan
36K+ Views
We use the function cv2.normalize() to normalize an image in OpenCV. This function accepts the parameters- src, dst, alpha, beta, norm_type, dtype and mask. src and dst are input image and output of the same size as input, alpha is lower norm value for range normalization, beta is upper norm ... Read More