akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Function to predict probability

username: Imene.b
cooked: <p>hy every one, i have a question please:<br>
first excuse me if i write with mistakes, because i dont speak english<br>
I have annotatated image data, where i have the objects within the images and informations about it’s positions and classes. I want to use neural network to predict probabilities of each pixel in the image if it is  corner of a box containing an object. I want to know if it is possible with neural network, and if there is function in pytorch that can help in the process.</p>

username: user_123454321
cooked: <p>You want to predict a probability for each pixel in the image (of whether it is corner of box) ? For that one would need to output a tensor that is of the same shape as the input (image) and that the last activation should be sigmoid (as it squishes the values to between 0 and 1). You can look up <a href="https://arxiv.org/abs/1505.04597" rel="nofollow noopener">UNet</a> for that.<br>
Also, if I have understood correctly, you want to detect objects (it’s location) in the image, for that there are many pre-trained models available in pytorch <a href="https://pytorch.org/docs/stable/torchvision/models.html#object-detection-instance-segmentation-and-person-keypoint-detection" rel="nofollow noopener">Object Detection Models in Pytorch</a></p>

username: Imene.b
cooked: <p>thanks for your reply. Yes i want to detect the postion of object within the image.<br>
if i inderstand i must give the network the coordinates of boxes and the image and it will predict the probabilities. but witch neural network should i use (VGG, Alexnet…) or i must create my one neural network?</p>

username: user_123454321
cooked: <p>You can incorporate any pre-trained classification model like (VGG, Alexnet, resnet, etc.) as an encoder and build the corresponding decoder. There is a good pytorch library for this <a href="https://github.com/qubvel/segmentation_models.pytorch" rel="nofollow noopener">Pytorch Segmentation Models</a></p>

username: Imene.b
cooked: <p>thank you very mutch</p>

username: Imene.b
cooked: <p>I  was asking the last time, if we can use neural network to predict if each pixel in an image is a corner of a box. I want to know<br>
1-  if this code is  correct or not:<br>
2- whene i got the probabilities, how can i distinct the probability of the top left corner from the probability of bottom right corner or the auther<br>
image input_size = 512</p>
<p>import torch<br>
import torch.nn as nn<br>
import torch.nn.functional as F<br>
class corner_predict(nn.Module):<br>
declarations…<br>
dim_out = 512*3 (3 if the pixel is Top left corner, bottom right corner, auther)<br>
self.base_conv = nn.conv2D(512, 512, 3, 1, 1, bias=True)<br>
self.class_pred = nn.conv2D( 512, dim_out, 1, 1, 0)<br>
self.class_loss = 0<br>
def forward (image, bbox):<br>
conv1 =   F.relu(self.base_conv(image), inplace=True)<br>
conv2 = self.class_pred(conv1)<br>
prob_corner = F.sigmoid(conv2)<br>
------- loss calculations</p>
Add tensor and array

username: Yi_Zhang
cooked: <p>Hi,</p>
<p>This might be a special situation. I have a cuda tensor and a numpy array. What is the best way to add their elements one by one? For example:<br>
tensor1 = [1,1,1,1,1]<br>
array1 = [0,1,2,3,4]<br>
result = tensor1 + array1 (not sure what function to use)<br>
Desired results:<br>
result = [1,2,3,4,5]</p>
<p>Thank you!</p>

username: albanD
cooked: <p>Hi,</p>
<p>It depends if you want the result to be a numpy array or a Tensor? And in the second case, if you want the result to be on CPU or GPU?</p>

username: Yi_Zhang
cooked: <p>Hi <a class="mention" href="/u/alband">@albanD</a>, thanks for reply. I want the result to be a GPU tensor. What could be the best way to do this?</p>

username: albanD
cooked: <p>This should do it:</p>
<pre><code class="lang-auto">result = tensor1 + torch.from_numpy(array1).to(tensor1.device)
</code></pre>