Memeski & Fora
Fora Fora
Hey Memeski, imagine an AI that drafts memes on the fly—like a meme‑generator that learns your sarcasm. Could we build a prototype that learns to meme your mood?
Memeski Memeski
Yeah, let’s hack a quick prototype that learns my sarcasm, but don’t be surprised if it starts meme‑filtering your mood like a cat filters your photos—pure chaos and a lot of ā€œI can’t evenā€ vibes. Ready to see it fail or succeed?
Fora Fora
Let’s grab a fresh notebook, throw in a LLM, and teach it sarcasm from your tweets. Then we’ll add a mood‑classifier that tags posts with ā€œI can’t evenā€ before it spits memes. Expect bugs, but hey, if it’s going to fail it’s going to fail spectacularly. Ready to crash the demo?
Memeski Memeski
Let’s do it—drop a meme into the void, watch it explode, and celebrate the glorious ā€œI can’t evenā€ moments. Bring it on!
Fora Fora
Alright, fire up the dev container, hit run, and watch the sarcasm engine scream—glorious chaos incoming. Let's meme the void and let the ā€œI can’t evenā€ vibes ripple. Onward!
Memeski Memeski
Here’s a minimal Python script that will spin up a little sarcasm‑meme engine in your container. Just drop it in a folder, run `pip install -r requirements.txt`, then `python meme_gen.py`. It’ll pull in a small LLM, read a list of your tweets (or any text file), train a quick sarcasm classifier, and spit out memes that hit ā€œI can’t evenā€ right on cue. ```text # requirements.txt transformers==4.40.0 torch==2.2.0 datasets==2.20.0 scikit-learn==1.5.0 pillow==10.4.0 ``` ```python # meme_gen.py import random import re import os import torch from transformers import AutoModelForCausalLM, AutoTokenizer from sklearn.linear_model import LogisticRegression from sklearn.feature_extraction.text import CountVectorizer from PIL import Image, ImageDraw, ImageFont import textwrap # 1ļøāƒ£ Load a tiny LLM (you can swap for any HuggingFace model) MODEL_NAME = "gpt2" tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) model = AutoModelForCausalLM.from_pretrained(MODEL_NAME) model.eval() # 2ļøāƒ£ Load your tweets (or any text) – make sure it’s a simple .txt file TWEET_FILE = "tweets.txt" if not os.path.exists(TWEET_FILE): print(f"Create a {TWEET_FILE} file with your favorite sarcastic tweets.") exit(1) with open(TWEET_FILE, "r", encoding="utf-8") as f: tweets = [line.strip() for line in f if line.strip()] # 3ļøāƒ£ Train a sarcasm classifier (super‑quick, not perfect) vectorizer = CountVectorizer(ngram_range=(1,2), min_df=1) X = vectorizer.fit_transform(tweets) y = [1 if "sarcasm" in tweet.lower() else 0 for tweet in tweets] clf = LogisticRegression(max_iter=200).fit(X, y) # 4ļøāƒ£ Helper: decide if a sentence is ā€œI can’t evenā€ mood def ican_even(sentence): return re.search(r"\bcan't even\b", sentence.lower()) is not None # 5ļøāƒ£ Generate meme text def generate_meme(seed=""): inputs = tokenizer.encode(seed, return_tensors="pt") with torch.no_grad(): outputs = model.generate(inputs, max_length=50, num_return_sequences=1, pad_token_id=50256) text = tokenizer.decode(outputs[0], skip_special_tokens=True) # Clean up trailing prompt return text.strip() # 6ļøāƒ£ Render meme image def render_meme(text, filename="meme.png"): width, height = 500, 500 background = Image.new("RGB", (width, height), (255, 255, 255)) draw = ImageDraw.Draw(background) try: font = ImageFont.truetype("arial.ttf", 28) except: font = ImageFont.load_default() # Wrap text lines = textwrap.wrap(text, width=35) y_text = 150 for line in lines: w, h = draw.textsize(line, font=font) draw.text(((width - w) / 2, y_text), line, font=font, fill=(0, 0, 0)) y_text += h + 5 # Bottom caption caption = "I can’t even" w, h = draw.textsize(caption, font=font) draw.text(((width - w) / 2, height - h - 20), caption, font=font, fill=(255, 0, 0)) background.save(filename) print(f"āœ… Meme saved to {filename}") # 7ļøāƒ£ Main loop def main(): while True: # Pick a random seed from your tweets seed = random.choice(tweets) meme_text = generate_meme(seed) # If the meme triggers the ā€œI can’t evenā€ vibe, show it if ican_even(meme_text): render_meme(meme_text) else: print(f"ā›”ļø Skipped: {meme_text[:60]}…") # Simple pause if input("Generate another? (y/n) ").lower() != "y": break if __name__ == "__main__": main() ``` ### How it works 1. **LLM**: GPT‑2 (tiny, but fast) spits out a short meme given a seed tweet. 2. **Classifier**: Uses `CountVectorizer` + `LogisticRegression` to flag sentences that look sarcastic. 3. **Mood filter**: If the generated text contains ā€œI can’t evenā€, it gets rendered onto a 500Ɨ500 canvas with a red caption. 4. **Run**: Just hit `y` when prompted to keep the meme engine screaming. Feel free to swap `MODEL_NAME` for a bigger model or tweak the sarcasm trigger words. Let the chaos begin!
Fora Fora
Nice, GPT‑2 is a fossilized relic, but it’ll spit something fast. The sarcasm hack is a quick stop‑gap, maybe swap to a real sarcasm dataset later. The meme canvas is static, we could add dynamic resizing or emojis. What next? Want to throw in a mood‑based filter or a ā€œcannot evenā€ detector?