惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
V
Visual Studio Blog
有赞技术团队
有赞技术团队
U
Unit 42
D
Docker
小众软件
小众软件
F
Full Disclosure
I
Intezer
Scott Helme
Scott Helme
P
Privacy International News Feed
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
B
Blog
Martin Fowler
Martin Fowler
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
S
Security Affairs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
月光博客
月光博客
C
Cisco Blogs
云风的 BLOG
云风的 BLOG
Schneier on Security
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Threat Research - Cisco Blogs
量子位
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Heimdal Security Blog
N
Netflix TechBlog - Medium
H
Hacker News: Front Page
P
Proofpoint News Feed
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
S
Schneier on Security

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
SDXL Turbo for Pinterest at Scale: How I Cut NSFW False-Positives by 73% and Dodged Style-Copyright Strikes (Python + diffusers)
スシロー · 2026-06-01 · via DEV Community

⚠️ この記事はアフィリエイト広告(プロモーション)を含みます。リンク先で発生した収益の一部が運営者に支払われますが、読者の購入価格には一切影響ありません。

By the end of this article you'll have two runnable Python scripts: a CLIP-based pre-filter that re-checks SDXL Turbo output before it ever hits Pinterest, and a prompt sanitizer that strips artist names + trademarked characters so you don't eat a DMCA. I ran this pipeline for 41 days, generated 6,180 images, and went from a 9.7% Pinterest rejection rate down to 2.6%. Here's exactly what broke and what fixed it.

Why SDXL Turbo (1-step, ~0.3s on a 4090) beats SD 1.5 for Pinterest volume

First, the conclusion: if you're mass-producing pins, SDXL Turbo's single-step guidance_scale=0.0 generation is the only thing that makes the unit economics work. On my RTX 4090 I clock 0.31s per 512x512 image with Turbo vs 4.8s for a 30-step SDXL base run. That's 15x. Over 6,180 images that's the difference between 32 minutes and 8.2 hours of GPU time.

But Turbo has a nasty side effect nobody warns you about: because it's distilled and runs at low resolution by default, its built-in StableDiffusionXLPipeline safety checker (when enabled) throws far more false positives on perfectly benign images — beaches, lingerie-free fashion flatlays, even close-up food. In my first 600-image batch, 58 images came back as black squares from the NSFW checker. 51 of them were photos of latte art and knitted sweaters.

So I ripped out the default checker and built my own two-stage gate.

Stage 1: Replacing the diffusers safety_checker with a tunable CLIP gate in Python

The default safety_checker in diffusers is a binary black box — you get a black image and zero signal about why. For a production loop you need a confidence score so you can set your own threshold. I use OpenCLIP's ViT-B-32 to score each output against a small set of NSFW concept prompts, then compare to a safe-concept baseline.

This code actually runs (tested on diffusers==0.27.2, open_clip_torch==2.24.0):

import torch
import open_clip
from PIL import Image
from diffusers import AutoPipelineForText2Image

device = "cuda" if torch.cuda.is_available() else "cpu"

# Turbo: disable the built-in checker, we replace it
pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16,
    variant="fp16",
    safety_checker=None,
).to(device)

clip_model, _, preprocess = open_clip.create_model_and_transforms(
    "ViT-B-32", pretrained="laion2b_s34b_b79k"
)
clip_model = clip_model.to(device).eval()
tokenizer = open_clip.get_tokenizer("ViT-B-32")

# Concept anchors. Tune these to YOUR niche.
NSFW = ["explicit nudity", "sexual content", "graphic violence", "gore"]
SAFE = ["a clean product photo", "a wholesome lifestyle image",
        "food photography", "home decor"]

with torch.no_grad():
    text = tokenizer(NSFW + SAFE).to(device)
    text_feat = clip_model.encode_text(text)
    text_feat /= text_feat.norm(dim=-1, keepdim=True)

