<?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 Shreenidhi Sudhakar on Medium]]></title>
        <description><![CDATA[Stories by Shreenidhi Sudhakar on Medium]]></description>
        <link>https://medium.com/@shree6791?source=rss-1b8049b35524------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wFuhE0L3l145MoUYfUifRA.jpeg</url>
            <title>Stories by Shreenidhi Sudhakar on Medium</title>
            <link>https://medium.com/@shree6791?source=rss-1b8049b35524------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:56:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shree6791/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[From 1 Billion Requests to 3 Machines: Guide to Real-World Scaling]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shree6791.medium.com/from-1-billion-requests-to-3-machines-guide-to-real-world-scaling-71fad3b339ec?source=rss-1b8049b35524------2"><img src="https://cdn-images-1.medium.com/max/1108/1*4_i4YjfnLDdJmA-1HFGWuQ.png" width="1108"></a></p><p class="medium-feed-snippet">How to think about DAU, RPS, Little&#x2019;s Law, Go vs Python, Kubernetes pods, and failure modes &#x2014; the way it actually works in production.</p><p class="medium-feed-link"><a href="https://shree6791.medium.com/from-1-billion-requests-to-3-machines-guide-to-real-world-scaling-71fad3b339ec?source=rss-1b8049b35524------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shree6791.medium.com/from-1-billion-requests-to-3-machines-guide-to-real-world-scaling-71fad3b339ec?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/71fad3b339ec</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Sat, 30 May 2026 06:04:49 GMT</pubDate>
            <atom:updated>2026-05-30T06:05:38.263Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Designing a Distributed Cache Platform at Twitter Scale]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Caching at Twitter is not a single Redis instance behind one service. It is a fully managed internal platform used by hundreds of teams&#x2026;</p><p class="medium-feed-link"><a href="https://shree6791.medium.com/designing-a-distributed-cache-platform-at-twitter-scale-24428fa964fa?source=rss-1b8049b35524------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shree6791.medium.com/designing-a-distributed-cache-platform-at-twitter-scale-24428fa964fa?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/24428fa964fa</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Mon, 23 Mar 2026 00:13:29 GMT</pubDate>
            <atom:updated>2026-03-23T00:36:21.825Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[A Real Decision Framework for Picking the Right Database]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shree6791.medium.com/a-real-decision-framework-for-picking-the-right-database-505e968e0b67?source=rss-1b8049b35524------2"><img src="https://cdn-images-1.medium.com/max/1410/1*T4AcOdpljelqX696nyIpJg.png" width="1410"></a></p><p class="medium-feed-snippet">Every junior engineer has heard this advice:</p><p class="medium-feed-link"><a href="https://shree6791.medium.com/a-real-decision-framework-for-picking-the-right-database-505e968e0b67?source=rss-1b8049b35524------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shree6791.medium.com/a-real-decision-framework-for-picking-the-right-database-505e968e0b67?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/505e968e0b67</guid>
            <category><![CDATA[database-design]]></category>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 22:59:10 GMT</pubDate>
            <atom:updated>2026-03-22T23:07:18.742Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The Data Structures That Power Modern Databases: How Trees, Logs, and Graphs Keep the World’s Data…]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shree6791.medium.com/the-data-structures-that-power-modern-databases-how-trees-logs-and-graphs-keep-the-worlds-data-5f70c5174a7e?source=rss-1b8049b35524------2"><img src="https://cdn-images-1.medium.com/max/1072/1*DeBtbEgYpglbVmRvRW95bw.png" width="1072"></a></p><p class="medium-feed-snippet">1. Databases Aren&#x2019;t Magic&#x200A;&#x2014;&#x200A;They&#x2019;re Math in Motion</p><p class="medium-feed-link"><a href="https://shree6791.medium.com/the-data-structures-that-power-modern-databases-how-trees-logs-and-graphs-keep-the-worlds-data-5f70c5174a7e?source=rss-1b8049b35524------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shree6791.medium.com/the-data-structures-that-power-modern-databases-how-trees-logs-and-graphs-keep-the-worlds-data-5f70c5174a7e?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f70c5174a7e</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 20:59:04 GMT</pubDate>
            <atom:updated>2025-10-28T20:59:04.497Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[From Tables to Vectors: Understanding Databases by Their Core Logic]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://shree6791.medium.com/from-tables-to-vectors-understanding-databases-by-their-core-logic-25624efbc523?source=rss-1b8049b35524------2"><img src="https://cdn-images-1.medium.com/max/1534/1*X1WMyy2AoizJa8xn_U1JOA.png" width="1534"></a></p><p class="medium-feed-snippet">1. Every Product Lives or Dies by Its Memory</p><p class="medium-feed-link"><a href="https://shree6791.medium.com/from-tables-to-vectors-understanding-databases-by-their-core-logic-25624efbc523?source=rss-1b8049b35524------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://shree6791.medium.com/from-tables-to-vectors-understanding-databases-by-their-core-logic-25624efbc523?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/25624efbc523</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 20:11:54 GMT</pubDate>
            <atom:updated>2025-10-28T20:11:54.126Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Designing a Newsfeed Ranking System: How Social Media Decides What You See]]></title>
            <link>https://shree6791.medium.com/designing-a-newsfeed-ranking-system-how-social-media-decides-what-you-see-d9edee45c087?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9edee45c087</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 01:34:16 GMT</pubDate>
            <atom:updated>2025-09-06T01:34:16.748Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction: The Invisible Algorithm</h3><p>Open Facebook, Instagram, or LinkedIn and refresh your feed. Out of billions of possible posts, only 20 or so rise to the top in a fraction of a second.</p><p>This isn’t random. It’s the work of one of the most consequential machine learning systems in existence: the <strong>newsfeed ranking system</strong>.</p><p>At Meta scale, even a <strong>1% improvement in ranking quality means billions of dollars in revenue and millions of user hours shifted</strong>. That’s why designing this system is not only a favorite interview case but also one of the hardest applied ML challenges in the industry.</p><h3>1. Framing the Problem</h3><p>A ranking system must balance <strong>three competing goals</strong>:</p><ol><li><strong>Engagement:</strong> keep users returning and interacting.</li><li><strong>Integrity:</strong> avoid harmful, spammy, or manipulative content.</li><li><strong>Fairness:</strong> ensure exposure for both popular creators and smaller voices.</li></ol><p><strong>Core metrics:</strong></p><ul><li><strong>Retention:</strong> Day-7 return rate.</li><li><strong>Session length / watch time:</strong> How long users stay.</li><li><strong>Guardrails:</strong> Diversity, long meaningful interactions (not just shallow clicks), safety checks.</li></ul><p>📌 <strong>Engineer callout:</strong> At scale, retention is the North Star. Engagement spikes without retention mean nothing. Guardrails ensure optimization doesn’t “burn the commons” by flooding feeds with low-quality clickbait.</p><h3>2. The System Shape: A Three-Stage Funnel</h3><ol><li><strong>Candidate Generation (Recall):</strong> Fetch ~1,000 promising posts from billions.<br> <em>Analogy:</em> entering a massive library and pulling a few shelves of likely books.</li><li><strong>Ranking:</strong> Sort the 1,000 candidates into a top-20 list.<br> <em>Analogy:</em> choosing which of those books to actually read first.</li><li><strong>Post-Ranking:</strong> Apply policy rules to ensure diversity, freshness, and fairness.<br> <em>Analogy:</em> making sure your bookshelf isn’t filled with only cookbooks.</li></ol><p>⏱ <strong>Latency budget:</strong> &lt;100ms p99, serving billions of requests per day.</p><p>📌 <strong>Engineer callout:</strong> Serving QPS at Meta scale means latency spikes (p99) are existential. Every extra millisecond multiplies into millions of wasted compute hours. This is why two-stage designs are standard: cheap recall + expensive precise ranking.</p><h3>3. Data: The Fuel of Ranking</h3><p>Ranking lives or dies by its data.</p><p><strong>Implicit signals:</strong> clicks, likes, dwell time. Abundant but noisy.<br><strong>Explicit signals:</strong> hides, reports, surveys. Clear but sparse.</p><p><strong>Biases:</strong></p><ul><li><em>Position bias:</em> higher slots get more clicks just by being visible.</li><li><em>Selection bias:</em> we only observe outcomes for shown posts.</li></ul><p><strong>Cold-start problems:</strong></p><ul><li><em>New user:</em> no history → ask for interests, use priors, or start with popular posts.</li><li><em>New post:</em> no engagement → rely on text/image/video embeddings + creator trust score.</li></ul><p><strong>Feature freshness:</strong></p><ul><li>Real-time (likes in last 10 minutes).</li><li>Batch (lifetime likes).</li><li>Managed in a <strong>feature store</strong> to ensure training-serving consistency.</li></ul><p>📌 <strong>Engineer callout:</strong> Production failures often come from <em>training-serving skew</em>. If training data uses a 5-minute delayed feature but serving uses a 1-hour delayed one, calibration breaks. Strict point-in-time joins and freshness SLAs are non-negotiable.</p><h3>4. Modeling the System</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8oH33WK6a5Dejx2zRDuuwg.png" /></figure><h3>Candidate Generation: Casting a Wide Net</h3><ul><li><strong>Two-Tower Model:</strong> User tower encodes preferences, item tower encodes posts, dot product measures relevance. Stored in fast ANN indices (FAISS, ScaNN).</li><li><strong>Graph-based recall:</strong> Spread engagement signals through the social graph. <em>If 10 friends liked it, you might too.</em></li><li><strong>Popularity heuristics:</strong> Trending posts in short time windows (10–30 min).</li><li><strong>Content similarity:</strong> Embeddings surface brand-new posts similar to past favorites.</li></ul><p>👉 <em>Goal:</em> breadth. Better to recall too many than to miss one valuable candidate.</p><p>📌 <strong>Engineer callout:</strong> Recall is a precision–latency trade-off. Larger candidate pools improve coverage but blow up serving costs. Tuning K in “recall top-K” is one of the most debated infra trade-offs.</p><h3>Ranking: Precision Over Breadth</h3><h4>Training objectives</h4><ul><li><strong>Pointwise:</strong> predict engagement probability for each post.</li><li><strong>Pairwise:</strong> train on clicked vs skipped pairs.</li><li><strong>Listwise:</strong> optimize the whole ordering (best aligned with user experience).</li></ul><h4>Deep architectures for ranking</h4><ul><li><strong>Wide &amp; Deep:</strong> memorizes frequent patterns + generalizes to unseen ones.</li><li><strong>DeepFM:</strong> learns hidden feature interactions automatically.</li><li><strong>Transformers:</strong> understand context in text captions, video frames, and audio.</li></ul><p>📌 <strong>Engineer callout:</strong> Wide &amp; Deep remains the production workhorse because it’s latency-friendly. Transformers boost offline metrics but are costly at serving time. In practice, many companies use hybrid models: transformer-based embeddings for recall, Wide &amp; Deep for real-time ranking.</p><h3>Post-Ranking: Guardrails</h3><ul><li><strong>Diversity rules:</strong> ensure mix of categories.</li><li><strong>MMR (Maximal Marginal Relevance):</strong> balances relevance and variety.</li><li><strong>Exposure caps:</strong> prevent one creator from flooding the feed.</li><li><strong>Freshness boosts:</strong> surface timely posts.</li></ul><p>📌 <strong>Engineer callout:</strong> This layer is where <em>governance</em> meets ML. Without post-ranking, feeds collapse into monocultures (all sports, all memes). This is a must-have, not a “nice-to-have.”</p><h3>5. Evaluating Success</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHag2RKtPe0ebDVWR1huog.png" /></figure><h3>Offline evaluation</h3><ul><li><strong>AUC:</strong> how often clicked &gt; skipped in logs.</li><li><strong>NDCG:</strong> rewards putting valuable posts higher.</li><li><strong>Calibration:</strong> predicted vs actual probabilities match.</li><li><strong>Diversity:</strong> coverage across creators and topics.</li></ul><p>📌 <strong>Engineer callout:</strong> AUC is fine for Kaggle. In production, NDCG@20 and calibration are king. Top slots drive retention; miscalibration sinks A/B tests.</p><h3>Replay evaluation (off-policy)</h3><ul><li><strong>IPS:</strong> reweights logs to correct position bias.</li><li><strong>Doubly robust (DR):</strong> blends IPS with a model for lower variance.</li></ul><p>Analogy: Watching yesterday’s soccer match and asking, <em>“What if we used a different formation?”</em></p><p>📌 <strong>Engineer callout:</strong> Replay looks rigorous but suffers from high variance. Senior engineers know to treat IPS results as directional, not launch-blocking.</p><h3>Online A/B testing</h3><ul><li><strong>Split traffic:</strong> old vs new.</li><li><strong>Guardrails:</strong> bounce rate, fairness, safety must not regress.</li><li><strong>Ramp plan:</strong> Shadow → 1% → 10% → 50% → 100%.</li><li><strong>Kill switch:</strong> rollback instantly if metrics tank.</li><li><strong>CUPED:</strong> reduces noise, cutting test duration by weeks.</li></ul><p>📌 <strong>Engineer callout:</strong> At Meta scale, a “1% canary” means millions of users. Guardrails and kill switches aren’t optional. Many infra teams run shadow + canary pipelines continuously to reduce rollout risk.</p><h3>6. Challenges: Integrity and Fairness</h3><ul><li><strong>Clickbait:</strong> CTR-only optimization fills feeds with junk.</li><li><strong>Spam &amp; bots:</strong> fake engagement pollutes training data.</li><li><strong>Fairness:</strong> popular creators dominate; small voices vanish.</li><li><strong>Well-being:</strong> more time ≠ more satisfaction.</li></ul><p>Solutions: downranking low-trust content, long-click optimization, fairness audits, adversarial model monitoring.</p><p>📌 <strong>Engineer callout:</strong> Long-click/dwell time is a proxy for satisfaction. Without it, models optimize the wrong behavior loop. This distinction is one of the hardest lessons new engineers learn.</p><h3>7. Deployment &amp; Operations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnrm7ZPpv7tK6pV55Qc_1A.png" /></figure><ul><li><strong>Infra:</strong> microservices, autoscaling, embedding caches.</li><li><strong>Model registry:</strong> track versions, support rollback.</li><li><strong>Monitoring:</strong></li><li><em>System: QPS, p99 latency, error rate.</em></li><li><em>Data: feature freshness, schema drift.</em></li><li><em>Model: calibration drift, population stability (PSI).</em></li><li><strong>Playbooks:</strong> on-call rotations, kill switches, post-mortems.</li></ul><p>📌 <strong>Engineer callout:</strong> Drift detection is critical. PSI shifts of even 5–10% can predict A/B test failures weeks in advance.</p><h3>8. Business &amp; Leadership Layer</h3><p>Ranking is a <strong>business lever</strong>, not just an algorithm.</p><ul><li><strong>Revenue:</strong> 1% retention uplift = billions in ad revenue.</li><li><strong>Governance:</strong> guardrails protect trust and avoid regulatory blowback.</li><li><strong>Leadership execution:</strong> retrieval team, ranking team, and feature freshness team work in parallel. A senior engineer aligns them to milestones and shared KPIs.</li></ul><p>📌 <strong>Engineer callout:</strong> E6+ engineers are judged on influence across teams. Owning “ranking” means coordinating infra, ML, and product, not just building models.</p><h3>9. Closing Thoughts</h3><p>Newsfeed ranking is the ultimate ML design problem. It demands:</p><ul><li><strong>Breadth:</strong> retrieval, ranking, evaluation, ops.</li><li><strong>Depth:</strong> trade-offs between latency, fairness, business goals.</li><li><strong>Judgment:</strong> balancing engagement vs well-being.</li></ul><p>Get it right, and billions of people feel informed and entertained. Get it wrong, and you risk eroding trust at planetary scale.</p><p>📌 <strong>Engineer takeaway:</strong> This is not just a model. It’s a socio-technical system where <strong>engineering judgment is as important as gradient descent.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9edee45c087" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Part 8: Your First AI Project — Turn Your Face Into a Storybook or Character Series]]></title>
            <link>https://shree6791.medium.com/part-8-your-first-ai-project-turn-your-face-into-a-storybook-or-character-series-d04b1960fce3?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/d04b1960fce3</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 20:06:44 GMT</pubDate>
            <atom:updated>2025-04-28T20:06:44.503Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Stable Diffusion — Part 8: Your First AI Project — Turn Your Face Into a Storybook or Character Series</h3><blockquote><em>“You’ve learned the tools — now it’s time to create something magical with them.”</em></blockquote><h3>🎯 The Goal</h3><p>In this project, you’ll create a <strong>series of AI-generated images starring YOU</strong> — in any world, any style, any identity.</p><p>Examples:</p><ul><li>You as a royal in 10 different kingdoms 👑</li><li>You in a sci-fi comic as a bounty hunter 🧑‍🚀</li><li>A fantasy storybook featuring your pet as a wizard 🐾🧙</li><li>Yourself across 5 historical eras</li></ul><p>You’ll use everything we’ve learned: <strong>LoRA + ControlNet + IP-Adapter + Prompt Engineering</strong>.</p><h3>🗂️ What You’ll Need</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*YRyNy5DLTyusftx_uARuZw.png" /></figure><h3>🧱 Step-by-Step Blueprint</h3><h4>🔧 1. Train Your LoRA (One-Time Step)</h4><p>Use kohya_ss, Hugging Face, or a Colab to train LoRA on your selfies.</p><p>Output: sks_person_lora.safetensors</p><h4>🖼️ 2. Gather Your Inputs</h4><ul><li>A <strong>pose photo</strong> (for ControlNet OpenPose)</li><li>A <strong>clean selfie</strong> (for IP-Adapter)</li><li>Your <strong>prompt</strong>, like:</li></ul><blockquote><em>“sks_person as a medieval knight in full armor, cinematic lighting, castle background”</em></blockquote><h3>🧪 3. Combine Everything in Code</h3><p>Here’s a full working example that brings everything together: LoRA + ControlNet + IP-Adapter + your prompt.</p><pre>from diffusers import StableDiffusionPipeline, ControlNetModel<br>from ip_adapter import IPAdapter<br>from controlnet_aux import OpenposeDetector<br>from PIL import Image</pre><pre><strong># Load base model and apply LoRA<br></strong>pipe = StableDiffusionPipeline.from_pretrained(&quot;runwayml/stable-diffusion-v1-5&quot;)<br>pipe.load_lora_weights(&quot;./lora_sks_person&quot;)<br>pipe.to(&quot;cuda&quot;)</pre><pre><strong># Load ControlNet for pose<br></strong>controlnet = ControlNetModel.from_pretrained(&quot;lllyasviel/sd-controlnet-openpose&quot;)<br>pipe.controlnet = controlnet<br>pose_image = OpenposeDetector().detect(Image.open(&quot;pose_reference.jpg&quot;))</pre><pre><strong># Apply IP-Adapter (reference image for your face)<br></strong>ref_face = Image.open(&quot;clean_selfie.jpg&quot;)<br>pipe = IPAdapter(pipe).add_reference_image(ref_face)</pre><pre><strong># Generate your themed image<br></strong>prompt = &quot;sks_person as a medieval knight, cinematic lighting, armor, forest backdrop&quot;<br>image = pipe(prompt, image=pose_image, num_inference_steps=30, guidance_scale=7.5).images[0]<br>image.save(&quot;outputs/knight_sks_person.png&quot;)</pre><p>Want to generate 10 variations? Just loop through a list of themed prompts and save each image.</p><pre>themes = [<br>  &quot;a cyberpunk hacker&quot;,<br>  &quot;a wizard casting a spell&quot;,<br>  &quot;a king on a throne in Rome&quot;,<br>  &quot;a space explorer on Mars&quot;<br>]</pre><pre># <strong>Loop over a list of themed prompts to generate a full collection.<br></strong>for i, theme in enumerate(themes):<br>    prompt = f&quot;sks_person as {theme}&quot;<br>    image = pipe(prompt, image=pose_image).images[0]<br>    image.save(f&quot;outputs/{i:02d}_{theme.replace(&#39; &#39;, &#39;_&#39;)}.png&quot;)</pre><p>Optional: Generate a title or caption using GPT:</p><pre>from transformers import pipeline<br>captioner = pipeline(&quot;image-to-text&quot;)<br>caption = captioner(image)[0][&#39;generated_text&#39;]</pre><h3>🌍 Where to Share It</h3><p>Once you’ve built your storybook or visual series:</p><ul><li>Post to <strong>X, LinkedIn, or Instagram</strong> (tag us!)</li><li>Publish on <strong>Notion, Substack, or Medium</strong></li><li>Print as a gift or zine 🎁</li></ul><p>You’ve just turned AI into a <strong>personal publishing engine</strong>.</p><h3>🧠 Reflection</h3><p>You didn’t just “play with a model” — you:</p><ul><li>Learned diffusion architecture</li><li>Customized identity with LoRA</li><li>Controlled structure with ControlNet</li><li>Plugged in style via IP-Adapter</li><li>And told a story <em>with yourself at the center</em></li></ul><p>That’s the future of creativity. And you’re already building it.</p><p><em>Written by Shreenidhi — helping people tell their own stories using pixels and possibility.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d04b1960fce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Part 7:  Code Recipes for Every Scenario — Stable Diffusion in Action]]></title>
            <link>https://shree6791.medium.com/part-7-code-recipes-for-every-scenario-stable-diffusion-in-action-790c6beb890f?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/790c6beb890f</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 20:02:35 GMT</pubDate>
            <atom:updated>2025-04-28T20:02:35.106Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Stable Diffusion — Part 7: 🔧 Code Recipes for Every Scenario — Stable Diffusion in Action</h3><blockquote><em>“You’ve got the tools. Now let’s cook up some magic — one recipe at a time.”</em></blockquote><h3>🍳 Why This Part Exists</h3><p>So far, we’ve covered <strong>how</strong> Stable Diffusion, LoRA, ControlNet, and IP-Adapter work.</p><p>But what if you just want to:</p><ul><li>🎯 Copy-paste a working code snippet</li><li>🧪 Try a variation with your own prompt/image</li><li>🎨 Stack modules like building blocks</li></ul><p>This part gives you a <strong>cheat sheet of code recipes</strong> for different creative tasks.</p><p>All examples use the Hugging Face diffusers library unless noted otherwise.</p><h3>📥 Setup (Once Per Session)</h3><pre>pip install diffusers transformers accelerate torch controlnet_aux</pre><h3>🧁 1. Basic Text-to-Image with Stable Diffusion</h3><pre>from diffusers import StableDiffusionPipeline<br>pipe = StableDiffusionPipeline.from_pretrained(&quot;runwayml/stable-diffusion-v1-5&quot;)<br>pipe.to(&quot;cuda&quot;)</pre><pre>image = pipe(&quot;a cozy cabin in the snow, 4k concept art&quot;).images[0]<br>image.save(&quot;output_basic.png&quot;)</pre><h3>🎭 2. Add IP-Adapter for Identity/Style Transfer</h3><pre>from PIL import Image<br>from ip_adapter import IPAdapter</pre><pre>ref_image = Image.open(&quot;my_face.jpg&quot;)<br>pipe = IPAdapter(pipe).add_reference_image(ref_image)<br>image = pipe(&quot;a superhero flying through the sky&quot;).images[0]<br>image.save(&quot;output_ipadapter.png&quot;)</pre><h3>🕺 3. Add ControlNet for Pose Guidance</h3><pre>from diffusers import StableDiffusionControlNetPipeline, ControlNetModel<br>from controlnet_aux import OpenposeDetector</pre><pre>controlnet = ControlNetModel.from_pretrained(&quot;lllyasviel/sd-controlnet-openpose&quot;)<br>pipe = StableDiffusionControlNetPipeline.from_pretrained(<br>  &quot;runwayml/stable-diffusion-v1-5&quot;, controlnet=controlnet).to(&quot;cuda&quot;)</pre><pre>pose_img = OpenposeDetector().detect(Image.open(&quot;pose_photo.jpg&quot;))<br>image = pipe(&quot;a robot knight sitting on a throne&quot;, image=pose_img).images[0]<br>image.save(&quot;output_pose.png&quot;)</pre><h3>🧑‍🎨 4. Load and Use a Trained LoRA (Your Identity/Style)</h3><pre>pipe.load_lora_weights(&quot;./lora_sks_person&quot;)<br>prompt = &quot;sks_person as a cyberpunk king in golden light&quot;<br>image = pipe(prompt).images[0]<br>image.save(&quot;output_lora.png&quot;)</pre><h3>🎬 5. Combine All: LoRA + ControlNet + IP-Adapter</h3><pre>pipe.load_lora_weights(&quot;./lora_sks_person&quot;)<br>controlnet = ControlNetModel.from_pretrained(&quot;lllyasviel/sd-controlnet-openpose&quot;)<br>pipe.controlnet = controlnet</pre><pre>pose_img = OpenposeDetector().detect(Image.open(&quot;pose.jpg&quot;))<br>ref_face = Image.open(&quot;clean_portrait.jpg&quot;)<br>pipe = IPAdapter(pipe).add_reference_image(ref_face)</pre><pre>prompt = &quot;sks_person as a fantasy emperor, cinematic portrait lighting&quot;<br>image = pipe(prompt, image=pose_img).images[0]<br>image.save(&quot;output_full_combo.png&quot;)</pre><h3>🧠 Bonus Tips</h3><ul><li>Use pipe(prompt, guidance_scale=7.5) to boost adherence to your prompt.</li><li>Try num_inference_steps=50 for sharper images, or reduce for speed.</li><li>Explore schedulers like DDIMScheduler or EulerAncestralScheduler to experiment with different image styles.</li></ul><h3>✅ Ready to Build?</h3><p>These recipes are just a starting point. Mix, match, and remix them to:</p><ul><li>Create consistent branded visuals</li><li>Make illustrated stories with yourself as the star</li><li>Build image-generation tools for your team or business</li></ul><p>Coming soon in Part 8: <strong>Your First AI Project — Turn Your Face Into a Storybook or Character Series</strong> 🎉</p><p><em>Written by Shreenidhi — turning ideas into pixels, one recipe at a time.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=790c6beb890f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Part 6: The Ultimate Combo — LoRA + ControlNet + IP-Adapter + Prompt]]></title>
            <link>https://shree6791.medium.com/part-6-the-ultimate-combo-lora-controlnet-ip-adapter-prompt-c938fcb43b27?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/c938fcb43b27</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 19:56:45 GMT</pubDate>
            <atom:updated>2025-04-28T19:56:45.632Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Stable Diffusion — Part 6: The Ultimate Combo — LoRA + ControlNet + IP-Adapter + Prompt</h3><blockquote><em>“Imagine telling AI: ‘Use </em>my face<em>, keep </em>this pose<em>, follow </em>this sketch<em>, and make it </em>cyberpunk<em>.’ With the right tools combined, you can.”</em></blockquote><h3>🚀 What We’ve Learned So Far</h3><p>Let’s recap what each tool gives us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GM6gVtT25fKVogLV90Yn-Q.png" /></figure><p>Individually, each is powerful. <strong>Together?</strong> You get <strong>god-level control</strong> over what AI draws.</p><h3>🖼️ Real-World Example</h3><blockquote><em>Goal: Create a poster of </em><strong><em>yourself</em></strong><em>, sitting like a king, wearing cyberpunk armor, in a cinematic setting.</em></blockquote><p>Here’s how you’d approach it:</p><ul><li>🎨 <strong>Prompt</strong>: “a cinematic portrait of sks_person as a cyberpunk king, dramatic lighting”</li><li>🧍‍♂️ <strong>ControlNet</strong>: Pose map from a photo of a person sitting regally</li><li>🧠 <strong>LoRA</strong>: sks_person_lora trained on your selfies</li><li>🖼️ <strong>IP-Adapter</strong>: Inject extra likeness from a clean portrait</li></ul><p>🎯 Result: A cyberpunk king that <strong>looks like you</strong>, sits like the original photo, and matches the prompt theme.</p><h3>⚙️ Combined Workflow Diagram (Conceptual)</h3><pre>[ Text Prompt ]<br>       ↓<br>  [ CLIP Text Embedding ]<br>       ↓<br>[ Latent Noise Space ]<br>       ↓<br>→ ControlNet (pose guidance)<br>→ LoRA (trained identity)<br>→ IP-Adapter (reference face/style)<br>       ↓<br>     [ U-Net ]<br>       ↓<br>   [ VAE Decoder ]<br>       ↓<br>  [ Final Image 🎨 ]</pre><h3>🧪 Code: Putting It All Together (Conceptual Pseudocode)</h3><pre>from diffusers import StableDiffusionPipeline, ControlNetModel<br>from ip_adapter import IPAdapter<br>from controlnet_aux import OpenposeDetector<br>from PIL import Image</pre><pre># Load base + LoRA + ControlNet<br>pipe = StableDiffusionPipeline.from_pretrained(&quot;runwayml/stable-diffusion-v1-5&quot;)<br>pipe.load_lora_weights(&quot;./lora_sks_person&quot;)<br>controlnet = ControlNetModel.from_pretrained(&quot;lllyasviel/sd-controlnet-openpose&quot;)<br>pipe.controlnet = controlnet<br>pipe.to(&quot;cuda&quot;)</pre><pre># Load pose + face reference<br>pose_image = OpenposeDetector().detect(Image.open(&quot;king_pose.jpg&quot;))<br>face_reference = Image.open(&quot;portrait.jpg&quot;)</pre><pre># Apply IP-Adapter<br>pipe = IPAdapter(pipe).add_reference_image(face_reference)</pre><pre># Generate<br>prompt = &quot;a cinematic cyberpunk king, sks_person, regal lighting&quot;<br>image = pipe(prompt, image=pose_image).images[0]<br>image.save(&quot;final_result.png&quot;)</pre><blockquote><em>You now have structure, identity, and creative theme — all working together.</em></blockquote><h3>🎯 Why This Is Powerful</h3><p>This multi-condition setup lets you:</p><ul><li>Design <strong>consistent characters</strong> across scenes</li><li>Create <strong>branded avatars</strong> that appear anywhere</li><li>Illustrate comics, games, or storytelling content</li><li>Replace green screens with imagination</li></ul><p>It’s personalized AI creativity — with dials for everything.</p><h3>🔚 Where Do We Go From Here?</h3><p>This wraps up our core series — but it’s just the beginning. Next steps could include:</p><ul><li>🧠 Fine-tuning for professional workflows</li><li>🧃 Style mixing, multi-LoRA fusion</li><li>🌐 Hosting a UI so others can generate <em>you</em> too</li><li>📦 Packaging your generation pipeline into a tool or product</li></ul><p>Thanks for being on this creative ride. Let’s keep building.</p><p><em>Written by Shreenidhi — blending identity, structure, and imagination into images that feel like magic.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c938fcb43b27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Part 5: Teach the AI — How LoRA Learns What You Look Like]]></title>
            <link>https://shree6791.medium.com/part-5-teach-the-ai-how-lora-learns-what-you-look-like-bfda202b08e1?source=rss-1b8049b35524------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfda202b08e1</guid>
            <dc:creator><![CDATA[Shreenidhi Sudhakar]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 19:56:45 GMT</pubDate>
            <atom:updated>2025-04-28T19:56:45.597Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 Stable Diffusion — Part 5: Teach the AI — How LoRA Learns What You Look Like</h3><blockquote><em>“What if AI could </em>remember<em> you — so you don’t have to upload your photo every time? That’s what LoRA lets you do.”</em></blockquote><h3>🎯 Why LoRA Exists</h3><p>In Part 4, we saw that <strong>IP-Adapter</strong> lets you guide image generation using a reference photo — no training required. It’s fast and flexible, but the model <strong>forgets your identity after each use</strong>.</p><p>What if you want the AI to <strong>remember your face or art style permanently</strong>? That’s where <strong>LoRA</strong> comes in.</p><h3>🧑‍🎓 What Is LoRA?</h3><p><strong>LoRA</strong> stands for <em>Low-Rank Adaptation</em>. It’s a smart way to <strong>fine-tune large models like Stable Diffusion without retraining everything from scratch</strong>.</p><p>It works by:</p><ul><li>Inserting <strong>tiny trainable matrices</strong> into the U-Net (and/or text encoder)</li><li>Only updating those small parts — so training is fast and memory-efficient</li><li>Letting you inject new knowledge (your face, your style, your character) into the model</li></ul><p>Once trained, LoRA can be <strong>plugged in like a LEGO block</strong> — and reused across prompts, tools, and workflows.</p><h3>🧸 Real-World Example</h3><p>You give the model 5–10 clear selfies. You train a LoRA named sks_person_lora. Now you can use prompts like:</p><blockquote><em>“A cinematic portrait of sks_person_lora as a king in a golden palace.”</em></blockquote><p>The model now <em>remembers your identity</em> — across any scene, pose, or outfit.</p><h3>🔬 LoRA vs IP-Adapter (At a Glance)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdD01Hgn7koLs3ESFZQr9w.png" /></figure><p>Use <strong>LoRA</strong> for long-term reuse. Use <strong>IP-Adapter</strong> for quick, one-off tasks.</p><h3>🧪 How to Train a LoRA</h3><h4>🔧 Tools You Can Use:</h4><ul><li>🧨 Hugging Face diffusers + peft</li><li>🧪 Kohya_ss (popular UI-based toolkit)</li><li>🧠 Automatic1111 + LoRA training extension</li></ul><h4>📸 What You Need:</h4><ul><li>5–10 clear photos (front, side, upper-body, etc.)</li><li>A concept name like sks_person</li></ul><h4>🧪 Example Workflow (Hugging Face / diffusers)</h4><pre># Install dependencies<br>pip install diffusers transformers peft accelerate bitsandbytes</pre><pre># Prepare your image dataset in a folder (e.g. training_images/)</pre><pre># Run LoRA training (simplified CLI or notebook)<br>python train_lora.py \<br>  --pretrained_model_name_or_path=&quot;runwayml/stable-diffusion-v1-5&quot; \<br>  --instance_data_dir=&quot;./training_images&quot; \<br>  --output_dir=&quot;./lora_sks_person&quot; \<br>  --instance_prompt=&quot;a photo of sks_person&quot;</pre><blockquote><em>Want it easier? Use a Colab or GUI-based tool like </em><em>kohya_ss, which handles tagging, captions, and scheduler tuning for you.</em></blockquote><h4>🖼️ Using a Trained LoRA in Generation</h4><p>Once your LoRA is trained, just plug it in:</p><pre>pipe.load_lora_weights(&quot;./lora_sks_person&quot;)<br>prompt = &quot;a regal painting of sks_person in medieval armor&quot;<br>image = pipe(prompt).images[0]</pre><p>That’s it — now the AI <em>knows you.</em></p><h3>🌟 Real Use Cases</h3><ul><li>Personalized avatars or storybooks</li><li>Brand mascots or product styles</li><li>Consistent characters across comics</li><li>Style transfer for niche artists</li><li>Creating yourself in any fantasy world</li></ul><h3>🚀 Coming Next: All Together Now</h3><p>In <strong>Part 6</strong>, we’ll combine everything:</p><ul><li>LoRA (identity)</li><li>ControlNet (pose/layout)</li><li>IP-Adapter (reference style)</li><li>Prompt (creative theme)</li></ul><p>Imagine generating <em>you</em>, in a specific pose, with a specific outfit — all in one go.</p><p>Let’s put it all together in the next post.</p><p><em>Written by Shreenidhi — helping AI learn who you are, and then reimagine you anywhere.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfda202b08e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>