1
2022-12-18 17:12:33 +00:00

214 lines
7.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/jpg" href="https:&#x2F;&#x2F;branding.ewpratten.com&#x2F;pfp&#x2F;2022&#x2F;460x460.webp" />
<link rel="canonical" href="https:&#x2F;&#x2F;ewpratten.com&#x2F;blog&#x2F;becomeranter&#x2F;" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="https://ewpratten.com/rss.xml">
<meta name="twitter:card" content="summary" />
<meta name="og:site" content="ewpratten.com" />
<meta name="og:site_name" content="Evan Pratten" />
<meta name="og:image"
content="https:&#x2F;&#x2F;branding.ewpratten.com&#x2F;pfp&#x2F;2022&#x2F;460x460.webp" />
<meta property="og:description" content="if&#x2F;else ++" />
<meta property="description" content="if&#x2F;else ++" />
<meta name="description" content="if&#x2F;else ++">
<meta property="og:title" content="Using a python script to create devRant posts based on the style and content of another user - Evan Pratten" />
<meta property="og:type" content="article" />
<title>Using a python script to create devRant posts based on the style and content of another user | Evan Pratten</title>
<link rel="stylesheet" href="/global.css">
<link rel="stylesheet" href="/dist/github-markdown-css/github-markdown-light.css" lazyload>
<link rel="stylesheet" href="/styles/bootstrap.css" lazyload>
<link rel="stylesheet" href="/styles/typography.css">
</head>
<body>
<div class="page">
<link rel="stylesheet" href="/styles/components/heading-card.css">
<div class="heading-card">
<div class="profile-photo-container">
<img src="https:&#x2F;&#x2F;branding.ewpratten.com&#x2F;pfp&#x2F;2022&#x2F;460x460.webp" alt="Profile Photo" loading="lazy">
</div>
<div class="text-container">
<h1>Evan Pratten</h1>
<p>Software Developer</p>
</div>
</div>
<div class="container">
<link rel="stylesheet" href="/styles/components/navbar.css">
<div class="ewp-navbar">
<hr>
<ul class="navbar-items">
<li><a href="/">Home</a></li>
<li class="separator">|</li>
<li><a href="/timeline">Timeline</a></li>
<li class="separator">|</li>
<li class="dropdown-center">
<a href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
More
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/photography">Photography</a></li>
<li><a class="dropdown-item" href="/contact">Contact</a></li>
</ul>
</li>
</ul>
<hr>
</div>
</div>
<article id="content" class="container markdown-body">
<h1 style="margin-bottom:0;padding-bottom:0;">Using a python script to create devRant posts based on the style and content of another user</h1>
<em>if&#x2F;else ++</em>
<br><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 rel="noopener" target="_blank" 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 &quot;magic&quot;. So first, we should install Tensorflow's dependencies.</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span>sudo apt install python3 python3-pip #change this command to fit your distro
</span><span>pip3 install numpy
</span></code></pre>
<p>Then install Tensorflow</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span>pip3 install tensorflow #for cpu processing
</span><span>pip3 install tensorflow-gpu #for gpu processing
</span></code></pre>
<p>Next up, install the rest of the stuff:</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span>pip3 install textgenrnn pandas keras
</span></code></pre>
<h2 id="clone-the-repo">Clone the repo</h2>
<p>This is pretty simple. just make sure you have <code>git</code> installed and run</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span>git clone https://github.com/Ewpratten/BecomeRanter.git
</span></code></pre>
<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>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>createsomerants.py</code> and change the variable called <code>input_file</code> to the path of your file. By default, the script generates from the <code>Linuxxx-epoch-90.hdf5</code> file.</p>
<p>Next, save that file and run the following in your terminal:</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span>python3 createsomerants.py &gt;&gt; output.txt
</span></code></pre>
<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>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>createhfd5frominput.py</code> file.</p>
<p>To start training, run:</p>
<pre style="background-color:#2b303b;color:#c0c5ce;"><code><span>python3 createhfd5frominput.py
</span></code></pre>
<p>A new hdf5 file will be generated in the same folder as the script</p>
</article>
<link rel="stylesheet" href="/styles/components/footer.css">
<div class="footer">
<br>
<span class="gray">-- EOF --</span>
<p>
Site design & content by: <a href="/contact">Evan Pratten</a><br>
Consider <a href="/donate" target="_blank">supporting my work</a> if you like what you see<br>
</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3"
crossorigin="anonymous"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script defer src="https://www.googletagmanager.com/gtag/js?id=G-5912H4H03P"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-5912H4H03P');
</script>
</body>
</html>