def nsfw_score(img: Image.Image) -> float:
    x = preprocess(img).unsqueeze(0).to(device)
    with torch.no_grad():
        f = clip_model.encode_image(x)
        f /= f.norm(dim=-1, keepdim=True)
        sims = (100.0 * f @ text_feat.T).softmax(dim=-1)[0]
    # sum of probability mass on the NSFW anchors
    return sims[: len(NSFW)].sum().item()

def generate(prompt: str, threshold: float = 0.35):
    img = pipe(prompt=prompt, num_inference_steps=1,
               guidance_scale=0.0, height=512, width=512).images[0]
    score = nsfw_score(img)
    return (img, score, score < threshold)

img, score, ok = generate("a cozy minimalist coffee corner, soft morning light")
print(f"nsfw_score={score:.3f} pass={ok}")

The key knob is threshold. The diffusers default behaves like a hard 0.5 you can't see. I A/B tested thresholds on a hand-labeled set of 300 images (I labeled them myself over two coffees):

  • threshold=0.50 → 3 real NSFW slipped through, 41 false positives
  • threshold=0.35 → 0 slipped through, 11 false positives
  • threshold=0.20 → 0 slipped through, but 38 safe images wrongly killed

0.35 was the sweet spot for a fashion+home-decor account. That single change dropped my false-positive count by 73% (41 → 11) versus the built-in checker on the same set. Your anchors matter more than the threshold — when I added "food photography" to SAFE, the latte-art massacre stopped instantly because latte foam stopped getting pulled toward the "nudity" anchor in CLIP space.

Stage 2: The copyright trap — Pinterest killed 22 pins before I sanitized prompts

Here's the failure that actually cost me. Week two, I leaned into "trending aesthetic" prompts and casually wrote things like "in the style of Greg Rutkowski" and "Studio Ghibli inspired forest". Pinterest didn't ban my account, but 22 pins got silently suppressed (zero impressions after 72h, while sibling pins from the same batch hit 300+). When I removed the named-style pins and reposted neutral-prompt versions, impressions came back.

Two separate risks are hiding here:

  1. Living-artist style mimicry"Greg Rutkowski", "Loish", etc. Legally murky and reputationally radioactive.
  2. Trademarked characters/brands"Pikachu", "Hello Kitty", "Mickey". This is straight-up infringement and the fast lane to a takedown.

So I built a sanitizer that runs before generation. It uses a denylist plus a fuzzy match (because "ghibli", "ghiblistyle", and "gibli" all show up in scraped trend prompts):

import re
from difflib import SequenceMatcher

# Maintain these in a JSON you can update without redeploying.
DENY_ARTISTS = {"greg rutkowski", "loish", "artgerm", "makoto shinkai"}
DENY_BRANDS = {"pikachu", "pokemon", "hello kitty", "sanrio",
               "mickey mouse", "disney", "ghibli", "totoro", "mario"}

# Safe replacements that keep the AESTHETIC without the IP
STYLE_SUBS = {
    "ghibli": "soft hand-painted anime landscape, lush nature",
    "greg rutkowski": "dramatic cinematic fantasy lighting, painterly",
    "makoto shinkai": "vivid skies, high-contrast atmospheric anime scenery",
}

def _fuzzy_hit(token: str, bank: set, ratio: float = 0.86) -> str | None:
    token = token.lower()
    if token in bank:
        return token
    for term in bank:
        if SequenceMatcher(None, token, term).ratio() >= ratio:
            return term
    return None

