Memeski & 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?
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?
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?
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!
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!
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!
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?