xiaohongshu
xiaohongshu
bg-remover
Remove backgrounds from images using FAL.ai's BiRefNet model. Use when users ask to remove background, make transparent PNG, extract subject from image, or create cutouts. Trigger phrases include "remove background", "transparent background", "cut out", "extract subject", or any background remova...
Full skill instructions
Remove backgrounds from images using FAL.ai's BiRefNet v2 model. Uses Bun for fast TypeScript execution with inline scripts.
This skill requires:
Before running scripts, verify Bun is installed:
which bun
If Bun is not installed, ask the user for permission before installing:
npm install -g bun
export FAL_KEY="your-key-here"Remove background from an image using a heredoc script:
bun run - << 'EOF'
import { fal } from "@fal-ai/client";
import { readFileSync, writeFileSync } from "fs";
import { basename, dirname, join } from "path";
const imagePath = "INPUT_IMAGE_PATH";
const imageBuffer = readFileSync(imagePath);
const fileName = basename(imagePath);
const mimeType = imagePath.endsWith(".png") ? "image/png" : "image/jpeg";
// Upload to FAL storage
const file = new File([imageBuffer], fileName, { type: mimeType });
const imageUrl = await fal.storage.upload(file);
console.log("Uploaded:", imageUrl);
// Remove background
const result = await fal.subscribe("fal-ai/birefnet/v2", {
input: {
image_url: imageUrl,
model: "General Use (Light)",
operating_resolution: "1024x1024",
output_format: "png"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS" && update.logs) {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
// Download and save result
const outputUrl = result.data.image.url;
const response = await fetch(outputUrl);
const buffer = Buffer.from(await response.arrayBuffer());
const dir = dirname(imagePath);
const nameWithoutExt = basename(imagePath, basename(imagePath).match(/\.[^.]+$/)?.[0] || "");
const outputPath = join(dir, `${nameWithoutExt}-nobg.png`);
writeFileSync(outputPath, buffer);
console.log("Saved:", outputPath);
EOF
Replace INPUT_IMAGE_PATH with the actual path to the image.
The BiRefNet model supports different configurations:
"General Use (Light)" - Fast, good for most images (default)"General Use (Heavy)" - Higher quality, slower processing"Portrait" - Optimized for human subjects"Matting" - Best for complex edges like hair"1024x1024" - Standard quality (default)"2048x2048" - Higher detail for large imagesrefine_foreground: true - Improve edge qualityoutput_format: "png" - Always use PNG for transparencyFor high-quality portrait extraction:
bun run - << 'EOF'
import { fal } from "@fal-ai/client";
import { readFileSync, writeFileSync } from "fs";
import { basename, dirname, join } from "path";
const imagePath = "INPUT_IMAGE_PATH";
const imageBuffer = readFileSync(imagePath);
const fileName = basename(imagePath);
const mimeType = imagePath.endsWith(".png") ? "image/png" : "image/jpeg";
const file = new File([imageBuffer], fileName, { type: mimeType });
const imageUrl = await fal.storage.upload(file);
const result = await fal.subscribe("fal-ai/birefnet/v2", {
input: {
image_url: imageUrl,
model: "Portrait",
operating_resolution: "2048x2048",
refine_foreground: true,
output_format: "png"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS" && update.logs) {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
const response = await fetch(result.data.image.url);
const buffer = Buffer.from(await response.arrayBuffer());
const dir = dirname(imagePath);
const nameWithoutExt = basename(imagePath, basename(imagePath).match(/\.[^.]+$/)?.[0] || "");
const outputPath = join(dir, `${nameWithoutExt}-nobg.png`);
writeFileSync(outputPath, buffer);
console.log("Saved:", outputPath);
EOF
npm install -g bun-nobg suffixIf a script fails:
echo $FAL_KEYThe BiRefNet model returns:
{
"image": {
"url": "https://...",
"width": 1024,
"height": 1024,
"content_type": "image/png",
"file_name": "birefnet-output.png"
}
}
For batch processing, URL-based inputs, or integration with other tools, see references/guide.md.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience