<?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 George Davila Durendal on Medium]]></title>
        <description><![CDATA[Stories by George Davila Durendal on Medium]]></description>
        <link>https://medium.com/@gdurendal?source=rss-6a9a11dd71c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ahMb4pZyYybq4s5mlPJP9g.png</url>
            <title>Stories by George Davila Durendal on Medium</title>
            <link>https://medium.com/@gdurendal?source=rss-6a9a11dd71c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:08:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gdurendal/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[Easily Deploy Python Computer Vision Models To The Web Using Hugging Face Spaces]]></title>
            <link>https://gdurendal.medium.com/easily-deploy-python-computer-vision-models-to-the-web-using-hugging-face-spaces-4065b6963786?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4065b6963786</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Tue, 24 May 2022 12:25:14 GMT</pubDate>
            <atom:updated>2022-05-24T12:27:40.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2d-8G9i0V3zVufyka659rQ.gif" /><figcaption>Make your own gif using OpenCV here <a href="https://huggingface.co/spaces/GDavila/GIFify_OpenCV">https://huggingface.co/spaces/GDavila/GIFify_OpenCV</a></figcaption></figure><p>In computer vision (CV) one of the most difficult tasks can be deploying and sharing models on the web. Especially when it comes to CV programs developed in python. There are options — like hoisting the model to the cloud — but those options often come at exorbitant costs in time or money. Over the last few years it has been exceedingly rare to see CV models deployed in a manner in which you can actually interact with them instantly. But what if we could interact with CV models instantly? No colab notebook, no downloading code and setting up an environment, just plain web inference.</p><p>That’s exactly what Hugging Face Spaces lets us do. We only need to build a UI in streamlit or gradio and put our code in an app.py file (and our dependencies in a requirements.txt file) and we can instantly put our CV programs on the web. To demonstrate this I created a space which uses an OpenCV script to convert any image into a colorful gif:</p><p><a href="https://huggingface.co/spaces/GDavila/GIFify_OpenCV">GIFify_OpenCV - a Hugging Face Space by GDavila</a></p><p>Refactored from this github repo of mine:</p><p><a href="https://github.com/GeorgeDavila/OpenCV_Rave">GitHub - GeorgeDavila/OpenCV_Rave: Make Color Changing GIFs in OpenCV!</a></p><p>This is what the app will look like in your browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*hQTE-Dr5Sgfz8GI14vsY0g.png" /><figcaption>UI as shown on hugging face spaces</figcaption></figure><p>And it lets us turn static images like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glJuIoc9Gvh9fF5bicQkfQ.jpeg" /></figure><p>into GIFs like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jLEpb3sQE4GMgMw8Vz_oow.gif" /><figcaption>Make your own gif using OpenCV here <a href="https://huggingface.co/spaces/GDavila/GIFify_OpenCV">https://huggingface.co/spaces/GDavila/GIFify_OpenCV</a></figcaption></figure><h4>The Code</h4><p>We can see that the app only consists of a relatively brief app.py:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a33aeb3ac95fc23e86b5b4861935b2a/href">https://medium.com/media/7a33aeb3ac95fc23e86b5b4861935b2a/href</a></iframe><p>and a requirements.txt referencing the dependencies opencv-python and Pillow.</p><p>The README is generated automatically in the spaces setup.</p><p>The algorithm itself generates copies of the image in different Hues (basically colors) and then patches those into a single gif. Hugging Face Spaces can retain saved files ephemerally so we can access them by loading them as outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*yvxS1oPlqi9ZU36WxmfPyw.gif" /><figcaption>Make your own gif using OpenCV here <a href="https://huggingface.co/spaces/GDavila/GIFify_OpenCV">https://huggingface.co/spaces/GDavila/GIFify_OpenCV</a></figcaption></figure><h4>A Revolution in Computer Vision Accessibility</h4><p>Web accessible CV models mean that new python CV engineers can interact and edit CV code more readily than ever before. This means that more people will be able to learn about the algorithms that go into machine learning based CV pipelines.</p><p><em>I’m George, a Stanford-Educated Tech Entrepreneur and A.I. Engineer. Follow me here on medium </em><a href="https://medium.com/u/6a9a11dd71c5?source=post_page-----adc1f550c4be--------------------------------"><em>George Davila Durendal</em></a><em> or over on </em><a href="https://www.linkedin.com/in/george-durendal"><em>LinkedIn</em></a><em> for more tech &amp; code.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4065b6963786" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google’s Kubric & Artificial Data: Are video game assets the future of computer vision?]]></title>
            <link>https://gdurendal.medium.com/googles-kubric-artificial-data-are-video-game-assets-the-future-of-computer-vision-bf3cb89cff3b?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf3cb89cff3b</guid>
            <category><![CDATA[blender]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Mon, 09 May 2022 22:20:19 GMT</pubDate>
            <atom:updated>2022-05-09T22:36:17.683Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I’m George, a Stanford-Educated Tech Entrepreneur and A.I. Engineer. Follow me here on medium </em><a href="https://medium.com/u/6a9a11dd71c5?source=post_page-----adc1f550c4be--------------------------------"><em>George Davila Durendal</em></a><em> or over on </em><a href="https://www.linkedin.com/in/george-durendal"><em>LinkedIn</em></a><em> for more tech &amp; code.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*14dk8X4439tOLNg8b6B3sg.gif" /><figcaption>Kubric in action</figcaption></figure><p>Google research recently released <a href="https://github.com/google-research/kubric">Kubric</a>, which they describe thusly:</p><blockquote>A data generation pipeline for creating semi-realistic synthetic multi-object videos with rich annotations such as instance segmentation masks, depth maps, and optical flow.</blockquote><p><a href="https://github.com/google-research/kubric">GitHub - google-research/kubric: A data generation pipeline for creating semi-realistic synthetic multi-object videos with rich annotations such as instance segmentation masks, depth maps, and optical flow.</a></p><p>It basically combines the 3D modelling capabilities of Blender with the physics simulation abilities of the <a href="https://pybullet.org/">PyBullet</a> python robotics simulation library. I.e. it lets you simulate realistic videos using video game assets.</p><p>Using video game assets to train A.I. is nothing new. <a href="https://www.forbes.com/sites/aarontilley/2017/10/04/grand-theft-auto-v-the-rise-and-fall-of-the-diy-self-driving-car-lab/?sh=cb59e8f7d7a4">Back in 2017, the company behind GTA 5 had to send out cease-and-desist notices to A.I. teams using the game to train self-driving car systems</a>. An interesting implementation of a virtual dataset-trained computer vision system can be seen on the YouTuber <a href="https://www.youtube.com/channel/UCQALLeQPoZdZC4JNUboVEUg">Jabrils</a>’ channel:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FE-uk9DtcOS8%3Fstart%3D594%26feature%3Doembed%26start%3D594&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DE-uk9DtcOS8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FE-uk9DtcOS8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/92dbe712be710d39b64fc3f805a5b88a/href">https://medium.com/media/92dbe712be710d39b64fc3f805a5b88a/href</a></iframe><p>This works because most computer vision systems are designed to learn the representation of objects from vast amounts of data. And modern video game assets are relatively photorealistic. So a self-driving model can be tested in a virtual world until a proper proof of concept is developed then be brought into the real world for completion.</p><p>Kubric lets us simulate real-world scenarios using Blender assets, which are extremely cheap by Silicon Valley standards. <a href="https://blendermarket.com/search?utf8=%E2%9C%93&amp;search%5Bq%5D=cup&amp;button=">Here you can see a bunch of cup assets which are cheaper than a real-world coffee</a>. But since these assets are digital, we can programmatically change them or capture photos of them from different angles. For instance, we can write a script to rotate these assets in Blender, change their color, change the background scenery, change their size relative to the background scenery, change the lighting conditions, or change the logo found on them. Leave that script to run while you go out to lunch and you have a robust dataset of thousands of images of coffee cups. Better yet, you automatically have the labels for every pixel of that image. What would’ve been a coffee cup photoshoot and required manual labelling can be reduced to a script.</p><p>Kubric, in particular, lets us simulate realistic interactions between objects. Rather than simply capturing 2D images made from 3D scenes made in Blender, we can capture videos of events, effectively letting us capture 4D info by recording events in 3D scenes (but most probably we’d split these scenes into 2D video streams). Suppose you want to build a computer vision system that detects whether or not some event occurs, perhaps a collision on a construction site. And suppose we want to know the severity of such a collision. Perhaps we can consider the case of an object falling onto another and using the displacement of the ground object as a proxy for severity. I.e. if a rock falls and sends a screwdriver flying across the room, we’ll call that severe. If the screwdriver just moves an inch or two we’ll call that minor. To train such a model we can construct a Kubric environment which moves the screwdriver by dozens of different amounts over dozens of different angles to get thousands of different scenarios. Change the items involved in the collision and we can generate hundreds of thousands of scenarios, giving us a whole new way to build this computer vision system.</p><p>While this particular example might be doable via other means, e.g. tracking bounding boxes and measuring object displacements, the Kubric-based method has the appealing feature of teaching the model about collisions. The Kubric-trained model would contain within it a representation of the concept of collisions and their associated severities rather than just being an object detector capable with other algorithms layered upon it. This will ultimately make Kubric-trained models better at detecting time-dependent events like collisions.</p><p>Car crash detection might be one of the first things its used for. Being from NYC, I can tell you that cars being close together does not equal a collision. So bounding box or car mask overlap algorithms are not likely ideal for detecting a collision. A YOLO-based vision model made to detect overlapping bounding boxes would register a bird landing on your car and a bike parking against it as “collisions”. Sure, you can remove these bounding box overlaps (bird-car, bike-car) from counting as collisions. But what if a car hits a bike on the rode or a bike slams into your car? Things quickly get complicated and branch off into potentially thousands of edge cases making it hard to tell the biker who just broke their leg apart from all the bikers who just bumped into a side-view mirror. A public or private safety camera system would have to wade through many false instances a day. But a Kubric-trained model might be able to learn the idea of a collision itself. In a Kubric environment we might collide hundreds of items with cars and see how they interact with it, with lighter objects bouncing off and heavier ones moving the car. This way we might ultimately train a model capable of detecting collisions and telling us their severity. The Kubric-trained model would let our hypothetical (or not-so-hypothetical in certain localities) public or private safety camera system prioritize the collisions rated as more severe.</p><p>This ability to better teach our A.I. about time-dependent events is what separates Kubric from Blender. Datasets of thousands of still images have been around for decades, so Blender lets us capture more images of these things but ultimately doesn’t provide too much novel data. But there are very few datasets dealing with time-dependent events in video format. Partly because video datasets can take up a lot of space, even on modern devices. Partly because its far harder and potentially dangerous to setup construction accidents or car crashes just for dataset construction. So Kubric lets us explore a brave new world of time-dependent event datasets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf3cb89cff3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PyScript: A Useful Abomination?]]></title>
            <link>https://medium.com/analytics-vidhya/pyscript-a-useful-abomination-adc1f550c4be?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/adc1f550c4be</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Fri, 06 May 2022 00:47:19 GMT</pubDate>
            <atom:updated>2022-05-06T05:43:38.084Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QOOLVjVclbj-kB02" /><figcaption>Python is invading HTML. Photo by <a href="https://unsplash.com/@artturijalli?utm_source=medium&amp;utm_medium=referral">Artturi Jalli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>I’m George, a Stanford-Educated Tech Entrepreneur and A.I. Engineer. Follow me here on medium </em><a href="https://medium.com/u/6a9a11dd71c5"><em>George Davila Durendal</em></a><em> or over on </em><a href="https://www.linkedin.com/in/george-durendal"><em>LinkedIn</em></a><em> for more tech &amp; code.</em></p><p>Last week the data science team over at Anaconda, the company behind the famous python package management system known as <a href="https://en.wikipedia.org/wiki/Conda_(package_manager)"><em>conda</em></a>, released a library known as PyScript. PyScript preposterously purports to stick python code right into HTML à la</p><pre>&lt;html&gt;</pre><pre>   &lt;head&gt;<br>     &lt;title&gt;PyScript Test&lt;/title&gt;<br>     &lt;script defer src=&quot;<a href="https://pyscript.net/alpha/pyscript.js">https://pyscript.net/alpha/pyscript.js</a>&quot;&gt;<br>     &lt;/script&gt;<br>   &lt;/head&gt;</pre><pre>   &lt;py-script&gt; <br>   print(&#39;Hello world welcome to PyScript&#39;) <br>   &lt;/py-script&gt;</pre><pre>&lt;/html&gt;</pre><p><a href="https://georgedavila.github.io/helloWorldPyScript.html">Yes, that is an actual functional webpage.</a></p><h3>Why?</h3><p>Upon seeing the example above you might conclude that the Anaconda data science team has gone crazy. But in reality, PyScript presents quite the useful innovation.</p><p>A little-known war has been happening recently. Different frameworks have been fighting it out to be the frontend for Machine Learning and Data Science.</p><p>Most data scientists and machine learning engineers are backend engineers. Most model-building ML engineers do their daily work in python, with a smaller contingent using C++. Most data scientists do their daily work in python, R, Julia, or even Excel. Relatively few are fluent in frontend technologies. Even those who are can find it disruptive and time-consuming to construct a proper frontend for their models.</p><p>Frameworks like <a href="https://streamlit.io/">Streamlit</a>, <a href="https://gradio.app/">Gradio</a>, and <a href="https://pywebio.readthedocs.io/en/latest/">PyWebIO</a> have been trying to bridge the gap. All these frameworks are pythonic frontends, allowing us to write web-interfaces directly in python (and quite importantly, in a python-friendly manner). You can write everything from simple calculators, to <a href="https://medium.com/analytics-vidhya/create-your-own-deepart-clone-pytorch-neural-style-transfer-web-app-using-streamlit-with-code-b12c0e41d4c7">image style-transfer demos</a>, using these frameworks without ever leaving python. Each of these has its benefits. Streamlit is extremely pythonic, beautifully designed, and easy to interact with. Gradio automatically tunnels to the web, making it easy to deploy an application from a notebook. But these frameworks have the poignant issue of not being easily deployed and/or integrated into JS frontends. I.e. I can’t just stick a button onto my website that says “Click me to run this python script” in a set-and-forget manner. At the very least you need to host a python script somewhere (Pythonanywhere is quite a nice and simple cloud host for this use-case, but it still requires quite a bit of setup and/or cost).</p><p>On the other hand, while the marvelous <a href="https://www.tensorflow.org/js">Tensorflow.js</a> framework is technically a backend framework, it makes it very easy to build ML frontends that run on a users’ device via WASM and WebGL. <a href="https://github.com/ml5js/ml5-library">ML5.js</a> is a particularly wonderful distillation of this frontend simplicity as you can deploy ML models as complex as human segmentation models to the browser in <a href="https://editor.p5js.org/ml5/sketches/BodyPix_Webcam">just 70 lines of code</a>. Alas, this still has the issues of 1) being written in javascript and 2) being slower than its python tensorflow counterpart (which uses C rather than JS on the backend). So if a python engineer learned Tensorflow.js just to write a web demo they would still have to deploy the final model in python anyway, wasting time and resources. And many ML models are written in sklearn anyway, so there’s both a language and framework incompatibility problem.</p><p>PyScript tackles some of these issues. It runs python in the browser from nothing but a basic server. So you can host your ML/DS demo on your free github.io website, as I show below. Not only that, but you can seamlessly pass inputs and outputs from python to javascript or html or vice versa. In practice this means that you can embed a python model on your website and not have to worry too much about hosting or maintenance.</p><h3>Coding in PyScript</h3><p><a href="https://github.com/pyscript/pyscript">GitHub - pyscript/pyscript: Home Page: https://pyscript.net Examples: https://pyscript.net/examples</a></p><p>PyScript purports to be able to run python right in your html. So the following JavaScript</p><pre>&lt;script&gt; <br>document.write(&#39;Hello World&#39;);<br>&lt;/script&gt;</pre><p>And the following PyScript</p><pre>&lt;py-script&gt; <br>print(&#39;Hello World&#39;) <br>&lt;/py-script&gt;</pre><p>Produce equivalent results. If you’re like me you probably assumed pyscript print() would be equivalent to JS console.log(), and indeed that’s what I assumed when first writing the examples above. But apparently that’s not currently the case (this probably should change, as I show below we can assign a python output to a html element anyway so print=console.log is likely a more useful relation).</p><p>Here is a working demo of the above hello world example:</p><p><a href="https://georgedavila.github.io/helloWorldPyScript.html">PyScript Test</a></p><p>For a more complex demo we can look at an example written by <a href="https://github.com/tirthajyoti">Tirthajyoti Sarkar</a> which uses python libraries like numpy and matplotlib to generate random distributions and plots:</p><p><a href="https://tirthajyoti.github.io/pyscript_random_gen.html">PyScript Random Number Generation</a></p><p>We should note the code snippet</p><pre>&lt;py-env&gt;      <br>- matplotlib <br>&lt;/py-env&gt;</pre><p>This is setting up the environment, effectively acting like “pip install matplotlib” normally would. Numpy is a standard python library, so it would appear that pyscript comes with a default python configuration and we import external libraries by including them in the &lt;py-env&gt;.</p><p>We can further observe that the python script is fetching values from the html elements and passing the figures back as outputs using PyScript’s own Element function</p><pre>&lt;py-script&gt;<br>import numpy as np<br>import matplotlib.pyplot as plt  </pre><pre>out = Element(&quot;outputDiv&quot;)<br>input_num = Element(&quot;how-many&quot;)<br>dist_type = Element(&quot;dist&quot;).value<br>out2 = Element(&quot;outputDiv2&quot;)</pre><pre>...</pre><pre>out.write(f&quot;Here are {n} random variates from Normal distribution: {r}&quot;) </pre><pre>...</pre><pre>out2.write(fig1)<br>&lt;/py-script&gt;</pre><p>To see how it handles more complex python libraries, I tried deploying the <a href="https://github.com/pyscript/pyscript/blob/main/pyscriptjs/examples/panel_kmeans.html">PyScript team’s scikit-learn k-means clustering example</a> on my github.io page:</p><p><a href="https://georgedavila.github.io/panel_kmeans.html">Pyscript/Panel KMeans Demo</a></p><p>It will likely take a bit for the above page to load but when it does you can see that the PyScript library is capable of hosting more complicated code. To host that I only needed to upload that one HTML file to github. The simplicity of it is a nice reprieve from the cumbersome environment management typically associated with machine learning.</p><p>So there we have it! A way to easily integrate a python script into a frontend. The scikit-learn library, in particular, is an essential pillar of modern machine learning and data science. So the ability to easily host and share sklearn models may very well make PyScript a favorite amongst data scientists, especially those who want to host projects or develop proof of concepts. Whole websites might even be built around this. Suppose, for instance, that you build an sklearn model that tells someone how many push-ups to do based on their height and weight inputs. Rather than deploying the python model to the cloud and accessing it as an API via JQuery — the way you would’ve done it a week ago — you can now use PyScript. PyScript will likely remain the slower of the two options for the foreseeable future; so enterprise-grade models should be properly deployed and orchestrated. But it quite nicely fills out that sweet spot of getting a minimally-viable model out to the world.</p><h3>Notes</h3><p><a href="https://brython.info/">Brython</a> has existed for quite a while. I saw it about a year ago but quickly found it to be maladapted for modern ML/DS use cases. To the contrary, PyScript seems to be built from the ground up with these fields in mind. Its less than a week old and can already be used with sklearn.</p><p>From my tests so far, Tensorflow.js seems to be far faster than PyScript when it comes to in-browser inference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adc1f550c4be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/pyscript-a-useful-abomination-adc1f550c4be">PyScript: A Useful Abomination?</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Pyinstaller in Virtual Environments]]></title>
            <link>https://gdurendal.medium.com/how-to-use-pyinstaller-in-virtual-environments-527007fd7343?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/527007fd7343</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pyinstaller]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Sat, 23 Oct 2021 03:38:24 GMT</pubDate>
            <atom:updated>2021-10-23T03:38:24.199Z</atom:updated>
            <content:encoded><![CDATA[<p>Pyinstaller is used to turn python code into functional desktop applications. But there’s the common issue of it failing in virtual environments. Simply do:</p><pre>pip install <a href="https://github.com/pyinstaller/pyinstaller/tarball/develop">https://github.com/pyinstaller/pyinstaller/tarball/develop</a></pre><pre>OR</pre><pre>pip install <a href="https://github.com/pyinstaller/pyinstaller/archive/develop.zip">https://github.com/pyinstaller/pyinstaller/archive/develop.zip</a></pre><p>i.e. install the development version as specified in the <a href="https://pyinstaller.readthedocs.io/en/stable/installation.html">documentation</a>. If you simply do</p><pre>pip install pyinstaller</pre><p>in a virtual environment, you may encounter errors when attempting to use pyinstaller. If the error message includes something about matplotlib or another package not present in your virtual environment, this is an error characteristic to this particular issue.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=527007fd7343" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The $3.5 Trillion Build Better Act Only Explicitly Mentions $1.17]]></title>
            <link>https://gdurendal.medium.com/the-3-5-trillion-build-better-act-only-explicitly-mentions-1-17-659e73b1b8b2?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/659e73b1b8b2</guid>
            <category><![CDATA[news]]></category>
            <category><![CDATA[money]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[taxes]]></category>
            <category><![CDATA[politics]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Sat, 02 Oct 2021 00:33:03 GMT</pubDate>
            <atom:updated>2021-10-02T00:33:03.352Z</atom:updated>
            <content:encoded><![CDATA[<h3>The $3.5 Trillion Build Better Act Only Explicitly Mentions $1.17 Trillion — More than $2 Trillion is Not Precisely Accounted For</h3><p>I recently used my A.I. — more aptly a collection of A.I. — to analyze the $3.5 Trillion Build Better Act. Despite being 2,500 pages, the act was only released a week ago and is being rushed through Congress. So, as an expert in A.I. trying out some new programs, I thought this would be a good opportunity to field test my A.I. a bit. What it found is quite astonishing.</p><h3>$1,178,500,858,844.37</h3><p>That’s the exact amount of money my A.I. was able to find mentioned in the bill. Now of course some of that is for defining tax brackets. And items such as recurring costs are not fully counted by the A.I. But by and large the multi-billion and multi-million dollar expenditures seem to have been found by the A.I. And then there are, of course, items which are recurring. E.g. a reclamation fee of 7 cents is applied to every ton of material under section 109 of the federal and gas royalty management act.</p><p>This means that $2.3 Trillion is purportedly hidden in the fees of a 2,500 page bill which elected representatives have only had a week to review.</p><p>What is also concerning is that the bill does not appear to try to account for the missing $2.3 Trillion. The A.I. found pretty much every instance of money being mentioned, including revenue-generating instances. Needless to say, this bill leaves out a lot.</p><p>I’ll be publishing some of the A.I.-generated data soon. Reach out for inquiries or early access.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=659e73b1b8b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenCV Rave: Make Color Changing GIFs (and Memes) using Python & OpenCV]]></title>
            <link>https://gdurendal.medium.com/opencv-rave-make-color-changing-gifs-and-memes-using-python-opencv-5cd08bad0bf6?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cd08bad0bf6</guid>
            <category><![CDATA[dogecoin]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Tue, 18 May 2021 19:10:30 GMT</pubDate>
            <atom:updated>2021-05-19T20:42:09.324Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Code, Google Colab, and Memes included! Discussion is below the meme. Scroll bit farther for some super useful code. For more neat stuff follow me on twitter:</em> <a href="https://twitter.com/GDurendal">@GDurendal</a></p><p>You can dive right into the code on Colab:</p><p><a href="https://colab.research.google.com/github/GeorgeDavila/OpenCV_Rave/blob/main/changeHueOpenCV.ipynb">Google Colaboratory</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArcFKKAbTUoZqxL-sL6sdg.gif" /><figcaption>Mentioning Elon Musk and DogeCoin will most certainly help my SEO. Also sure here’s an example or whatever.</figcaption></figure><p>Don’t worry this actually includes some useful coding-related stuff. Scroll down to the next section for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ljLzL6p7bgcLruIcMtsCw.gif" /><figcaption>I coded all this on April 1st when Doge was like 5 cents. Knew I should’ve trusted my gut and bought more….</figcaption></figure><p>I coded this as a fun little project and published it on April 1st. I even included Doge memes when DogeCoin was still like 5 cents. Guess the joke’s on me, should’ve bought more….</p><p>Its basically a program that changes the <strong>Hue</strong> of an image over 180 possible variations. Note that Hue isn’t exactly ‘color’ as we use colloquially. See how in all the gifs none of the whites or blacks change at all? If we simply changed the color then those would change. Hue can basically be seen as travelling around this wheel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*EANvUouold8rXH4JZgE-dA.png" /><figcaption>Color wheel where all colors appear to have same saturation and brightness. Only difference is Hue. From <a href="https://en.wikipedia.org/wiki/Hue">Wikipedia</a>. Public Domain.</figcaption></figure><p>So neither the brightness or the saturation change, only the colors change. White/black spectrum (including gray) counts as brightness, so those whites and blacks don&#39;t change at all. It certainly gives a more neat visual effect. Try it out yourself! I discuss how to use it in the github link in the next section (<a href="https://github.com/GeorgeDavila/OpenCV_Rave">here it is again</a> just go to the ‘How to Use’ section). Here’s the Colab notebook so you can run it pretty much No-Code (basically just press the play buttons and follow the ‘How to Use’ section):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*dVFZwzP1bO4Wu-77FoGwAQ.gif" /><figcaption>Goddamit I made this stupid thing on April 1st I should&#39;ve invested more.</figcaption></figure><h3><strong>Actually Useful Code Snippets For Images In Colab</strong></h3><p>While fun, I mainly did this as a fun way to simplify working with images in OpenCV and images in Google Colab. Here’s the full Github Repo:</p><p><a href="https://github.com/GeorgeDavila/OpenCV_Rave">GitHub - GeorgeDavila/OpenCV_Rave: Make Color Changing GIFs in OpenCV!</a></p><p>The <strong>Uploads Snippets</strong> are super helpful. I occasionally have issues with uploading images with ease into colab. We can do it manually but I think you’ll find that the code here is much easier and far more intuitive should you come back to it months or years from now. No need to sort out where to put an image, or in what form factor, or read through the documentation for that info, none of that hassle. Even compared to the common method of uploading from drive it’s a breeze. No needing to put the image in drive and then authorize drive access for colab, just click button.</p><p>With these snippets you can upload from your local device (even your phone, I know because I tried it) or from a URL by simply entering the URL where prompted then running that cell. Renames your image to input_image.png, but you can obviously change that name by editing strings where it appears. These snippets are super useful if you’re working with images in colab frequently. I’ve found myself going back to code from years ago and having little to no clue how and where to upload images without reading any notes I left (if any at all). This method makes it easy and obvious.</p><p><em>Note: the ‘Magic’ commands, i.e. console commands starting with % can be useful in Colab and IPython Shells. But make sure you rename these lines according to your project structure. All Colabs use ‘/content/’ as the master directory but if you set a different one adjust the code accordingly.</em></p><p>Lets look at the <strong>Local Device Upload Snippet</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85048592aa1d75ad0372e8fc338ae380/href">https://medium.com/media/85048592aa1d75ad0372e8fc338ae380/href</a></iframe><p>It basically just provides a standard ‘upload’ option present on most devices. That is done in line 3 through the files.upload() function. This even takes uploads from phones (I tried on 2 phones, worked on both, no special configuration or coding, just plain old phone you just need to be signed into colab). Note that this comes from the google.colab library so will not work outside of colab. Once ran it will show a button prompting the user to upload an image or cancel. Upload as normal. Code-wise it saves the image as ‘input_image.png’ and saves the original photo title as variable original_filename for later use. The ‘magic’ command %cd ‘/content/’ changes the working directory (of the entire program not just this snippet) to /content/, which is colab’s default master directory. Should colab change that name in the future this name will need to be changed accordingly.</p><p>Lets look at the <strong>From URL Upload Snippet</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56970c3ebea3b4e11b982ad0ab3ded2a/href">https://medium.com/media/56970c3ebea3b4e11b982ad0ab3ded2a/href</a></iframe><p>Basically gives you a form as seen here on the lower right hand side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5mC_LTiFqo_bIgnHw4RCNQ.png" /><figcaption>Screenshot of the Snippets</figcaption></figure><p>Just enter your URL there, super easy and obvious.</p><p>Both upload snippets rename your file to ‘input_image.png’. Don’t have to rename it but does streamline things. Can also use the renaming function to redirect the path. E.g. you can replace ‘input_image.png’ with ‘some_folder/input_image.png’</p><p>The <strong>Show Image Snippet</strong> is also fairly useful, although much easier. You should see it right above the picture. If you don’t, here it is again:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77ebe93c6f772c22eecbc1c9009a4d73/href">https://medium.com/media/77ebe93c6f772c22eecbc1c9009a4d73/href</a></iframe><p>The <strong>Parameters snippet</strong> (ie the sliders) can be super helpful. Don’t see people use this Colab feature enough. Here’s the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ee4b01151e7e9647e5b24caa90bacad/href">https://medium.com/media/6ee4b01151e7e9647e5b24caa90bacad/href</a></iframe><p>The #@ denotes some form field. #@title inputs a title, #@markdown lets you write markdown into the form, and #@param gives us the sliders. The other # are just plain python comments of mine.</p><p>Finally here’s the <strong>ZIP File Download Snippet. </strong>This one has served me well over many projects. Just assigns a name to a zipped file (here name is based on parameter choices) and uses console commands to put our Hue variations (aka the images we use to make the gif) into a single zip file which it then downloads. Multiple files can be a huge pain to download from colab, so this does it for us.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4650a86cc8c89a9f7521a6cc4ee320c/href">https://medium.com/media/f4650a86cc8c89a9f7521a6cc4ee320c/href</a></iframe><p>Alternatively you can mount your Google Drive and use os.system(‘mv /content/’ + zip_filename + ‘ YOUR_DRIVE_DIRECTORY’).</p><p>As for the Hue changing and GIF creating code, those are less pertinent to the average computer vision programmer, but the code, comments, and sources are in the colab notebook.</p><p>Thanks for reading!</p><p>— George</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cd08bad0bf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenCV_TotalAccess: Instantly Watch and Label All Cameras Attached to a Computer Using this Python…]]></title>
            <link>https://gdurendal.medium.com/opencv-totalaccess-instantly-watch-and-label-all-cameras-attached-to-a-computer-using-this-python-b2d64da8f879?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2d64da8f879</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Tue, 18 May 2021 04:05:11 GMT</pubDate>
            <atom:updated>2021-05-19T20:48:06.131Z</atom:updated>
            <content:encoded><![CDATA[<h3>OpenCV_TotalAccess: Instantly Watch and Label All Cameras Attached to a Computer Using this Python Code</h3><p>Probably the most James Bond OpenCV script that you’ll ever use, although that’s not really saying much… <a href="https://twitter.com/GDurendal">@GDurendal</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0qHaJnAmlUskGnKd" /><figcaption>Photo by <a href="https://unsplash.com/@arkeyphoto?utm_source=medium&amp;utm_medium=referral">arvin keynes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Do you know that moment in movies where some logs on to a computer and instantly accesses all the security cameras? That’s basically what this software does. Although, for a flexible piece of software than can instantly access and display all permissioned cameras on a given device — invocative of that moment in spy movies where they hack into all the cameras — it is almost <em>shockingly</em> <em>boring </em>in its actual execution.</p><h3>The Problem</h3><p>A consistent practical problem in computer vision is the simple problem of camera selection. I don’t mean choosing between an OAK ai-enabled camera or an infrared camera. No, I mean the simple process of selecting between a default front camera and a rear camera. It’s a common enough problem with 2 or 3 cameras. When we have a dozen or more showing multiple rooms and we have to select only cameras 4, 7, and 9 it becomes an even greater problem.</p><p>Now this isn’t too much of a problem for even the most novice computer vision engineer. Looking at the common function <strong>cv2.VideoCapture(0) </strong>we can recognize it as simply a matter of choosing the right indices. It might take a minute to search over those indices, but no big deal.</p><p><em>But when it comes to actual deployment this simple problem can become an unexpected nightmare</em>. The lay user likely doesn’t know how to change their default webcam or doesn’t care to. Even if they can do that, it is unlikely that they will be able to easily find and enter the indices for a given few cameras out of dozens. Not to mention the fact that a common user may do something to alter an originally working configuration, thus necessitating a follow-up customer service interaction in just a few months time.</p><p>There is also the matter of computational efficiency. In modern computer vision — where we might run neural network inference on any given video feed — we do not want excess cameras around eating up valuable CPU and GPU resources.</p><p>Thus, for reasons of usability and computational viability we must give the user an easy way to choose what camera(s) they want to use. That is where this code comes in.</p><h3>The Code</h3><p>All of the code is made available on my GitHub:</p><p><a href="https://github.com/GeorgeDavila/OpenCV_Various/tree/main/OpenCV_TotalAccess">GeorgeDavila/OpenCV_Various</a></p><p>Download the directory called OpenCV_TotalAccess. Assuming that you already have Python 3.6+ you only need to run the following in console:</p><p><em>pip install -r requirements.txt</em></p><p><em>python showAllCameras.py</em></p><p>The only requirements are OpenCV and Numpy. Should work with most versions of these so if you already have these libraries feel free to skip the pip install. This python script will show you all the camera feeds OpenCV can find and access on your device. Here is an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*Tihgrxt3SIaUfZWWO0HoFA.jpeg" /><figcaption>Photo by Author. Shows laptop cameras. Camera 0 is the default inner webcam. Camera 1 is the 2nd, rear-facing, camera. Notice the indices are written in red.</figcaption></figure><p>Voila! That’s the code that will get you instant eyes on all cameras on the device. If you have 10 cameras you will see 10 feeds here, 100 cameras ad you’ll see 100 and so on. Certain parameters and options can be adjusted in the code to quickly change the display format (see the github repo for that). Now on to the details…</p><p>Notice the red text. Those show the indices corresponding to their usage in OpenCV. So if we call <strong>cv2.VideoCapture(0) </strong>we will get the image on the left and if we call <strong>cv2.VideoCapture(1) </strong>we will get the image on the right.</p><p>The script itself is a bit interesting. <strong>cv2.VideoCapture()</strong> will not produce an ‘out of range’ error on the index input. So if we try cv2.VideoCapture(5000), a structure which technically calls camera number 5000 (of our 2 cameras) we will not get an error from that function. So, in order to see how many cameras are on an otherwise unknown network, we simply observe that <strong>cv2.imshow()</strong> <em>will</em> produce an error if it gets an input from the empty camera feed cv2.VideoCapture(5000). We then apply a try/except block on this function. It then builds a list of indices that will only stop building once we run into that first empty feed. We should note that it is probably most generally useful to run the try/except block on this function on this function rather than another. This is because different feeds may have different structures (e.g. different sizes or filetypes) which may interfere with other intermediate functions. At the end of the day we only really care about whether or not a given camera feed can be readily displayed, not if it can be run through some arbitrary function. So we search for the error occurrence in <strong>cv2.imshow()</strong>.</p><p>So now both you and the user have an easy way to know which camera you want to use for your particular application. Indeed, this can even be quite the time saver for a computer vision engineer. Easier to run this script than manually search over the indices.</p><p>Lets also create an easy way for the totally non-technical user to assign a camera to be used. Inlcuded in the repo is a tkinter-based script, let us run that:</p><p><em>python tkinterEnterIndex.py</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*MUHDspIUAnsO2kXUOw7tiw.jpeg" /><figcaption>Photo by Author. Simple App for selecting the camera you want to use. Here we typed ‘1’ in order to get the camera indexed ‘1’ on the right in the image above.</figcaption></figure><p>This app inputs a number into the text file selectedCameraIndex.txt. You can simply input this into a json file or input a list of such numbers according to the specifications of your particular program. I went with a tkinter app here since its exceedingly easy to turn tkinter files into .exe’s through pyinstaller. That exe can be what the common non-technical user interacts with.</p><p>After typing ‘1’ in the app as shown above, the input then feeds into the coode in showSelectedCamera.py. Run:</p><p><em>python showSelectedCamera.py</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*GesQc4dyEHXLkttyT30XgQ.jpeg" /><figcaption>Photo by Author.</figcaption></figure><p>As we can see the resulting image is that of my rear laptop camera, exactly as specified (Recall that index ‘1’ corresponds to camera number 2 in OpenCV). Here I ran a grayscale function as a bit of a placeholder, but you can change that function to any that your program uses.</p><p>There we have it. An easy and adjustable way for CV engineers and common users alike to properly know and adjust which cameras they might use. Now your user can simply look at which numbers correspond to their hallway, kitchen, etc. and enter those numbers into a straightforward exe.</p><p>Told you it was surprisingly boring…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2d64da8f879" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publishing One of the World’s First A.I. Written Books — The Poetic Prototype]]></title>
            <link>https://gdurendal.medium.com/publishing-one-of-the-worlds-first-a-i-written-books-the-poetic-prototype-771576c8139c?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/771576c8139c</guid>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[news]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Fri, 26 Mar 2021 15:28:45 GMT</pubDate>
            <atom:updated>2021-03-30T22:35:10.644Z</atom:updated>
            <content:encoded><![CDATA[<h3>Publishing One of the World’s First A.I. Written Books — The Poetic Prototype</h3><p><em>Get one of the World’s First AI written books for free here (enter $0 in payment section or buy me a coffee!): </em><a href="https://gum.co/PoeticPrototype"><strong><em>gum.co/PoeticPrototype</em></strong></a><strong><em> </em></strong><em>or follow me on twitter </em><a href="https://twitter.com/GDurendal"><em>@GDurendal</em></a></p><p>And it it now also the <strong>World’s First A.I. created audiobook!</strong> As in both written and spoken by an A.I. (more on that coming soon!). See the demo:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUHjRYh1HL7g%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUHjRYh1HL7g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUHjRYh1HL7g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecaf852d2d6b48d72ce91fff2af19ea8/href">https://medium.com/media/ecaf852d2d6b48d72ce91fff2af19ea8/href</a></iframe><p>As we all know, A.I. has long been prophesized to replace us all. One of the few domains of human society assumed to be safe from this encroachment was the Arts. <em>Most assuredly</em> — we all assumed — A.I. could not replicate the artistic side of humanity.</p><p>As those following the field already know, AI generated imagery has been a thing for a few years now. Sites like <a href="https://www.artbreeder.com/">ArtBreeder</a> and <a href="https://deepart.io/">DeepArt</a> let anyone make AI images. Or you can create images using nothing but code and an input image, as I did <a href="https://gdurendal.medium.com/create-your-own-deepart-clone-pytorch-neural-style-transfer-web-app-using-streamlit-with-code-b12c0e41d4c7">here</a> (some coding required for that demo). Some have even sold at <a href="https://www.christies.com/features/A-collaboration-between-two-artists-one-human-one-a-machine-9332-1.aspx">auction</a>. Basically we could say that the domain is quite saturated.</p><p>But one thing that hasn’t been as well explored is AI-generated literature. Sure, in the AI community we have explored the efficacy of generating technical text using AI and modern NLP (Natural Language Processing). Famous models like <a href="https://medium.com/predict/what-you-need-to-know-about-gpt-3-and-why-it-matters-4878215b78e8">GPT-3</a> might even be familiar to many outside of the AI community. They work fine on generating technically-proficient and grammatically correct texts. But again, those lack an artistic orientation.</p><p><em>Where’s the style? </em>In the aforementioned domain of AI painting we have styles ranging from <a href="https://medium.com/x8-the-ai-community/neural-style-transfer-using-deep-learning-to-generate-art-651d9ccf740c">van Gogh</a> to <a href="https://gdurendal.medium.com/renify-create-your-own-custom-renaissance-portrait-using-a-i-8522a8445b8d">Renaissance Portraiture</a> to the trippy output of <a href="https://medium.com/@grrowl/a-crash-course-in-deepdream-n-31933770a634">DeepDream</a>. All of varying qualities. You could run one of those algorithms 1000 times and get a different result every time. With this AI writer I wanted to explore that kind of variation, that kind of <em>style</em>. More technically, I wanted to explore style transfer as applied to natural language generation algorithms, but the technicalities of that are a discussion for another day.</p><p>In such a task we can take two major approaches: the <strong>high-entropy</strong> approach &amp; the <strong>low-entropy</strong> approach. The high-entropy approach produces more statistical randomness, whereas the low-entropy approach is far more orderly. The low-entropy approach produces a corpus that is far more grammatically and thematically coherent. To put it in a relatable context, the <strong>low-entropy</strong> approach is kind of like taking a photograph and putting an Instagram filter over it. It might be slightly different from a real photograph, but chances are a lot of people will look at it and not even know that it’s edited. To the contrary, the <strong>high-entropy</strong> approach is like taking a photograph and turning it into a full painting. It might be something relatively subtle like a Renaissance-style portrait or it might be a fully impressionist van Gogh style portrait, but nobody is going to confuse it for a photograph.</p><h3>With <strong><em>The Poetic Prototype</em></strong> I took the <strong>high-entropy</strong> approach, making a more creative AI.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0MC_tU6JVY89NXzd" /><figcaption>Photo by <a href="https://unsplash.com/@diesektion?utm_source=medium&amp;utm_medium=referral">Robert Anasch</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The inspiration (aka the training dataset) for this AI was 18th &amp; 19th century naturalist poetry by a variety of authors. Some other similar styles of the period were thrown in to give the AI a bit more to work with. It should be noted that spelling and grammatical conventions were different at this time. This style of poetry also tends to take more artistic liberties than both the technical writings and longer-form literature of its time. The AI is more familiar with the writing conventions of these poems than it is with the conventions of modern times.</p><p>I felt relatively confident that a vanishingly minute number of readers would enjoy reading 500 pages of rather matter-of-fact descriptions of trees, the sky, birds, and the like. That’s what the low-entropy models wrote. <em>So I decided to just turn up the high-entropy dial all the way</em>. Personally I enjoyed this writing much more. Sure, it gave plenty of grammatical errors and even totally nonsensical descriptions. But I would be willing to wager that few modern readers of this style of poetry read it to learn basic grammar or even for any sort of narrative structure. Sure, some might read it for a supposed message. But lets have a look at well-known author Samuel Taylor Coleridge’s poem <em>Sonnet: To the River Otter </em>(this work and many others by Coleridge were part of the dataset used to create the AI):</p><blockquote>Dear native Brook! wild Streamlet of the West!<br>How many various-fated years have past,<br>What happy and what mournful hours, since last<br>I skimm’d the smooth thin stone along thy breast,<br>Numbering its light leaps! Yet so deep imprest<br>Sink the sweet scenes of childhood, that mine eyes<br>I never shut amid the sunny ray,<br>But straight with all their tints thy waters rise,<br>Thy crossing plank, thy marge with willows grey,<br>And bedded sand that vein’d with various dyes<br>Gleam’d through thy bright transparence! On my way,<br>Visions of childhood! oft have ye beguil’d<br>Lone manhood’s cares, yet waking fondest sighs:<br>Ah! that once more I were a careless child!</blockquote><p>Did you get a message? Maybe an appreciation for otters? Maybe you just enjoyed the rhythm or the relaxing nature of the imagery? <strong>That’s what I wanted to do with this AI: create a heavily stylistic writing that is more enjoyable than it is technically-proficient or thematically benevolent.</strong> I wanted to create the van Gogh portrait rather than the photo filter, except with writing style.</p><p><strong>Don’t worry I’ll publish some of the more technical ones soon. </strong>But I think most readers, particularly avid readers of similar styles of poetry, will enjoy the novel nature of the present AI.</p><p>When reading the book you’ll most certainly notice some of these alluded-to grammatical errors and even some non-sensical statements. Lets look at the following from the opening lines of Chapter 3:</p><blockquote>With dreams of sorrow come,</blockquote><blockquote>And so clouds not fears his land of bright so spirit place,</blockquote><blockquote>The shadows so have beautiful the sight</blockquote><blockquote>Fall in the sense of stone</blockquote><blockquote>Then he gaint of the wiser and the ship</blockquote><blockquote>Is trouble the links of all most beauty seems the light</blockquote><blockquote>Of all the last saddess the more strike a spectering more</blockquote><blockquote>And what clouds and I steep in sleep.</blockquote><p>Most assuredly it is quite the novel scene. I would most certainly recommend reading this aloud to get a full appreciation for the AI’s focus on rhythmic structure, alliteration around the letter ‘s’ and pacing. Further try reading it exactly as you think 18th-19th century poetry should sound. Then try reading it aloud in that way to someone who has no clue that it was written by an AI. Can they tell that something is up? Do they enjoy the sound of it? My bet would be no and yes, respectively.</p><p>One interesting thing to note is the manner in which it makes spelling mistakes or mentions. Some are artifacts of the training dataset. For instance, we can see that Samuel Coleridge adds ‘t’ and ‘d’ to certain words to enhance the pronunciation and expression of this words. The AI can be seen doing the same, turning ‘gain’ into ‘gaint’ in the 5th line. Yet the misspelling ‘saddess’ (which isn’t a word in this period’s English) seems to be made to play up the local ‘s’ alliteration. Moreover saddess rhymes more fluidly with the preceding word last (try saying ‘last saddest’ and ‘last saddess’ aloud). The AI very much seems to prefer rhythmic structure and rhythmic flow to technical proficiency, a style not dissimilar to that of the authors that inspired the AI.</p><p>At the very least, it is certainly interesting to read something highly entropic yet still strongly focused on poetic and rhythmic structure. It is certainly something you won’t find anywhere else, which is kind of the point. I’ll publish more technically-focused A.I. writings in the future, but certainly do let me know if you enjoy this style of this one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=771576c8139c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Your Own DeepArt Clone: Pytorch Neural Style Transfer Web App Using Streamlit (With Code…]]></title>
            <link>https://medium.com/analytics-vidhya/create-your-own-deepart-clone-pytorch-neural-style-transfer-web-app-using-streamlit-with-code-b12c0e41d4c7?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b12c0e41d4c7</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[art]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Fri, 12 Mar 2021 06:55:28 GMT</pubDate>
            <atom:updated>2021-03-30T15:56:37.119Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create Your Own DeepArt Clone: Pytorch Neural Style Transfer Web App Using Streamlit (With Code and Colab Demo)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnTfU4ARyAy9ivN5au9lKA.png" /><figcaption>Neural Style Transfer on Nikola Tesla</figcaption></figure><p><em>Follow me on twitter:</em> <a href="https://twitter.com/GDurendal">@GDurendal</a></p><p>Neural Style transfer is one of those fun yet generally impractical domains of modern machine learning. Its usually hardly worth the logistical effort of setting up the environment given the relative complexity of the algorithms. Then once you do its just console commands, the process of creating images is hardly as fun or easy as it should be. There are of course sites like deepart and plenty of apps on the topic. But nothing that lets A.I. engineers insert their own models or deploy the frontend themselves. And one also gets the added latency of the App/Web Queue when using those. What if we could create our own that was a lot quicker and infinitely more customizable?</p><p>One day I found myself wanting to take on a custom Streamlit project to better understand the framework beyond simple buttons and tables. Luckily I also came across this pytorch neural style transfer demo around the same time: <a href="https://github.com/pytorch/examples/tree/master/fast_neural_style">https://github.com/pytorch/examples/tree/master/fast_neural_style</a>. This particular implementation gives strikingly good results (in my opinion). So I decided to create my own streamlit style transfer web app based on it.</p><h3>The App</h3><p>Lets take a look at the app itself. Here’s what you’ll see when you first open it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*uruc2mEWCnh8T2KZCDvlSg.png" /></figure><p>As you can see it is totally intuitive. Just pick a style based on the paintings given and upload your image. Lets try one of Einstein in the Mosaic style:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*nB6Ml8HWnk3nebBPNgz35Q.png" /></figure><p>Now click the ‘Create Style Transfer Image’ button to run the algorithm!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*zoV9FVJjTg7tt9dSXUPgCw.png" /></figure><p>And that’s it! Super easy! Speed will vary according to image size but any image under 2MB should be done in under a minute, depending on the power of your computer/internet speed if you’re using the colab. This one ran in a few seconds for me, as did most. Certainly far faster than any publicly available style transfer app.</p><p>Its so easy to use that I had time to play around with it. You can paint your dogs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiD7j8DsTTqYhvvlqx0hHA.png" /></figure><p>I especially like the results on old images. Sure, there are frameworks like <a href="https://heartbeat.fritz.ai/using-deoldify-to-colorize-and-restore-grayscale-images-and-videos-c5f88b67cffb">deoldify</a> that can restore old photos, but thats hardly any fun. Check out these results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kOrTOLQzo4_TmOqWZ88X5A.png" /><figcaption>Took me longer to edit this collage than to run the A.I.</figcaption></figure><p>Can certainly see how one might prefer having paintings like this hanging up in the house over a plain old image.</p><p>Code wise the algorithm stores these images in the directory images/output-images and names them solely according to the style used so as to not clog up the directory. Can just right click and do ‘save image as’ to save the images straight from the streamlit app. But if you want to save them images in folder make sure to copy them before you use the same style again.</p><h3>The Code</h3><p>All the relevant code can be found on my github:</p><p><a href="https://github.com/GeorgeDavila/PytorchNeuralStyleStreamlit">GeorgeDavila/PytorchNeuralStyleStreamlit</a></p><p>A colab demo was included for ease but it works best in a dedicated virtual environment. Open command prompt on a computer with Python 3.7+ installed and create a virtual environment:</p><p><strong>py -m venv streamlitstyle</strong></p><p>Then navigate to that directory: <strong>cd streamlitstyle</strong> and activate the venv using <strong>.\scripts\activate</strong></p><p>Then simply download the repo and install the requirements using the requiremnts.txt I provided: <strong>pip install -r requirements.txt</strong></p><p>A pytorch 1.7.1 download is also required. This can be done fairly simply following the instructions on <a href="https://pytorch.org/">https://pytorch.org/</a></p><p>Once all that is done you’re ready to run the program! Just use <strong>streamlit run streamlit_main.py </strong>and the app should open up in your browser at <a href="http://localhost:8501/">http://localhost:8501</a></p><p>Now just its just a simple interface!</p><p>And here’s a colab demo for ease of access for those that don’t have the requisite hardware.</p><p><a href="https://github.com/GeorgeDavila/PytorchNeuralStyleStreamlit/blob/main/pytorchNeuralStyle.ipynb">GeorgeDavila/PytorchNeuralStyleStreamlit</a></p><p>The colab demo is much more hackish since Colab and IPython shells do not support localhosting. So we have to tunnel the app through ngrok and use a corresponding ngrok.io link, follow the instructions I wrote in the colab notebook. It can be a bit convoluted but follow those instructions and you should be able to get an active tunnel up. More active usage will require opening an ngrok account, so I suggest using a local virtual environment if you want to play around with it for longer.</p><p>I even made a way to edit the streamlit code within the colab itself. Streamlit typically can only be called from console commands using streamlit run, so you can’t just run it right from a IPython shell, have to call it using console commands. So we simply write the streamlit code to a python file as text (see the text variable my_st_code). Try some basic edits yourself (if you know basic streamlit), you can edit it straight from that notebook.</p><p>And that’s it! We have a beautiful and easy to use streamlit web app! One could even host it on Heroku if so inclined (although this particular algorithm can use up a lot of compute power). Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b12c0e41d4c7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/create-your-own-deepart-clone-pytorch-neural-style-transfer-web-app-using-streamlit-with-code-b12c0e41d4c7">Create Your Own DeepArt Clone: Pytorch Neural Style Transfer Web App Using Streamlit (With Code…</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Renify: Create Your Own Custom Renaissance Portrait Using A.I.]]></title>
            <link>https://medium.com/carre4/renify-create-your-own-custom-renaissance-portrait-using-a-i-8522a8445b8d?source=rss-6a9a11dd71c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8522a8445b8d</guid>
            <category><![CDATA[art]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[painting]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[George Davila Durendal]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 00:10:20 GMT</pubDate>
            <atom:updated>2021-03-26T14:46:04.292Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJEzKIbwBR8meuZcH1nkWA.png" /><figcaption>A.I.-generated Renaissance paintings based on real human faces.</figcaption></figure><p><em>Follow me on twitter </em><a href="https://twitter.com/GDurendal"><em>@GDurendal</em></a><em>. Guide for coders and non-coders alike to create paintings of your own towards bottom of article.</em></p><p>As a man of science and technology born in Brooklyn, far too often have I heard artists — both the delusional and the talented — claim that machines simply cannot do what they do. That in their brushstrokes and positively pernicious sense of self-importance lies something that machines simply could not replicate nor repudiate. Well, as a native of Brooklyn exhausted by these hordes of self-aggrandizing artists with oddly-colored hair, I felt that it was my duty to retaliate. So I present <a href="https://github.com/GeorgeDavila/Renify"><strong>Renify</strong></a>, an open source coding library capable of turning any photo of any human face into a beautiful renaissance-style painting. And most assuredly a definitive blow to the careers of artists everywhere (I’m joking artists, please don’t paint me).</p><p>Renify takes your face photos and turns them into renaissance style portraits. All the paintings featured in this article were generated by the A.I. It tends to take on the characteristics of your photo. If your picture is dark and brooding, it is likely that that A.I. will produce a dark and similarly styled painting. If your photo is more of a plain profile photo, the algorithm will spit out something more plain. It will generally paint the background a uniform color with a paint-looking texture. Let us compare some generated paintings to the original photos:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LvL_cgzzB1smjHViwlr86Q.png" /><figcaption>Renify paintings and the photos they were based off of.</figcaption></figure><p>Notice how the background colors and general features are preserved. The algorithm also crops images automatically, the bottom right image was cropped by the algorithm. The shading and lighting of the photos are also carried over into the algorithm.</p><p>More interestingly it even seems to take on artistic liberties of its own. Lets take a look at some results with a bit more of an artistic bent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yO-dyRxBncfKk7nDGrUB2w.png" /><figcaption>Some of the more artistic paintings.</figcaption></figure><p>In the 2 samples on the left we can observe that the algorithm essentially tries to carry over the artistic style of the photographer. In the 2 on the right it introduces its own style. In the top right sample it seems to pick up on the greenish amber color of the eyes and amplify that, to quite good effect in my opinion. In the bottom right image the algorithm seems to play off of the fact that the image lacks much besides a face. One stipulation of the algorithm is that it must produce a square image. So rather than distorting the face to fit a square it takes the approach of blending the face and the background.</p><p>And how long does it take to make these paintings? About 2–4 minutes per painting depending on the size of the photo. Here’s the code for all of you who are technically inclined:</p><p><a href="https://github.com/GeorgeDavila/Renify">GeorgeDavila/Renify</a></p><p><strong>For coders:</strong> Simply open the notebook file (Renify.ipynb) in Google Colab, select a GPU runtime, move your own photos into the stylegan2/raw/ directory and run the Setup and Run Models sections. Find your generated paintings in the stylegan2/generated/ folder, the completed image should be tagged with -renify.jpg. Plenty of instructions included in the notebook files.</p><p><strong>For the non-technical or those new at coding: </strong>don’t worry I thought of you too! Go to this link:</p><p><a href="https://colab.research.google.com/github/GeorgeDavila/Renify/blob/main/RenifyColab.ipynb">Google Colaboratory</a></p><p>And follow these instructions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YK9T9dsnbfnYfeiw_5P6hQ.png" /><figcaption>Note: Need to sign into your google account. May also need to restart your runtime after Step 2. To do this simply click Runtime &gt; Restart Runtime and then repeat step 2. Enjoy!</figcaption></figure><p>Enjoy playing around with the algorithm. You can create in 2 minutes what took the masters of renaissance art 2 months.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8522a8445b8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/carre4/renify-create-your-own-custom-renaissance-portrait-using-a-i-8522a8445b8d">Renify: Create Your Own Custom Renaissance Portrait Using A.I.</a> was originally published in <a href="https://medium.com/carre4">CARRE4</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>