<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Шабат Дмитрий on Medium]]></title>
        <description><![CDATA[Stories by Шабат Дмитрий on Medium]]></description>
        <link>https://medium.com/@mitya.shabat?source=rss-1cd15e865e14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*NTHEvjNw_DN2ciFy</url>
            <title>Stories by Шабат Дмитрий on Medium</title>
            <link>https://medium.com/@mitya.shabat?source=rss-1cd15e865e14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:21:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mitya.shabat/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[C++ Programming setup for noobs]]></title>
            <link>https://medium.com/@mitya.shabat/c-programming-setup-for-noobs-3c3c87df350e?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c3c87df350e</guid>
            <category><![CDATA[lldb]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[clangd]]></category>
            <category><![CDATA[cmake]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Sat, 05 Jul 2025 21:47:32 GMT</pubDate>
            <atom:updated>2025-07-05T21:47:32.739Z</atom:updated>
            <content:encoded><![CDATA[<p>Setting up my dev environment for C++ a few months ago was unsurprisingly non-trivial, so I wanted to share the things that would’ve helped me get it started much faster.</p><blockquote><em>Some parts may vary for non-Mac users. More on this in the </em><strong><em>clangd</em></strong><em> section</em></blockquote><h3>IDE: VSCode / Cursor</h3><p>In the past I’ve worked with: <a href="https://eclipseide.org/">Eclipse</a>, <a href="https://www.jetbrains.com/clion/">CLion</a>, <a href="https://visualstudio.microsoft.com/">Visual Studio</a>, <a href="https://www.vim.org/">Vim</a> — and <a href="https://code.visualstudio.com/">VSCode</a> is the best in terms of versatility + ease of setting up.</p><p><em>Though tbh the main reason I initially switched from Vim to VSCode was proper </em><a href="https://jupyter.org/"><em>Jupyter Notebook</em></a><em> support.</em></p><p>But it’s easy to have a very pleasant setup that doesn’t require me to really tweak much:</p><ul><li><a href="https://open-vsx.org/extension/vadimcn/vscode-lldb">CodeLLDB</a> for debugging</li><li><a href="https://open-vsx.org/extension/llvm-vs-code-extensions/vscode-clangd">Clangd</a> for language support — more on that in respective section</li><li><a href="https://open-vsx.org/extension/twxs/cmake">CMake</a> — syntax highlighting for CMakeLists.txt files</li></ul><p>And <strong>Monokai</strong> as my Color Theme of choice</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-piJncqviEMfNFjcpxtStg.png" /><figcaption>How my IDE setup looks</figcaption></figure><blockquote><em>My other must-have is the </em><a href="https://marketplace.visualstudio.com/items?itemName=vscodevim.vim"><em>Vim</em></a><em> extension — if you’re not familiar, I believe the speedup is worth investing a ~week of your life into developing the muscle memory for it.</em></blockquote><blockquote><a href="https://github.com/iggredible/Learn-Vim"><em>LearnVim</em></a><em> is probably a good starting point if you’re interested</em></blockquote><h3>CMake</h3><p><a href="https://cmake.org/">CMake</a> initially isn’t a nice build system to use, but it’s the most widespread &amp; well-adopted for C/C++, so it’s worth to stick to it. Also, it’s <a href="https://64.github.io/cmake-raytracer/">turing-complete</a> (<em>is that a good thing? lol</em>), basically meaning you can do anything with it.</p><p>I’ve taken a look at <a href="https://bazel.build/">Bazel</a> for C++ — the syntax is definitely much nicer, but then again, it’s mostly only used in Google projects (for example, I’ve had to battle with <a href="https://xallt.github.io/posts/connecting-mediapipe-cmake/">its usage in Mediapipe</a>), and the syntax sugar leads to abstractions that are hard to debug once something goes wrong.</p><p>The very minimal example of CMakeLists.txt:</p><pre>cmake_minimum_required(VERSION 3.10)<br>project(lib)<br>include_directories(${CMAKE_SOURCE_DIR})<br>file(GLOB SOURCES *.cpp)<br>add_executable(cct_tests ${SOURCES})</pre><p>This works in a file setup like:</p><pre>- main.cpp<br>- lib.hpp<br>- lib.cpp<br>- CMakeLists.txt</pre><blockquote><em>Understanding CMake basics is not trivial — I only actually grasped it after a month of close work with it (and wrote </em><a href="https://xallt.github.io/posts/cmake-is-a-pain-in-the-ass/"><em>some notes</em></a><em> about it). But I believe you can achieve this understanding </em>much faster<em>.</em></blockquote><blockquote><em>I found this article about </em><a href="https://cliutils.gitlab.io/modern-cmake/chapters/basics.html"><em>CMake Basics</em></a><em> that seems to be written in a more human way than usual, might be a good starting point.</em></blockquote><p>For convenience, in all my C++ projects I have a build.sh that looks like this:</p><pre>ADDITIONAL_FLAGS=&quot;-DCMAKE_EXPORT_COMPILE_COMMANDS=1&quot;<br>BUILD_TYPE=&quot;Release&quot;<br>if [ &quot;$DEBUG&quot; = &quot;1&quot; ] || [ &quot;$DEBUG&quot; = &quot;true&quot; ]; then<br>    ADDITIONAL_FLAGS=&quot;$ADDITIONAL_FLAGS -DCMAKE_CXX_FLAGS=&#39;-fsanitize=address&#39; -DCMAKE_C_FLAGS=&#39;-fsanitize=address&#39; -DCMAKE_EXE_LINKER_FLAGS=&#39;-fsanitize=address&#39;&quot;<br>    BUILD_TYPE=&quot;Debug&quot;<br>fi<br><br>mkdir build<br>cd build<br>cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE $ADDITIONAL_FLAGS<br>make -j$(nproc)</pre><p>What this does is:</p><ul><li>By default, running ./build.sh will simply build your project, and also generate a compile_commands.json (about which I&#39;ll talk in the <strong>clangd</strong> section)</li><li>Running it like DEBUG=1 ./build.sh will enable running the debugger on the compiled executable, and enable the <a href="https://en.wikipedia.org/wiki/Code_sanitizer">sanitizer</a></li></ul><h3>Linting: clangd</h3><p><a href="https://clangd.llvm.org/">Clangd</a> is a <a href="https://microsoft.github.io/language-server-protocol/">language server</a> for C/C++ (and more) which integrates well if you’re using <a href="https://clang.llvm.org/">clang</a> for compilation (which I kinda recommend)</p><blockquote><em>If you are using </em><a href="https://gcc.gnu.org/"><em>GCC</em></a><em> as your compiler, you can either:</em></blockquote><blockquote>- Configure <a href="https://stackoverflow.com/questions/62624352/can-i-use-gcc-compiler-and-clangd-language-server">clangd to work with gcc</a></blockquote><blockquote>- Use <a href="https://code.visualstudio.com/docs/editing/intellisense">Intellisense</a> which also <a href="https://code.visualstudio.com/docs/cpp/configure-intellisense#_compilecommandsjson-file">uses compile_commands.json</a> the wonders of which I’ll explain below</blockquote><p>A very common issue that I encountered while setting up C++ projects — the linter just doesn’t understand where to search for your header .h/.hpp files / where to find the libraries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJ3On_kJyYnDASU_aVE8LQ.png" /><figcaption>Some examples of things that the linter gets weirdly wrong</figcaption></figure><p>But your compiler can provide your linter with those hints — just add -DCMAKE_EXPORT_COMPILE_COMMANDS=1 to your CMake flags (as in the build.sh script in the <strong>CMake</strong> section), and then setup a .clangd at the root of your project with</p><pre>CompileFlags:<br>  CompilationDatabase: build/</pre><p>And <em>voila</em>, your linter perfectly understands your codebase! (<em>Given that it actually compiles</em>)</p><p>Clangd also has <a href="https://clangd.llvm.org/features#clang-tidy-checks">clangd-tidy</a> with advanced code checks — to enable, add this to the .clangd file:</p><pre>CompileFlags:<br>  CompilationDatabase: build/<br>  ClangdTidy:<br>    Add: modernize-*</pre><p>All available <strong>clangd-tidy</strong> checks are <a href="https://clang.llvm.org/extra/clang-tidy/checks/list.html">here</a>.</p><blockquote><em>After every </em><em>.clangd update or major change to the build setup, you&#39;ll need to </em><strong><em>reload</em></strong><em> the IDE for the linter to see the changes</em></blockquote><h3>Debugging</h3><p>As mentioned, the <a href="https://open-vsx.org/extension/vadimcn/vscode-lldb">CodeLLDB</a> provides very simple debugging support. However, in VSCode for debugging you need to set up a launch.json file -- my template is:</p><pre>{<br>    &quot;version&quot;: &quot;0.2.0&quot;,<br>    &quot;configurations&quot;: [<br>        {<br>            &quot;name&quot;: &quot;run_script&quot;,<br>            &quot;type&quot;: &quot;lldb&quot;,<br>            &quot;request&quot;: &quot;launch&quot;,<br>            &quot;program&quot;: &quot;${workspaceFolder}/build/run_script&quot;, <br>            &quot;args&quot;: [<br>                &quot;--input&quot;,<br>                &quot;lalala&quot;<br>            ],<br>        },<br>    ]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qA-JUWkjyJYmlBxXIgUPpA.png" /><figcaption>How the debugger looks. Very convenient, and snappy fast for C++</figcaption></figure><p><em>Originally posted on </em><a href="https://xallt.github.io/posts/c-programming-setup-for-noobs/"><em>https://xallt.github.io/posts/c-programming-setup-for-noobs/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c3c87df350e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CMake is a pain in the ass]]></title>
            <link>https://medium.com/@mitya.shabat/cmake-is-a-pain-in-the-ass-4ff0becb06aa?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ff0becb06aa</guid>
            <category><![CDATA[clangd]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[clang]]></category>
            <category><![CDATA[cmake]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 22:46:04 GMT</pubDate>
            <atom:updated>2025-07-02T22:46:04.906Z</atom:updated>
            <content:encoded><![CDATA[<p>I really dislike <a href="https://cmake.org/">CMake</a>. Until recently — when I started using it more, fought through the things that were confusing me, and now I dislike it <em>only moderately</em>.</p><p>I gathered some insights, a few of them generally about C++ development. Here’s an unordered list of my recommendations for your CMake journey.</p><ul><li><strong>Don’t try to start from scratch.</strong> A CMakeLists.txt file is not something you can write from scratch. You NEED a starting point. Example from online / something an LLM will generate for you initially. It&#39;s a waste of time to try to work from first principles - you need to have a working starting point to modify to adapt it to your needs.</li><li><strong>Learn how compiling works.</strong> Important concept — ALL code that the computer runs has to be compiled. If its your code, then all of it has to be referenced in your CMakeLists.txt. If there’s a library, you have to understand that the code of the library HAS to be somehow included in your final output</li><li><strong>There is no “correct” way.</strong> Just do things that worked. You HAVE to learn from examples, copy-paste their solutions, and NEVER think that “oh I did this in a dirty unsustainable way…” — NO. Stop that. EVERY way is dirty</li><li><strong>Copy-paste works.</strong> Just dump the code from libraries’ repos into your proejct. Hell, its even ok if you just copy the full source code of a library into a subdirectory of your repository. You can then cut out things you don’t need, simplify the compilation process, etc etc. It’s normal. You’re not working with <a href="https://news.ycombinator.com/item?id=19295253">cargo</a> — you won’t do it in a “clean” way.</li><li><a href="https://clangd.llvm.org/"><strong>clangd</strong></a><strong> as LSP</strong> (Language Server Protocol). Ask your LLMs (wherever you get them) how to set up <a href="https://clangd.llvm.org/design/compile-commands">compile_commands.json</a> and you will never have any issues with linting</li><li><strong>The </strong><strong>find_package command IS confusing.</strong> It IS black magic. You WILL have problems with it. Main recommendation — be very thorough when making sure the version of the library CMake is looking for is compatible with the one installed in your system</li><li><strong>How to find libraries in your system?</strong> Google and google and google where they <em>could</em> lie in your system. For some reason it’s hard to find library installations every time.</li><li><strong>Uhhh how do you <em>install</em> these libraries?</strong> Well if you’re lucky, you can do something like brew install opencv or whatever your package manager is. But also. Just build it. It does seem scary and like overkill, but turns out its much easier than trying to find the right version in your package manager.</li><li><strong>Yes, the syntax is terrible.</strong> Yes, the documentation is hideous. At this point, I never read the docs, it’s only a waste of time there. Just accept it and move on — ask LLMs, look for examples on github, etc.</li><li><strong>A </strong><strong>build.sh script.</strong> Have it do all the cmake commands for you, highly recommend. Easy to then expand it with downloading other libraries / setting some CMake flags related to debugging / etc</li><li><strong>You’re a builder, don’t try to do things “nice”.</strong> CMake is one of those tools — you tweak until it works, forget it, until you quickly need to tweak something again. If you think something is ugly about how your build is set up, then soon enough you’ll see the cracks show. And <strong>that’s</strong> when you’ll actually understand the architecturally sound way to fix that. Don’t try to over-engineer in the beginning</li></ul><p><em>Original post at </em><a href="https://xallt.github.io/posts/cmake-is-a-pain-in-the-ass/"><em>https://xallt.github.io/posts/cmake-is-a-pain-in-the-ass/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ff0becb06aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deriving the formula for the homography matrix]]></title>
            <link>https://medium.com/@mitya.shabat/deriving-the-formula-for-the-homography-matrix-7834f7351b97?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/7834f7351b97</guid>
            <category><![CDATA[3d]]></category>
            <category><![CDATA[homography]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Sat, 28 Dec 2024 13:13:17 GMT</pubDate>
            <atom:updated>2024-12-28T13:13:17.910Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently at work I was researching ML approaches to image matching, specifically <a href="https://arxiv.org/abs/1911.11763">SuperGlue</a> / <a href="https://arxiv.org/abs/2406.09756">MAST3R</a> / <a href="https://arxiv.org/abs/2304.03608">ALIKED</a> and some similar methods.</p><blockquote><em>The interesting part in all this was to find out that </em><a href="https://arxiv.org/abs/1911.11763"><em>SuperPoint</em></a><em> / </em><a href="https://arxiv.org/abs/1911.11763"><em>SuperGlue</em></a><em> are trained on synthetic data, and then in a self-superviser manner, without needing some sort of smart labeling procedure.</em></blockquote><p>Inevitably, both of these methods being trained in a supervised manner, they need a sufficiently big dataset of Ground-Truth points pairs between a large corpus of images. I looked at what kind of data <a href="https://arxiv.org/abs/2112.02906">ALIKE</a> specifically is trained on, and saw that one of the datasets provides images of planes with annotated true Homograhy transformation between cameras.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kdmsbah-5sHYVNun5gSuSw.png" /><figcaption><em>Mention of the HPatches dataset in the ALIKE paper</em></figcaption></figure><p>Now, I’ve of course heard about homographies before — — that’s the matrix that, for a given plane, describes how to match a point on one camera with a point on another camera if they’re observing the same point on that plane.</p><p>But after looking at this, and reviewing all my knowledge, I thought… why does a simple matrix work? Why is remapping a pixel from one camera to the other, given they’re looking at a plane, describable with a single matrix (in homogeneous coordinates)?</p><p>This was leaving me dumbfounded because I couldn’t simply come up with an intuitive explanation of why we couldn’t apply some kind of similar assumption to any other shape. If two cameras looked at a sphere instead of a plane, would the mapping of pixels from one camera to the other also be describable with a linear matrix? Of course not, the projection of rays from a camera to a sphere is a very non-linear operation, so why would the relation of matching pixels between two cameras be linear in this case?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pi_KdxZ_UCzyoI375iU7kQ.png" /><figcaption><em>Mapping between cameras, in the case of a sphere and a plate</em></figcaption></figure><p>Anyways, I started jumping through various online resources about what homographies really are but none really satisfied my need to understand the underlying logic.</p><p>Some resources did provide a sufficient proof for existence of a homography matrix and it being linear, but they did it through just proving the formula of deriving the homography matrix through 4 point correspondences between 2 cameras. And then just by the ability to express any other point on the plane as a linear combination of those 4 points, the matrix holds true for all points on the plane.</p><p>But that feels like cheating — — I wanted to get a proof / formula irrespective of the particular points, just from the camera parameters / plane parameters alone.</p><p>So, here’s my pretty detailed derivation of the formula for the homography matrix, given just the camera/plane parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4sh3MDcdSUy46inB5qL23g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4sh3MDcdSUy46inB5qL23g.png" /><figcaption>The derivation</figcaption></figure><p>Now this is what I’m talking about!</p><p>Going through this process did build a seed of intuition about homographic transformations in me, and why they’re linear (up to a scale, i.e. in homogeneous space!): if you parameterize the plane the way I did — — it’s the most linear thing ever. I.e. the generator function for the plane points is linear (just take literally any 2D point, convert to a homogeneous point and multiply by a 3x3 matrix). All of this kinda leads to the idea that it probably is linear.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7834f7351b97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Obsidian link aggregator]]></title>
            <link>https://medium.com/@mitya.shabat/obsidian-link-aggregator-a52e04af67f3?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/a52e04af67f3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[obsidian]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Fri, 22 Dec 2023 07:20:55 GMT</pubDate>
            <atom:updated>2023-12-22T07:20:55.118Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally posted at </em><a href="https://xallt.github.io/posts/obsidian-link-aggregator/"><em>https://xallt.github.io/posts/obsidian-link-aggregator/</em></a></p><p>I’m a big fan of the idea of preserving as many “useful” links as possible. A while ago I managed to educate myself about a lot of things in Computer Graphics and Machine Learning because of the great resources I stumbled upon online.</p><p>Maybe if I keep all the links I find interesting / useful, I’ll be able to share them with someone who might find them really helpful.</p><p>All of this motivated me to store everything I found interesting in my Obsidian Vault, and also make a script that would turn them into a biig table of all the links.</p><p>Each link I find interesting goes <strong>into its own note</strong>. I mark it’s type in the frontmatter as either “link”, “tool”, “library”, or whatever else I have. Each of those notes also has a “link” frontmatter property for the link itself.</p><blockquote><em>You can read more about my Obsidian Vault structure here:<br></em><a href="https://xallt.github.io/posts/obsidian-useful-scripts/">https://xallt.github.io/posts/obsidian-useful-scripts/</a></blockquote><p>I use <a href="https://blacksmithgu.github.io/obsidian-dataview/">Dataview</a> to collect all my relevant notes into a big table, using this Javascript snippet:</p><pre>```dataviewjs<br>const link_pages = dv.pages(&#39;&quot;Notes&quot; or &quot;Definitions&quot;&#39;).filter((page) =&gt; (page.type == &quot;link&quot; | page.type == &quot;tool&quot;));<br>async function load_page(page) {<br>    return await dv.io.load(page.file.path);<br>}<br>function get_description(file_content) {<br>    const file_content_lines = file_content.split(&#39;\n&#39;);<br>    const link_line_idx = file_content_lines.findIndex(line =&gt; line.startsWith(&quot;## Link: &quot;));<br>    if (link_line_idx == -1) {<br>        return &quot;&quot;;<br>    }<br>    const file_description_lines = file_content_lines.slice(link_line_idx + 1);<br>    return file_description_lines.join(&quot;\n&quot;);<br>}<br>dv.table(<br>    [&quot;Name&quot;, &quot;Link&quot;, &quot;Tags&quot;, &quot;Description&quot;, &quot;Type&quot;],<br>    await Promise.all(link_pages.map(async (page) =&gt; [<br>        page.file.name,<br>        page.link,<br>        page.file.outlinks.join(&quot;, &quot;),<br>        get_description(await load_page(page)),<br>        page.type<br>    ]))<br>)<br>```</pre><p>And then I use this <a href="https://github.com/metawops/obsidian-table-to-csv-export">Table to CSV Exporter</a> plugin to turn the Dataview table into a CSV table that can be imported into Notion.</p><p>The latest version of my link aggregator is here: <a href="https://rare-save-0fa.notion.site/6eedcf7b68b9454986b894456f165df2?v=8ef4d2426ec14874beb2bdd405190711">https://rare-save-0fa.notion.site/6eedcf7b68b9454986b894456f165df2?v=8ef4d2426ec14874beb2bdd405190711</a></p><p>I should eventually work on either exporting this table automatically or integrating it into the website in a nicer way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a52e04af67f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My overview of LRM]]></title>
            <link>https://medium.com/@mitya.shabat/my-overview-of-lrm-5c7ada74119c?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c7ada74119c</guid>
            <category><![CDATA[3d-reconstruction]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nerf]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Fri, 17 Nov 2023 09:50:17 GMT</pubDate>
            <atom:updated>2023-11-17T09:50:17.264Z</atom:updated>
            <content:encoded><![CDATA[<p>Original version of the post is on <a href="https://xallt.github.io/posts/large-reconstruction-model-overview/">https://xallt.github.io/posts/large-reconstruction-model-overview/</a></p><h3>Introduction</h3><p>I’ve been updating myself on the most major advancements in the field of 3D reconstruction and text-to-3D over the past year, and I’ve seen <strong>lots</strong> of tricks to improve performance, reformulate the task in various ways, inserting components from different fields of Machine Learning, and so on.</p><p>Recently I saw a paper that described a method called <a href="https://yiconghong.me/LRM/">Large Reconstruction Model</a> (LRM) that generates a 3D object from a single image. It just blew my mind with how things like this are possible now. Largely because of the enormous 3D datasets available — <a href="https://objaverse.allenai.org/">Objaverse</a> and <a href="https://gaplab.cuhk.edu.cn/projects/MVImgNet/">MVImgNet</a></p><p>Initially I thought I’d just make a streamlined post with my thoughts on the topic. <br>Then I thought I wanted to make one large post describing many concepts in 3D generative models — but decided that’s too much for one post, and I’ll burn out before writing something actually good. So I’ll focus on overviewing just this paper I found fascinating.</p><h3>Overview</h3><p>So the idea of LRM is a lot simpler compared to those of MVDream / <a href="https://mrtornado24.github.io/DreamCraft3D/">DreamCraft3D</a> / etc. which utilize Score Distillation Sampling (from the <a href="https://dreamfusion3d.github.io/">DreamFusion</a> paper).</p><p>In this paper we’re simply training a model that, given a single input image, predicts a <a href="http://tancik.com/nerf">NeRF</a> of the 3D object. <strong>That’s it</strong>. That’s the idea. The rest is architectural / implementation details. I’ll explain why this is amazing later.</p><p>Let’s pull up the image describing their model architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pFc1V1tdyBLbkh0g.png" /><figcaption><em>LRM architecture from the paper</em></figcaption></figure><p>This is just for reference — it’s <em>some</em> kind of neural network that just does “Image -&gt; NeRF”. How a NeRF can be regressed with a model I’ll explain <a href="https://markdown-to-medium.surge.sh/#nerf-for-3d-representation">here</a>.</p><p>Let’s start with how <em>whatever this is</em> is trained.</p><h3>How LRM is trained</h3><blockquote><em>All variable names are improvised by me, don’t try to look for corresponding formulas/variables in the paper</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*hJD0IUzqxhZ7kyFnqv_eMg.png" /></figure><p>The way to train this model is pretty trivial if we have the required data: we are trying to solve the image-to-3D issue, i.e. we <strong>want to know the mapping from 2D to 3D</strong>. BUT — for any 3D object <strong>we know the true mapping from 3D to 2D</strong> (given camera parameters) — it’s the render of the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*wHqAWQJ1rqJ9jZZgw4rdag.png" /></figure><p>So let’s just get a dataset of 3D objects, get 2D renders of them, and train the model to do the opposite!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*MTLFu5fiL1lA5UZEiHhbBA.png" /></figure><p>Though we didn’t specify one thing yet — how are we going to compare the Ground Truth 3D object with the estimated 3D object? These two aren’t really comparable <strong>directly.</strong></p><p>Then how about <strong>indirectly</strong> — via their <strong>renders</strong>? If two objects looks the same from all sides, you can pretty much consider them identical. We’ll have to use more camera parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSCEVLvovSkzzbDLuBoeUw.png" /></figure><p>Even though our loss is just comparing two images, sampling many more renders and minimizing this loss for many-many sampled 3D objects will result in our model producing faithful 3D reconstructions.</p><p>As always, the tougher the ML task is, the more &amp; higher-quality data we need. LRM in particular trains on huge <a href="https://objaverse.allenai.org/">Objaverse</a> and <a href="https://gaplab.cuhk.edu.cn/projects/MVImgNet/">MVImgNet</a> that appeared relatively recently, so it’s no wonder it got to this level of quality and consistency.</p><p>Ok, we have the understanding of what this model is trained to do.\ This was the most fascinating part of this method to me — it’s just <strong>so straightforward</strong>, compared to Score Distillation Sampling methods that <strong>rely on a pretrained diffusion model</strong>, do various tricks with it, etc.</p><p>Now model architecture itself — it has crucial ideas too.\ Lots of scary blocks, so let’s go component by component.</p><h3>NeRF for 3D representation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yxyc6NaIOdNLs63G.png" /><figcaption><em>A NeRF is predicted via regressing triplanes</em></figcaption></figure><p>Just like <em>most</em> of the current state-of-the-art Image-to-3D/Text-to-3D approaches, this paper generates an object represented as a NeRF. It does so by <strong>regressing the planes</strong> for the <strong>Triplane Encoder</strong> that is introduced in <a href="https://apchenstu.github.io/TensoRF/">TensoRF</a>.</p><p>This idea of regressing a NeRF from an input isn’t new — it’s very often used in 3D GANs, where we’d like to generate a 3D object from a latent code. <a href="https://universome.github.io/epigraf">EpiGRAF</a> is a good example — it uses a backbone very similar to StyleGAN2 to generate the 3 embedding images that are reshaped into this Triplane structure.</p><p>The MLP is the same for every object — only the Triplane features change, therefore they are the ones driving the geometry &amp; appearance, and the MLP is trained to interpret all those features.</p><h3>Image Encoder</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E7EtNjW-G5d-Yvig.png" /><figcaption><em>Image encoder architecture</em></figcaption></figure><p>Almost always when processing a single image with some type of Neural Network, we want to extract <em>meaningful</em> features for future processing. This paper goes the <strong>Transfer Learning</strong> path and just uses the image encoder from <a href="https://arxiv.org/abs/2104.14294">DiNO</a> (very powerful image embedder <strong>trained with self-supervision</strong>). Not much else to describe here.</p><h3>Injecting image features into the Triplane</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PFt7E5n84_xWlrqx.png" /><figcaption><em>Cross-Attention to integrate image features into the triplane</em></figcaption></figure><p>So, on the left here you can see <strong>Learnable positional encodings</strong> with the shape (3x32x32)x1024 — you can maybe guess that these positional embeddings are also a TensoRF Triplane, i.e. the 3 images comprising such a Triplane. I called this section <strong>“Injecting image features into the Triplane”</strong> because we aren’t really predicting those Triplane images — we’re <strong>modifying existing ones via Cross-Attention</strong>.</p><p>The encoded camera parameters are also injected in this decoder, though I don’t find it interesting explaining how exactly they are injected. They just are — to <strong>inform the Cross-Attention layers of the n’Point of View</strong> of the input image.</p><p>Looking at how this transformer with Cross-Attention is implemented isn’t really that informative:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*zwOG1RrK34AWKCrD.png" /><figcaption><em>The formulas for a single Image-to-Triplane layer</em></figcaption></figure><p>BUUT knowing that there’s 16 layers of this Cross/Self-Attention does make an impression that we’re <strong>meta-learning Score Distillation Sampling</strong>, i.e. the Attention layers <strong>simulate the distillation of image features</strong> into 3D.</p><blockquote><em>This is the paper I was thinking about: </em><a href="https://arxiv.org/abs/2212.07677"><em>https://arxiv.org/abs/2212.07677</em></a><em> \ Basically authors show that Transformers out of Self-Attention blocks resemble </em>“mesa-optimizers”<em>, i.e. modify the input features at every layer to minimize some objective. Didn’t read it through though, just saw a summary of this somewhere 🤪</em></blockquote><h3>Noteworthy Technical details</h3><ul><li>Ground-truth camera parameters $\mathbf{c}$ are only injected into the Image-to-Triplane decoder during training. During inference, the camera features are replaced with an encoding of the default, fixed camera parameters</li><li>The loss not only has an L2 loss inside, but also an LPIPS loss, often referred to as a <strong>Perceptual loss</strong>. Empirically, minimization of just the L2 leads to blurriness, but LPIPS loss compares features related to local structures, therefore minimizing it leads to better preservation of edges. And an ablation study shows that removing it results in a drop of all metrics.</li><li>Instead of sampling ground-truth renders of data during training, authors sample 32 renders of each object as a pre-processing stage, and then train with those renders only, for optimization purposes</li><li><strong>My favorite</strong> — it takes a looooot of hardware to train such a large model on so much data. For them it took <strong>128 A100s training for 3 days</strong>, on a <strong>batch size of 1024</strong>. Nowadays this may seem like a normal workload for a Computer Vision lab, but it’s still mind-boggling to me</li><li>They use <strong>deferred back-propagation</strong> from <a href="https://www.cs.cornell.edu/projects/arf/">ARF</a> , which I learned about just while writing this post. Definitely recommend reading Section 4.2 from <a href="https://drive.google.com/file/d/19HmB8Ls_H_3higF_QOHrIWu9hISXVIwZ/view">their paper</a> that explains how they optimize NeRF back-propagation</li></ul><blockquote><em>To save computational cost in training, we resize the reference novel views from 512x512 to a randomly chosen resolution between 128x128 and 384x384 and only ask the model to reconstruct a randomly selected 128x128 region. With this design, we can possibly increase the effective resolution of the model.</em></blockquote><ul><li>Basically, the loss is actually computed on patches</li><li>An ablation study shows that training without the real images from MVImgNet rapidly drops all of the metrics. Presumably because they have a lot more lighting/size/camera pose variation (though if they sample cameras themselves for Objaverse, why do they say they don’t have enough variation?)</li></ul><h3>Conclusion</h3><p>Again, I love how straightforward this approach is compared to the usual Score Distillation Sampling way. And how so much is possible if you have enough GPUs.</p><p>Please, if you have any feedback on the post, I’d love to hear it! The comments under the post should work, or you can DM me on <a href="https://twitter.com/Xallt_">Twitter</a> / <a href="https://t.me/Xallt">Telegram</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c7ada74119c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[libffi.so.7 not found after Linux update]]></title>
            <link>https://medium.com/@mitya.shabat/libffi-so-7-not-found-after-linux-update-1713a4b65b45?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/1713a4b65b45</guid>
            <category><![CDATA[arch-linux]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Thu, 09 Nov 2023 08:46:48 GMT</pubDate>
            <atom:updated>2023-11-09T08:47:02.062Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently ran a global update of my system by executing</p><pre>sudo pacman -Syu</pre><p>One of my work pyenv environments contained scipy==1.5.4</p><p>Running import scipy.ndimage as nd produced this error:</p><pre>ImportError: libffi.so.7: cannot open shared object file: No such file or directory</pre><p>Which meant that the recent Linux update removed libffi version 7 from the system.</p><h3>Solution</h3><p>The solution was just to install the version I needed</p><pre>git clone https://aur.archlinux.org/libffi7.git<br>cd libffi7<br>makepkg -si</pre><p>I found this solution initially on lakur’s website: <a href="https://lakur.tech/2021/10/21/arch-linux-cannot-find-shared-library-libffi-so-7/">https://lakur.tech/2021/10/21/arch-linux-cannot-find-shared-library-libffi-so-7/</a></p><p><em>Originally posted on </em><a href="https://xallt.github.io/posts/libffi-7/"><em>https://xallt.github.io/posts/libffi-7/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1713a4b65b45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing my website after a recent Github Pages overhaul]]></title>
            <link>https://medium.com/@mitya.shabat/fixing-my-website-after-a-recent-github-pages-overhaul-46c06a0f282d?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c06a0f282d</guid>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Thu, 09 Nov 2023 08:10:34 GMT</pubDate>
            <atom:updated>2023-11-09T08:10:34.773Z</atom:updated>
            <content:encoded><![CDATA[<p>So recently I started being a bit more active with personal projects — I did a paid project on the side, I decided to make a C++ hand tracking app on top of Mediapipe for fun, I started upgrading my Obsidian scripts again, I became just a bit more active with my posts on Telegram.</p><p>So I decided to check out my Github Pages website that I made like 1.5 years ago, and then completely forgot about. <br><strong>TLDR</strong>: it wasn’t up, even though I didn’t change <strong>anything</strong> in those 1.5 years.</p><p>Well, turns out about a year ago Github <a href="https://github.com/orgs/community/discussions/29250#discussioncomment-3384692">updated their default guidelines</a> for releasing Github Pages websites. It shouldn’t have broken anything, but I guess some vulnerabilities &amp; other issues accumulated in my build workflow, and the workflow re-ran at some point and broke.</p><p>Github has good tutorials for pretty much everything, even for setting up <a href="https://docs.github.com/en/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages">your own Github Pages workflow</a>. <br> However, the GitHub actions used in these examle tutorials, in particular actions/upload-pages-artifact and actions/deploy-pages were barely explained in the article, neither can you make sense of them while looking at their respective repositories <br> They provide all their examples assuming you build with Jekyll, which wasn&#39;t the case for me - my website is built with Eleventy, and I didn&#39;t find any tutorials on how to combine Eleventy with the new Github Pages. So I had to <strong>actually understand</strong> how these actions/upload-pages-artifact and actions/deploy-pages worked.</p><p>So, I’ll quickly break down the key concepts that were hard for me to pick up while figuring out the new workflows:</p><ul><li>The actions/deploy-pages that needs to be run at the end of your publishing workflow operates with some kind of artifact called github-pages.</li><li>You <strong>do not</strong> need to know how this artifact system works — you only need to know that any artifact is produced via the special actions/upload-artifact action.</li><li>actions/upload-pages-artifact makes a call to actions/upload-artifact inside</li><li>actions/upload-pages-artifact takes in a parameter called path which should have your built static website in it. For me it was &quot;docs/&quot;, so the root of my website was in &quot;docs/index.html&quot;. This action converts your built static website into just the github-pages artifact that actions/deploy-pages needs.</li></ul><p>With this in mind, it should be clear that the sequence of steps upload-pages-artifact -&gt; deploy-pages just publishes your website built at path to Github Pages.</p><p>Hope this clears things up!</p><p><em>Originally published at </em><a href="https://xallt.github.io/posts/my-github-pages-overhaul/">https://xallt.github.io/posts/my-github-pages-overhaul/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46c06a0f282d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting Mediapipe with CMake for my own Hand Tracking app]]></title>
            <link>https://medium.com/@mitya.shabat/connecting-mediapipe-with-cmake-for-my-own-hand-tracking-app-f3e57dc14b8d?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e57dc14b8d</guid>
            <category><![CDATA[mediapipe]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[cmake]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Thu, 09 Nov 2023 08:06:39 GMT</pubDate>
            <atom:updated>2023-11-09T08:19:35.695Z</atom:updated>
            <content:encoded><![CDATA[<p>Original version of the post is on <a href="https://xallt.github.io/posts/connecting-mediapipe-cmake/">https://xallt.github.io/posts/connecting-mediapipe-cmake/</a></p><h3>Motivation</h3><p>When thinking about applications of good Hand Tracking, my imagination is just going all over the place. Stuff like: UI interaction in AR devices (btw Quest 2/3 hand tracking <a href="https://www.youtube.com/watch?v=j77tfU5jfgw">is fantastic</a>), or <a href="https://www.8thwall.com/blog/post/126815603359/wave-hello-to-hand-tracking">fun filters</a>, or controlling smart home devices with your hands.</p><p>it’s kind of my dream to eventually work on AR apps, especially those with hand interaction, so I gathered myself and started working on a Hand-Tracking app from scratch (wanted to get <em>hands-on experience</em> (lol))</p><p>The idea was to create a simple UI to play around with webcam Hand Tracking. Just wanted to get creative — feel like spiderman (shooting webs?) / a mage (summoning fire?) / control the PC cursor.</p><p>I knew about <a href="https://developers.google.com/mediapipe">Mediapipe</a> for a while now, and knew it had a Python API. So I started there — and implemented simple Hand Tracking in Python using that API. <br>It was a whole other journey for me to implement a tracker in python, because I took the time to make it actually efficient — have separate processes for:</p><ul><li>reading frames from the camera</li><li>processing them with the API</li><li>displaying the results with `cv.imshow`</li></ul><p>(for some reason I went with multi-processing and not multithreading?).</p><p>It’s a whole other journey deserving of its own post.</p><p>Doesn’t matter — it was still slow. Python is slow + the Mediapipe Python API only provides CPU inference. And I wanted to squeeze out the maximum FPS I could get by running on the GPU.</p><p>So I gathered the courage to work with C++ to get the best performance. My first 4–5 years of programming were all C++ (back in 2015–2019), but then I started doing ML and completely transitioned into Python. And so, my C++ knowledge and muscle memory slowly faded away… but I’m going to get it back, hell yeah🚀</p><p>This post in particular is about the first stage of the development of this app, where I was setting up Mediapipe’s Hand Tracking as a library for my app. There *should be* eventually a post about the app itself and the creative things I’ve done with it.</p><h3>What’s so cool about Mediapipe?</h3><blockquote><strong>TLDR</strong>: Mediapipe is a framework for compiling your ML Inference pipelines into binaries runnable on any platform (Android / iOS / Desktop)</blockquote><p>Suppose you work&amp;work your ass off on a Neural Network for processing <em>some</em> kind of data — images / text / audio. Deploying it to run in the real world in real apps is a whole other struggle:</p><ul><li>You want it to work on different platforms: Android, iOS, Desktop, etc.</li><li>You want it to work fast — your Python code is <a href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/gpp-python3.html">100X</a> slower than C++, and C++ isn’t even the most efficient sometimes (<a href="https://blog.42yeah.is/cuda/2023/06/03/cuda.html">CUDA</a> exists)</li></ul><p>What can you do about that?<br>Well, you have <a href="https://onnx.ai/">ONNX</a> / <a href="https://www.tensorflow.org/lite">Tflite</a>. These are basically frameworks for exporting your trained Neural Networks in a format that can be run by various libraries on any device.</p><p>But those are only for the NN layers themselves, not for all the preprocessing/postprocessing that are also involved in your model inference. So, you want to package the whole thing — model + data processing.</p><p><a href="https://developers.google.com/mediapipe">Mediapipe</a> comes into the picture — it not only lets you compile code (C++ code though) including calls to NNs into a binary package <strong>runnable anywhere</strong> — it lets you define your processing+model as an arbitrarily complex <strong>graph of data flow</strong>. Each node is some processing operation, each edge is a packet of data flowing from one node to the other.</p><p>It comes with a fantastic tool for visualization of their graphs: <a href="http://viz.mediapipe.dev/">viz.mediapipe.dev</a>, you can look at some example graphs there</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*nZP4E62EFUHZYv_p.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*gCbvsw88xDJIL1wT.png" /><figcaption>A visualization of a graph &amp; a snippet of the graph’s definition</figcaption></figure><blockquote>While looking for other Mediapipe tools, I found out you can <a href="https://github.com/google/mediapipe/blob/master/docs/tools/tracing_and_profiling.md">upload your profiling log</a> to <a href="https://viz.mediapipe.dev/">viz.mediapipe.dev</a> and it will visualize both the graph, all the statistics, and also <strong>all intermediate states of each node?</strong> (not sure). Whatever that does, it looks fantastic</blockquote><h3>How do I use Mediapipe in my project?</h3><p>You can pretty much consider Mediapipe documentation to be <strong>non-existent</strong>. They have instructions how to compile their examples, and explanations of their core concepts, but very little help for creating your own graphs / using Mediapipe as a library.</p><p>Well, it kinda doesn’t seem like it if you browse their <a href="https://developers.google.com/mediapipe/framework/framework_concepts/calculators">Calculators Overview</a>. But after all that code , it’s still not clear how you would integrate your own calculator into a graph, compile that graph, use Tensorflow models other than their own. Or maybe Torch models?</p><p>There’s just so many components to consider, and honestly it’s not surprising that there is no single well-made documentation.</p><h4>Use Mediapipe within Python</h4><p>If you just need one/some of Mediapipe’s examples as a library for your app — you can use the extremely convenient <a href="https://developers.google.com/mediapipe/api/solutions/python/mp">Mediapipe Python API</a>!</p><p>And they have pretty well-documented examples, for example here’s one for running their facial landmark detection: <a href="https://developers.google.com/mediapipe/solutions/vision/face_landmarker/python](https://developers.google.com/mediapipe/solutions/vision/face_landmarker/python)">https://developers.google.com/mediapipe/solutions/vision/face_landmarker/python</a></p><p>However, important note:</p><blockquote>The Python <strong>mp</strong> library only provides <strong>CPU</strong> inference of models</blockquote><p>If your app is in C++ or if you want fast GPU inference, the next section is for you.</p><h4>Actually integrating Mediapipe into C++</h4><p>If you want to have Mediapipe as a dependency in your project in any way, you <strong>WILL</strong> have to read the <a href="https://github.com/google/mediapipe">Mediapipe source code</a>. Sometimes C/C++, sometimes Protobuf <strong>.proto</strong> files, Bazel <strong>BUILD</strong> files, sometimes even Java code (idk why).</p><p>And I bet you’ll have to make a fork of Mediapipe and add some changes to the internal code/build files. It was inevitable for me, so I accepted the path of tweaking the source code.</p><p>When I started experimenting, I encountered this post which is a C++ Mediapipe mini-tutorial: <a href="https://www.it-jim.com/blog/mini-tutorial-on-mediapipe/">https://www.it-jim.com/blog/mini-tutorial-on-mediapipe/</a><br>It’s a short intro that shows how you would run a graph with your own calculator — helped me in the beginning when I was searching for resources on the topic.</p><p>I won’t be able to walk you through the whole source code and rid you of the pain that I went through. Or, I actually can — you can just look at my code:</p><ul><li><a href="https://github.com/Xallt/HandTrackingProject](https://github.com/Xallt/HandTrackingProject)">https://github.com/Xallt/HandTrackingProject</a> for the CMake project itself. At the moment of writing this post it’s on <a href="https://github.com/Xallt/HandTrackingProject/tree/5296fa80ca2dd90fb97e1f9ca557bb30e0033f71">this commit</a></li><li><a href="https://github.com/Xallt/mediapipe](https://github.com/Xallt/mediapipe)">https://github.com/Xallt/mediapipe</a> with my mediapipe fork. It’s added as a submodule inside of the HandTrackingProject repo</li></ul><h4>Bazel/CMake</h4><p>You can either have your project built with <a href="https://bazel.build/">Bazel</a>, which means you can simply add Mediapipe Bazel build files as a dependency in your build files. Or you’ll work with a different build system, which means you’ll have to figure out how to export a shared library with all the relevant data</p><p>I personally wanted to work with <a href="https://cmake.org/">CMake</a> for this project (because it’s widely used and probably the hardest to understand), so I went with the second option, which resulted in about 10 days of pain where I learned a lot about CMake, Bazel, and how C++ compilers work. But I got it to work!!</p><h3>Mitya Shabat on Twitter: &quot;I WON, I FUCKING WON. I GOT fudging MEDIAPIPE BAZEL-BUILT SHARED LIBRARY TO WORK WITH MY CMAKE PROJECT I&#39;m so happy. I started trying to link it together like 10 days ago. And I learned so much trying to make it work. Would definitely make a great post pic.twitter.com/Za4ElgjvGE / Twitter&quot;</h3><p>I WON, I FUCKING WON. I GOT fudging MEDIAPIPE BAZEL-BUILT SHARED LIBRARY TO WORK WITH MY CMAKE PROJECT I&#39;m so happy. I started trying to link it together like 10 days ago. And I learned so much trying to make it work. Would definitely make a great post pic.twitter.com/Za4ElgjvGE</p><p>look at how happy I was</p><p>If you want to actually understand the intricacies of C++ linking and Mediapipe, I recommend you go through this painful experience yourself 🙃.</p><p>And the rest of the insights stem from this decision of mine (because if I went with Bazel, I probably wouldn’t have wasted so much time)</p><h4>Exporting a shared library from Bazel</h4><p>When looking for existing projects integrating Mediapipe into CMake, I found this one called <a href="https://github.com/rajkundu/mediapipe/tree/master">LibMP</a>. I tried to set it up but it was based off of an old Mediapipe commit (7 months ago) so I didn’t want to bother with it. However, <a href="https://github.com/rajkundu/mediapipe/blob/master/mediapipe/examples/desktop/libmp/BUILD">their BUILD file</a> that exports a shared library gave me lots of hints on how I need to set up my BUILD file.</p><p>I wanted to run the GPU inferencing graphs, so my goal was to integrate the<strong> RunMPPGraph()</strong> from <a href="https://github.com/google/mediapipe/blob/master/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc">demo_run_graph_main_gpu.cc</a> into my app. That’s the first step anyway, I’d modify it to give me landmarks instead of images later on.</p><p>Initially this source file is treated as a library with a predefined <strong>main()</strong> in the corresponding Bazel <a href="https://github.com/google/mediapipe/blob/master/mediapipe/examples/desktop/BUILD">BUILD</a> file, but it isn’t created as an actual C++ library.</p><p>So, to be able to export the <strong>RunMPPGraph()</strong> function, but also for the Mediapipe hand tracking example to not break down, I did these things in order, checking after each step that everything compiles and runs as usual:<br>1. <a href="https://github.com/google/mediapipe/blob/master/mediapipe/examples/desktop/BUILD"><strong>fork</strong></a> &amp; clone &amp; compile &amp; run Mediapipe with their instructions:</p><ul><li>First, the <a href="https://developers.google.com/mediapipe/framework/getting_started/install">Hello World example</a></li><li>Then the <a href="https://developers.google.com/mediapipe/framework/getting_started/cpp">Hand Tracking example</a></li></ul><p>2. Break up the <strong>demo_run_graph_main_gpu.cc</strong> file into:</p><ul><li><strong>run_graph_main.h</strong>with header guards &amp; the declaration of the <strong>RunMPPGraph()</strong></li><li><strong>run_graph_main.cc</strong> with the source code for the <strong>RunMPPGraph()</strong></li><li><strong>demo_run_graph_main_gpu.cc</strong> with the <strong>main()</strong> from the older version of this file</li><li>And create an intermediate <strong>cc_library</strong> for <strong>run_graph_main.cc</strong> inside of this <a href="https://github.com/google/mediapipe/blob/master/mediapipe/examples/desktop/BUILD">BUILD</a> file accordingly</li></ul><p>3. Create a <strong>run_graph_main_linux.so</strong> target in the BUILD file with the Bazel rule <strong>cc_binary</strong> and flags <strong>linkshared=1</strong>, also add <strong>alwayslink=1</strong> to the <strong>run_graph_main</strong> Bazel target (important for when we’ll export the shared library)<br>4. Also, I changed the output result of <strong>RunMPPGraph()</strong> to be a <strong>bool</strong> instead of <strong>absl::Status</strong> so that I don’t have to have Abseil as a dependency in my project</p><p>There will be lots of ups &amp; downs in this process, you’ll have a fair deal of issues with OpenCV dependencies &amp; other libraries. Later there’ll be a section specifically for library issues.</p><p><strong>alwayslink=1</strong> has something to do with linking <strong>all</strong> of the files used by the build target. Not exactly sure, you can <a href="https://bazel.build/reference/be/c-cpp#cc_library.alwayslink">read the Bazel docs</a> for details.</p><blockquote><strong>IMPORTANT:</strong> Bazel isn’t capable of compiling static libraries without a <strong>main()</strong> function, so we are forced to make a <strong>shared</strong> library</blockquote><p>Ok, at this stage we should have something called <strong>run_graph_main_linux.so</strong> somewhere in the <strong>bazel-bin</strong> directory. Now let’s try to link it to our small CMake project</p><h4>Linking the Bazel-built shared library to a CMake project</h4><p>Now, let’s get to actually creating a CMake project with this shared library linked 🚀</p><blockquote>Again, and <strong>this is important</strong> — the key to success in these new projects is iterative small changes, <strong>git commit</strong>ting each one after you tested it. <br> <br>Otherwise, while on a rush of excitement you’re making lots of changes, one of those will break something. Likely you won’t be able to tell what exactly (because C++ error logs are either non-existent or trash), so you’ll have to roll everything back, discarding even good changes. Trust me, I’ve been there.</blockquote><p>Anyway, here’s the steps I took:</p><p>1. First, create a very simple Hello World <strong>main.py</strong> — just to confirm that something trivial compiles<br>2. Then, with the help of the internet of ChatGPT, create a CMake file that will compile this trivial <strong>main.py</strong>. CMake boilerplates are impossible to memorize, so yeah.<br>Also, here’s a great intro post to CMake: <a href="https://www.internalpointers.com/post/modern-cmake-beginner-introduction](https://www.internalpointers.com/post/modern-cmake-beginner-introduction).">https://www.internalpointers.com/post/modern-cmake-beginner-introduction.</a> There’s also lots&amp;lots of links to other posts in the bottom, maybe one of those will help you a lot.<br>3. Add the <strong>run_graph_main.h</strong> header and <strong>run_graph_main_linux.so</strong> to CMake, check that it compiles<br>4. Add <strong>#include “run_graph_gpu.h”</strong><br>5. Call <strong>RunMPPGraph()</strong></p><p>The steps 4&amp;5 are the most problematic ones — all the issues with file positioning, linking problems, etc. will come out here. Also the suddenly the model checkpoint can’t be found, the <strong>.pbtxt</strong> graph definition can’t be found, etc.<br>Good luck with figuring this out! 🙃</p><p>While debugging all the issues with missing libraries and conflicting library versions, two tools helped me out:<br>- <strong>nm -C {binary or shared library}</strong> lists all of the functions defined in the file<br>- <strong>ldd {shared library}</strong> lists all references from functions to corresponding libraries installed in your system</p><p>General advice about installing libraries in a later section.</p><p>Also, for some mysterious reason I <strong>had</strong> to have the <strong>bazel-bin</strong> directory under where my <strong>main</strong> executable lies? I just made a symlink, but it’s still confusing, and I don’t understand where in the source code it references <strong>bazel-bin</strong> specifically:</p><pre>ln -s ../dependencies/mediapipe/bazel-bin ./bazel-bin</pre><h4>Extracting landmarks from the graph</h4><p>After the previous steps, we should basically get the app as the Mediapipe Hand Tracking example (we literally run the same function). However, we want to play around with the landmarks ourselves.</p><p>Essentially, over a few commits I refactored the <strong>RunMPPGraph()</strong> function into a class with this interface:</p><pre>class MPPGraphRunner {<br> absl::Status InitMPPGraph(std::string calculator_graph_config_file)<br> absl::Status ProcessFrame(cv::Mat &amp;camera_frame, size_t frame_timestamp_us, cv::Mat &amp;output_frame_mat, std::vector&lt;NormalizedLandmarkList&gt; &amp;landmarks, bool &amp;landmark_presence)<br> absl::Status RunMPPGraph(std::string calculator_graph_config_file, std::string input_video_path, std::string output_video_path)<br>}</pre><p>However, there was a problem — in order to be able to <strong>#include</strong> this class signature, I’d need to have <a href="https://abseil.io/">Abseil</a> as dependency (<strong>absl::</strong> stands for the Abseil namespace). So I came up with a simple hack:</p><pre>class SimpleMPPGraphRunner {<br>   public:<br>    SimpleMPPGraphRunner();<br>    ~SimpleMPPGraphRunner();<br>    bool RunMPPGraph(std::string calculator_graph_config_file, std::string input_video_path, std::string output_video_path);<br>    bool InitMPPGraph(std::string calculator_graph_config_file);<br>    bool ProcessFrame(cv::Mat &amp;camera_frame, size_t frame_timestamp_us, cv::Mat &amp;output_frame_mat, std::vector&lt;LandmarkList&gt; &amp;landmarks, bool &amp;landmark_presence);<br><br>   private:<br>    void* runnerVoid;<br>};</pre><p>It’s basically a wrapper around the <strong>MPPGraphRunner</strong>, which is now entirely defined in <strong>run_graph_gpu.cc</strong>, so now <strong>MPPGraphRunner</strong> isn’t referenced as a type anywhere in the <strong>run_graph_gpu.h</strong> file — this way Abseil also isn’t required.</p><p>The <strong>runnerVoid</strong> is a pointer to the <strong>MPPGraphRunner</strong> class that I’d handle in the source file <strong>run_graph_gpu.cc</strong> like this:</p><pre>bool SimpleMPPGraphRunner::InitMPPGraph(std::string calculator_graph_config_file) {<br>    runnerVoid = (void *)new MPPGraphRunner();<br>    MPPGraphRunner &amp;runner = *(MPPGraphRunner *)runnerVoid;<br>    // ... rest of the code ...<br>}<br>bool SimpleMPPGraphRunner::ProcessFrame(cv::Mat &amp;camera_frame, size_t frame_timestamp_us, cv::Mat &amp;output_frame_mat, std::vector&lt;LandmarkList&gt; &amp;landmarks, bool &amp;landmark_presence) {<br>    MPPGraphRunner &amp;runner = *(MPPGraphRunner *)runnerVoid;<br>    // ... rest of the code ...<br>}</pre><h4>Polling nonexistent landmarks</h4><p>One of the painful issues that I encountered when I was also extracting landmarks from the graph instead of just the processed image — whenever both hands were off-screen, <strong>no packet with landmarks would be produced</strong> by the graph. And polling for the packet like this <strong>poller_landmarks-&gt;Next(&amp;packet_landmarks)</strong> would just <strong>freeze the whole app</strong>!</p><p>First off — when this started happening, it probably took me a whole day to debug, because it just quitely freezes (and I didn’t do small testable changes back then). So, <strong>do small changes</strong>!</p><p>When I figured out the issue was the polling, I found <a href="https://github.com/google/mediapipe/issues/1532">this issue on Github</a> that addresses this problem exactly. The solution was nice — add a boolean output in the graph that indicates whether landmarks will be returned this frame. The solution is basically described in the issue, I won’t go into detail here.</p><p>Now polling for the landmarks looks like this:</p><pre>poller_landmark_presence-&gt;Next(&amp;packet_landmark_presence);<br>landmark_presence = packet_landmark_presence.Get&lt;bool&gt;();<br>if (landmark_presence) {<br> poller_landmarks-&gt;Next(&amp;packet_landmarks);<br> landmarks = packet_landmarks.Get&lt;std::vector&lt;NormalizedLandmarkList&gt;&gt;();<br>}</pre><h3>Issues &amp; insights &amp; friends I made along the way</h3><p>I’m done with the structured part of the post where I describe how I made stuff work. Now I can get to even more detailed parts of the process — most notably, what worked and what failed.</p><h4>Installing C++ libraries</h4><p>Lots of the issues you’d come across during the set up of Mediapipe here, or of any other project honestly, look like this:</p><pre>could not load dynamic library &#39;libnvinfer.so.7&#39;</pre><p>or</p><pre>could not load dynamic library &#39;libopencv_videoio.so.4.2&#39;</pre><p>Well, for some reason it took me <strong>waaaay too long</strong> to realize that most of these are solved by just</p><pre>sudo apt-get install lib{library}-dev</pre><p>Of course, I’m on an Ubuntu-based system, if you’re Arch or whatever, can’t help you there (but it’s probably very similar).</p><p>If there’s a library like <strong>libcudnn.so</strong> missing (name starts with <strong>cu</strong>), which is basically part of CUDA, you’ll probably have to go to the Nvidia website and use their installer instructions. For me it was the <a href="https://developer.nvidia.com/cuda-12-2-0-download-archive">CUDA 12.2 Toolkit Downloads</a>.</p><p>Sometimes you may even have an issue where none of the library versions from your package manager work — whatever you install the build process complains that <strong>something is of the wrong version</strong>.<br>Aaand you can always just <strong>build from source</strong>! It’s a lot easier than I initially assumed.</p><p>For example, I had issues with OpenCV versions, so I decided at some point I’d just do an installation from source. It literally looked like this:</p><pre>git clone https://github.com/opencv/opencv.git<br>cd opencv<br>mkdir build &amp;&amp; cd build<br>cmake ..<br>make install</pre><p>Of course this may look scary and unreliable at first (it sure did look like that to me). But this series of commands:</p><pre>mkdir build &amp;&amp; cd build<br>cmake ..<br>make install</pre><p>Is one you’ll be very familiar with once you work with more CMake projects — it’s THE commands for building C++ libraries and installing them into your system.</p><p>Maybe at some point you learned about <strong>Makefile</strong>s separately from CMake — it’s a very simple minimalistic build system, which is good for beginners and small projects. CMake is good for bigger projects with dependencies that are harder to manage manually, and all it does — <strong>it literally just generates Makefiles for your project</strong>. So, the logic is:<br>1. Create a <strong>build </strong>directory where the <strong>Makefile</strong>s will be located together with all the helper files<br>2. <strong>cd</strong> into it, and call <strong>cmake ..</strong> which just says “generate <strong>Makefile</strong>s in this directory using the <strong>CMakeLists.txt</strong> from the directory <strong>..</strong>”<br>3. Then, run the <strong>install</strong> instruction from the Makefile, that compiles everything, and adds the header files (like <strong>opencv2/videoio.hpp</strong> which is basically the same as <strong>.h</strong>) and shared libraries (like <strong>libopencv_videoio.so</strong>`) to the directories where they’re supposed to be</p><h4>Wow, following installation instructions is useful</h4><p>In Mediapipe installation instructions for C++, there’s this <a href="https://developers.google.com/mediapipe/framework/getting_started/install#installing_on_debian_and_ubuntu">first section of installation instructions</a>, and in the 3rd step they specify how you need to change the <strong>opencv_linux.BUILD</strong> file if you have OpenCV&gt;=4 version.</p><p>Now, on a completely unrelated note 🙃 — when linking the <strong>run_graph_gpu_linux.so</strong> as in the section about linking, and calling <strong>RunMPPGraph()</strong>, I got errors like:</p><pre>(...): undefined reference to cv::VideoCapture::VideoCapture(int)<br><br>(...): undefined reference to cv::VideoCapture::~VideoCapture()<br><br>(...): undefined reference to cv::String::deallocate() ...</pre><p>And I checked with `ldd` that the linking inside of <strong>run_graph_gpu_linux.so</strong> point to the correct shared OpenCV libraries. At this point I’ve already looked at the instructions from Mediapipe to change their OpenCV dependency BUILD file, but I scratched that — it only changed the include directories for the headers, and headers don’t contain function definitions, so changing that now won’t add any function references that the linking complain about above.</p><p>WRONG — apparently by default (if you have OpenCV&gt;=4) it uses headers of an “older” version, that won’t break during compilation of a library, but will notice that something is wrong once you try to link those with functions (some kind of mismatch between older headers and newer libraries’ function interfaces?).</p><p>So yeah, setting a different <strong>-I</strong> flag during <strong>gcc</strong>compilation can fix the linking in your cpp app.</p><p>I found this post that should serve as a good introduction into what compilation&amp;linking are, if you’re new to this: <a href="https://www.learncpp.com/cpp-tutorial/introduction-to-the-compiler-linker-and-libraries/](https://www.learncpp.com/cpp-tutorial/introduction-to-the-compiler-linker-and-libraries/)">https://www.learncpp.com/cpp-tutorial/introduction-to-the-compiler-linker-and-libraries/</a></p><h4>“bazel query” just didn’t work</h4><p>There’s one thing that I just gave up on when debugging — trying to make <strong>bazel query</strong>. It’s a tool that is supposed to help you understand the dependencies in your Bazel project.</p><p>But it didn’t work — because mediapipe uses a command in Bazel that creates a “local repository”, which in this case was used (probably, not sure) for installing files specific for building for/on different systems, like this one:</p><pre>new_local_repository(<br>    name = &quot;windows_opencv&quot;,<br>    build_file = &quot;@//third_party:opencv_windows.BUILD&quot;,<br>    path = &quot;C:\\opencv\\build&quot;,<br>)</pre><p>And apparently to run <strong>bazel query</strong> it has to traverse the whole graph, which in this case requires it to run every creation of a local repository. But this one is specifically for windows, which means this command fails!</p><p>I tried just removing this command in particular, but there were just too many problems like this, and I decided to give up on this idea. Which was sad, because having a working <strong>bazel query</strong> could’ve sped up my debugging process back then.</p><h4>Errors not logging from inside “glcontext”</h4><p>The code for running a graph on the GPU has two instances of entering an “OpenGL context” which is required to move an image from the CPU to the GPU and back.</p><p>The problem was — there is some Abseil error handling inside of the context, but it just wouldn’t work. I manually checked — and whenever an error was returned, it would just be ignored. Still don’t know why, but I had to modify <a href="https://github.com/google/mediapipe/blob/master/mediapipe/examples/desktop/demo_run_graph_main_gpu.cc#L135">this line</a> to manually check the returned <strong>absl::Status</strong> instead of delegating it to the <strong>MP_RETURN_IF_ERROR</strong> macro.</p><p>And oh yeah, the macros in Mediapipe look horrendous.</p><h4>Understanding the macros</h4><p>There’s lots of usage of macros in the code, like these ones:</p><pre>MP_RETURN_IF_ERROR(graph.StartRun({}));</pre><p>or</p><pre>MP_ASSIGN_OR_RETURN(auto gpu_resources, mediapipe::GpuResources::Create());</pre><p>Which are veeery confusing at first. Well, best thing to do in this case — read the source code! Which here just means — read what these actually mean. The moment I did that, it became much easier to navigate the code.</p><p>All defined here: <a href="https://github.com/google/mediapipe/blob/master/mediapipe/framework/deps/status_macros.h](https://github.com/google/mediapipe/blob/master/mediapipe/framework/deps/status_macros.h)">https://github.com/google/mediapipe/blob/master/mediapipe/framework/deps/status_macros.h</a><br>Just had to look for “#define MP_RETURN_IF_ERROR” inside the github</p><h4>C++ in VSCode</h4><p>A couple words about C++ in VSCode — previously when doing stuff with C++ it was only small projects and I didn’t have many issues, but now this one had a pretty large Mediapipe and ImGui dependencies.</p><p><a href="https://code.visualstudio.com/docs/editor/intellisense">IntelliSense</a> is the VSCode plugin for C++ IDE features, and mostly it works well, but for me it failed on deeply-positioned files. I complained about it on Twitter, and one of the maintainers actually replied and was nice!</p><p>Here’s the thread: <a href="https://twitter.com/Xallt_/status/1714777777046503442](https://twitter.com/Xallt_/status/1714777777046503442)/">https://twitter.com/Xallt_/status/1714777777046503442</a><br>Didn’t report the issue to Github yet, but I <em>probably</em> will</p><p>And another note — C++ is generally a harder language to grasp than Python, but the IDE features (at least in VSCode) are a lot nicer, and I was reminded of how nice it is to have actual static types, and catch small issues in the code before you even try to run it.</p><h4>ChatGPT is a great help</h4><p>ChatGPT isn’t all that powerful — many times when asking it questions about the code, about my linking issues, or Bazel features, it didn’t respond with anything that was helpful.</p><p>However, when I asked it to explain to me about particular concepts either about CMake, or about how the compilation&amp;linking works… it was <strong>ok</strong>. But then I asked dumb questions one after the other, until we both <strong>converged to the exact piece of understanding that I was missing</strong>.</p><p>And lately that’s what I find most useful about it — it suddenly became a lot easier to grasp concepts that you find VERY hard. You just <strong>ask dumb questions one after another</strong> until you either <a href="https://en.wikipedia.org/wiki/Rubber_duck_debugging">rubber-duck</a> yourself into understanding where you were wrong, or until it points that out itself.</p><h4>Some great CLI tools</h4><p>I either learned, or was reminded of some great CLI tools:<br>- Already mentioned <strong>ldd</strong> and <strong>nm -C</strong> — they really were a great help during debugging<br>- Highly recommend installing <strong>locate</strong> — it literally just finds a file in your whole system. <strong>locate libopencv</strong> will give you the positions of all your installed OpenCV libraries. Also <strong>sudo updatedb</strong> if you added/removed files, and you want to update the <strong>locate</strong> index. <br>- <strong>tldr</strong> is probably the best CLI thing you’ll learn ever — it’s a superior version of <strong>man</strong>. Useful always. More about it here: <a href="https://github.com/tldr-pages/tldr](https://github.com/tldr-pages/tldr)">https://github.com/tldr-pages/tldr</a><br>- <strong>grep -Ril “cv::VideoCapture” .</strong> looks for lines containing this string in all files in your directory (and subdirectories)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e57dc14b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Slashed zeros]]></title>
            <link>https://medium.com/@mitya.shabat/slashed-zeros-91caed565ed2?source=rss-1cd15e865e14------2</link>
            <guid isPermaLink="false">https://medium.com/p/91caed565ed2</guid>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Шабат Дмитрий]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 20:00:16 GMT</pubDate>
            <atom:updated>2023-11-09T08:14:53.310Z</atom:updated>
            <content:encoded><![CDATA[<p>So when I was starting off creating this website of my own, I encountered a minor problem — my zeros were slashed</p><p>Here’s a comparison of before and after:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/0*q8IqyE4zip_RCO6Z.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/0*CMILxFrggpLsmkLt.png" /></figure><p>As I found out, the issue was with the template I was using — <a href="https://github.com/yinkakun/eleventy-duo">Eleventy-Duo</a><br>Digging into everything related to fonts, I found this CSS setting in the template:</p><pre>body {<br>  font-size: var(--text-lg);<br>  line-height: 1.54;<br>  color: var(--color);<br>  text-rendering: optimizeLegibility;<br>  -webkit-font-smoothing: antialiased;<br>  font-feature-settings: &#39;liga&#39;, &#39;tnum&#39;, &#39;case&#39;, &#39;calt&#39;, &#39;zero&#39;, &#39;ss01&#39;, &#39;locl&#39;;<br>  font-variant-ligatures: contextual;<br>  -webkit-overflow-scrolling: touch;<br>  -webkit-text-size-adjust: 100%;<br>  font-family: -apple-system,BlinkMacSystemFont,segoe ui,Roboto,Oxygen,Ubuntu,Cantarell,open sans,helvetica neue,sans-serif;<br>}</pre><p>Pay attention to this:</p><pre>font-feature-settings: &#39;liga&#39;, &#39;tnum&#39;, &#39;case&#39;, &#39;calt&#39;, &#39;zero&#39;, &#39;ss01&#39;, &#39;locl&#39;;</pre><p>As I found out, font-feature-settings is a CSS property for tweaking advanced typographic features</p><ul><li>Link to the resource: <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings">https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings</a></li></ul><p>And zero is apparently such a feature, made specifically for differentiating between 0 and O (zero and big &#39;o&#39;)<br> So if you encountered the same issue - unwanted slashed zeros, search for <strong>&#39;zero&#39;</strong> in your CSS files</p><p><em>Originally published at </em><a href="https://xallt.github.io/posts/slashed-zeros/">https://xallt.github.io/posts/slashed-zeros/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91caed565ed2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>