<head> <title>Evan Pratten</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link rel="stylesheet" href="/assets/css/main.css"> <link rel="stylesheet" href="/assets/css/github-syntax.css"> <link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono:400,400i|IBM+Plex+Sans:100,100i,400,400i,700,700i" rel="stylesheet"> </head> <body> <div class="site-ctr"> <!-- Navbar --> <nav class="navbar navbar-dark sticky-top bg-dark navbar-expand-lg"> <!-- Navbar content --> <!-- <div class="container"> --> <a class="navbar-brand" href="/">Evan Pratten</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNavAltMarkup"> <div class="navbar-nav ml-auto"> <a class="nav-item nav-link" href="/blog">Blog</a> <a class="nav-item nav-link" href="/projects">Projects</a> <a class="nav-item nav-link" href="/about">About</a> </div> <!-- </div> --> </div> </nav> <!-- <div style="height:5vh"></div> --> <!-- Header --> <!-- <div class="header"> <div class="container"> <div class="content"> </div> </div> <div class="header-gap"></div> </div> --> <div class="reactive-bg"> <div class="post container"> <h1>Using a python script to create devRant posts based on the style and content of another user</h1> <h4>if/else ++</h4> <hr> <p><em>2018-06-27 14:32:00 -0400</em></p> <br> <p>Ok… The title is slightly wrong. There are actually 2 scripts.. Sorry about that.</p> <p>This is a guide on installing and using the <a href="https://github.com/Ewpratten/BecomeRanter">BecomeRanter</a> script.</p> <h2 id="getting-dependancies">Getting dependancies</h2> <p>The scripts use Google’s tensorflow library to do its “magic”. So first, we should install Tensorflow’s dependencies.</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install python3 python3-pip #change this command to fit your distro pip3 install numpy </code></pre></div></div> <p>Then install Tensorflow</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pip3 install tensorflow #for cpu processing pip3 install tensorflow-gpu #for gpu processing </code></pre></div></div> <p>Next up, install the rest of the stuff:</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pip3 install textgenrnn pandas keras </code></pre></div></div> <h2 id="clone-the-repo">Clone the repo</h2> <p>This is pretty simple. just make sure you have <code class="highlighter-rouge">git</code> installed and run</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/Ewpratten/BecomeRanter.git </code></pre></div></div> <h2 id="generate-some-rants-with-a-hdf5-file">Generate some rants with a .hdf5 file</h2> <p>As of the time of writing this, I have pre-generated some files for the two most popular ranters. These files can be found in <code class="highlighter-rouge">BecomeRanter/Checkpoint\ Files</code>.</p> <p>Higher epoch numbers mean that they have had more time to train. The files with lower numbers are generally funnier.</p> <p>To change the .hdf5 file you would like to use, open the file called <code class="highlighter-rouge">createsomerants.py</code> and change the variable called <code class="highlighter-rouge">input_file</code> to the path of your file. By default, the script generates from the <code class="highlighter-rouge">Linuxxx-epoch-90.hdf5</code> file.</p> <p>Next, save that file and run the following in your terminal:</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>python3 createsomerants.py >> output.txt </code></pre></div></div> <p>It will not print the results out to the screen and put them in the file instead.</p> <p>To stop the script, press CTRL + C</p> <h2 id="create-your-own-hdf5-file">Create your own .hdf5 file</h2> <p>If you want to make your own hdf5 file, you just have to use the other script in the repo.</p> <p>By default, you can just put all your text to train on in the <code class="highlighter-rouge">input.txt</code> file.</p> <p>If you want to use a different file, or change the number of epochs, those variables can be found at the top of the <code class="highlighter-rouge">createhfd5frominput.py</code> file.</p> <p>To start training, run:</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>python3 createhfd5frominput.py </code></pre></div></div> <p>A new hdf5 file will be generated in the same folder as the script</p> </div> </div> </div> <div class="container"> <hr> </div> <nav class="navbar navbar-expand-lg "> <!-- Navbar content --> <div class="container"> <span class="navbar-text"> Site design by: <a href="https://retrylife.ca">Evan Pratten</a> | This site was last updated at: 2019-08-13 15:05:12 -0400 </span> </div> </nav> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <!-- Offsets for links --> <script> (function ($, window) { var adjustAnchor = function () { var $anchor = $(':target'), fixedElementHeight = 100; if ($anchor.length > 0) { window.scrollTo(0, $anchor.offset().top - fixedElementHeight); } }; $(window).on('hashchange load', function () { adjustAnchor(); }); })(jQuery, window); </script> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-74118570-2"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-74118570-2'); </script> </body>