akankshakshurai/cuda-error-resolution-analysis huggingface dataset:
Using a custom dataset for Detectron2: can't visualize annotations

iskode: <p>Hi everyone,<br>
I’m working on a custom dataset using the tutorial   <a href="https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5" rel="noopener nofollow ugc">use custom dataset</a>.<br>
I’ve have tested (print out) my image annotations and they are all there but I just see the image without annotation overlays using the instruction in the tutorial. Below is the output of an image I’m trying to visualize the annotations. I showed only the first 10 items of the segmentation key.</p>
<blockquote>
<p>nb of labels : 3<br>
<strong>label 0</strong><br>
bbox : [38, 61, 54, 80]<br>
bbox_mode : 0<br>
category_id : 0<br>
iscrowd : 0<br>
segmentation: [63.5, 62.5, 64.5, 61.5, 66.5, 61.5, 67.5, 62.5, 68.5, 61.5]<br>
<strong>label 1</strong><br>
bbox : [64, 85, 62, 61]<br>
bbox_mode : 0<br>
category_id : 1<br>
iscrowd : 0<br>
segmentation: [103.5, 86.5, 104.5, 85.5, 105.5, 85.5, 106.5, 86.5, 107.5, 86.5]<br>
<strong>label 2</strong><br>
bbox : [68, 90, 53, 51]<br>
bbox_mode : 0<br>
category_id : 2<br>
iscrowd : 0<br>
segmentation: [92.5, 91.5, 93.5, 90.5, 94.5, 90.5, 95.5, 91.5, 98.5, 91.5]</p>
</blockquote>
<p>Some images don’t have my target objects so I set <code>category_id</code> to  <code>num_categories</code> (here 3) to indicate that this image is only background (<strong>is my use of it correct ??</strong>).</p>
<p>As I work in google colab, I’ve tried to modify the source that prompts when accessing the method definition in order to add some print in the <code>overlay_instances</code>. But nothing appears.<br>
Please how can debug this matter.</p>
<p>Thank you so much.</p>

iskode: <p>Concerning the local repo modification, I’ve found that the instruction below adapted from the <a href="https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5" rel="nofollow noopener">custom dataset tutorial</a>:</p>
<pre><code class="lang-auto">!pip install -e "/content/gdrive/My Drive/Colab Notebooks/project_dir"/detectron2_repo
</code></pre>
<p>doesn’t  make the repo editable at all. No changes in files in the local repo take effect.<br>
So if someone could point me a way to make the repo editable, it’ll help debug my issue.<br>
I’ve searched around and found some other CLI but nothing works:</p>
<pre><code class="lang-auto">!cd "/content/gdrive/My Drive/Colab Notebooks/acdc"/detectron2_repo ; python setup.py develop
</code></pre>
<p>PS: I’m working on google colab! is that related to my inability to modify the repo ?</p>

iskode: <p>Hi, sorry I figured out my dumb tiny mistake: forgot to put “s” at the end the “annotation<strong>s</strong>” key in the data dict.</p>
Nonlinearity choice based on target

blade: <p>I have a network that has 2 output vectors, where, MSE loss is computed for each output. One of my targets outputs a value between -1,1 and the other one computes a value between 0 and 9. Based on this, would it be possible to suggest non-linear activations for each branch? Also, is there an activation that encourages close to integer outputs?</p>
Examples of custom autograd backward function in C++

mikehamer: <p>I have an operation computed with a custom CUDA kernel, which involves a custom forward, and custom backward pass. I have this working in Python (calling via PyBind11 to the custom C++). I am now porting the entire pipeline to use the PyTorch C++ frontend, since I can then do away with Python completely.</p>
<p>I’m struggling to figure out how the autograd infrastructure builds the computation graph for the backwards pass in C++, how gradients are propagated backwards, and how I would fit my custom backward pass into the pipeline.</p>
<p>Is there any documentation on this? Or any examples where a custom backward function is implemented?</p>
<p>Thank you,<br>
Mike</p>

mikehamer: <p>To answer my own question, I compiled libtorch from source and reverse engineered the autogenerated functions (eg. torch::pow() which uses e.g. the PowBackward0 backward function).</p>
<p>Doing this I came up with the minimal working example:</p>
<aside class="onebox githubgist">
  <header class="source">
      <a href="https://gist.github.com/mikehamer/df0af5ec7ff98d3cae487975d0c921df" target="_blank" rel="nofollow noopener">gist.github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://gist.github.com/mikehamer/df0af5ec7ff98d3cae487975d0c921df" target="_blank" rel="nofollow noopener">https://gist.github.com/mikehamer/df0af5ec7ff98d3cae487975d0c921df</a></h4>
<h5>pytorch_custom_backward.cpp</h5>
<pre><code class="C++">// An example of using the PyTorch C++ API to implement a custom forward and backward function

#include &lt;iostream&gt;
#include &lt;vector&gt;

#include &lt;torch/torch.h&gt;
#include &lt;torch/csrc/autograd/variable.h&gt;
#include &lt;torch/csrc/autograd/function.h&gt;
#include &lt;torch/csrc/autograd/VariableTypeUtils.h&gt;
#include &lt;torch/csrc/autograd/functions/utils.h&gt;</code></pre>
This file has been truncated. <a href="https://gist.github.com/mikehamer/df0af5ec7ff98d3cae487975d0c921df" target="_blank" rel="nofollow noopener">show original</a>

<p>
</p>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>To show a clean example, I cut out a lot of JIT stuff from the auto-generated examples, as well as checks and balances (asserts, error handling logic if wrong types are passed, etc).</p>
<p>I’d still be interested in someone’s input on how the whole autograd infrastructure works in C++. But in the meantime, I hope this example helps someone.</p>

Carol_Ye_Liu: <p><a class="mention" href="/u/mikehamer">@mikehamer</a> Thanks a lot for sharing your code. I tried your code with the libtorch 1.4 version, it works great with few changes:</p>
<ol>
<li>auto result = as_variable(tmp); need to be changed to auto result = tmp; since as_variable is no longer available.</li>
<li>deleteFunction and Function need to be replaced with deleteNode and Node.</li>
</ol>