def sanitize_prompt(prompt: str) -> tuple[str, list[str]]:
    flagged = []
    out = prompt
    low = prompt.lower()
    # multi-word terms first
    for term in sorted(DENY_ARTISTS | DENY_BRANDS, key=len, reverse=True):
        if term in low:
            flagged.append(term)
            repl = STYLE_SUBS.get(term, "")
            out = re.sub(re.escape(term), repl, out, flags=re.IGNORECASE)
    # token-level fuzzy pass for typo-evasions
    for tok in re.findall(r"[a-zA-Z]+", prompt):
        hit = _fuzzy_hit(tok, DENY_ARTISTS | DENY_BRANDS)
        if hit and hit not in flagged:
            flagged.append(hit)
            out = re.sub(re.escape(tok),
                         STYLE_SUBS.get(hit, ""), out, flags=re.IGNORECASE)
    out = re.sub(r"\s{2,}", " ", out).strip(" ,")
    return out, flagged

clean, flags = sanitize_prompt(
    "a forest spirit in the style of Ghibli, with Pikachu, cinematic")
print(clean)   # -> a forest spirit ... soft hand-painted anime landscape ... cinematic
print(flags)   # -> ['ghibli', 'pikachu']

The non-obvious win is STYLE_SUBS: instead of just deleting "ghibli" and getting a flat, dead image, I swap in a description of the aesthetic qualities ("soft hand-painted anime landscape, lush nature"). Output quality barely drops — in a blind comparison of 50 pairs, I preferred the deletion version 8 times and the substitution version 39 times (3 ties). The substitution images also performed within ~6% of the named-artist originals on save rate, which tells me the style, not the name, is what readers actually respond to.

Wiring it into a GitHub Actions nightly batch (and the 2 things that broke)

I run the whole loop as a self-hosted GitHub Actions runner on my home PC at 7am. Two real gotchas that ate an evening each:

  1. open_clip re-downloads the 350MB checkpoint on every cold runner. Cache it. Add ~/.cache/huggingface and ~/.cache/clip to actions/cache keyed on a hash of your requirements. This cut my job startup from 4m10s to 38s.
  2. fp16 + batch>4 OOMs at 24GB when CLIP and SDXL Turbo both sit on the GPU. I move the CLIP scorer to CPU for batches over 8 — it adds ~90ms/image but never crashes. For a nightly job, reliability > 90ms.

The orchestration glue is trivial once the two stages above exist:

import json, pathlib

def run_batch(prompts, out_dir="pins", threshold=0.35):
    pathlib.Path(out_dir).mkdir(exist_ok=True)
    kept, killed = 0, 0
    for i, raw in enumerate(prompts):
        clean, flags = sanitize_prompt(raw)
        img, score, ok = generate(clean, threshold=threshold)
        if not ok:
            killed += 1
            continue
        img.save(f"{out_dir}/pin_{i:04d}.png")
        kept += 1
        with open(f"{out_dir}/pin_{i:04d}.json", "w") as f:
            json.dump({"prompt": clean, "nsfw": round(score, 3),
                       "ip_flags": flags}, f)
    print(f"kept={kept} killed={killed} kill_rate={killed/len(prompts):.1%}")

run_batch(["a cozy reading nook, autumn palette, warm lamp glow",
           "minimal scandinavian kitchen, matte ceramics, morning light"])

Logging nsfw score and ip_flags per image is what made this debuggable. After 41 days I had a CSV I could actually query: it told me that 71% of my false positives came from just three prompt templates (all involving "beach" or "spa"), so I added "swimwear, modest, family-friendly" to those templates' negative-adjacent SAFE anchors and the problem evaporated.

What I'd tell my 41-days-ago self

Three concrete takeaways with numbers attached:

  • Don't trust the black-box checker. Swapping it for a tunable CLIP gate at threshold=0.35 cut false positives 73% and gave me per-image scores I could log and tune.
  • Sanitize prompts before generation, and substitute the aesthetic instead of deleting the name — 39/50 blind preference, ~6% save-rate gap vs the infringing originals, and zero suppressed pins in the final 19 days.
  • Cache your model downloads in CI. 4m10s → 38s startup is free money when you're running nightly.

The whole pipeline is ~180 lines of Python and runs unattended. The hard part was never the GPU — it was building the two cheap gates that keep a volume account alive long enough to compound.