The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
AI Influencer: Gender is Male, Female or Other
Adarsh35b961eb98c8
diff --git a/scripts/gen-influencer-options.py b/scripts/gen-influencer-options.pyindex 42adff91..9c52ff3f 100644--- a/scripts/gen-influencer-options.py+++ b/scripts/gen-influencer-options.py@@ -7,7 +7,9 @@ Outputs (data only; the rules and the prompt compiler are src/lib/influencer.ts)INFLUENCER_CATEGORIES — the 19 categories in Higgsfield's order: id, label, kind (media / text / color),max picks, and every option with its id, label, the tiers it shows in(visibleIn), its swatch (color categories) and its slot (Features).- CREATURE_TYPES — the 6 creature types with their species ids and labels.+ Gender is Fuobe's own: Male, Female, Other (GENDER_OPTIONS below).+ RETIRED_OPTIONS — option ids Fuobe no longer shows, and the option a saved pick of one becomes.+ CREATURE_TYPES — the 6 creature types with their species ids and labels.CREATURE_CATEGORIES — the categories a creature type shows.DISPLAY_ORDER_FIRST — the categories the builder lists first.SHUFFLE_RESEARCH — Shuffle's weights and the picks a reference photo keeps.@@ -22,12 +24,18 @@ import refrom pathlib import PathROOT = Path(__file__).resolve().parent.parent-RESEARCH = json.loads((ROOT / "docs/research/higgsfield-delta-4.json").read_text())["aiInfluencerBuilder"]+RESEARCH = json.loads((ROOT / "docs/research/higgsfield-delta-4.json").read_text(encoding="utf-8"))["aiInfluencerBuilder"]OUT = ROOT / "src/lib/catalog/influencer-options.generated.ts"# Species ids are snake_case; these read better with their proper capitals.SPECIES_LABELS = {"maine_coon": "Maine Coon", "british_shorthair": "British Shorthair"}+# Gender: Fuobe shows Male, Female and Other, in that order, in every human tier (the research lists five).+HUMAN_TIERS = ["normal", "freak", "total"]+GENDER_OPTIONS = [{"id": i, "label": l, "visibleIn": HUMAN_TIERS} for i, l in (("male", "Male"), ("female", "Female"), ("other", "Other"))]+# Option ids Fuobe no longer shows, and the option a saved pick or link that carries one becomes.+RETIRED_OPTIONS = {"gender": {"trans_man": "male", "trans_woman": "female", "non_binary": "other"}}+def ts(v):return json.dumps(v, ensure_ascii=False, indent=2)@@ -49,6 +57,12 @@ for c in RESEARCH["categories"]:if "slot" in o:opt["slot"] = o["slot"]options.append(opt)+ if c["id"] == "gender":+ shown = {o["id"] for o in GENDER_OPTIONS}+ lost = [o["id"] for o in options if o["id"] not in shown and o["id"] not in RETIRED_OPTIONS["gender"]]+ if lost:+ raise SystemExit(f"gender options with no new option: {lost}")+ options = [dict(o) for o in GENDER_OPTIONS]categories.append({"id": c["id"], "label": c["label"], "kind": c["kind"], "max": c["max"], "options": options})tier_labels = {o["id"]: o["label"] for o in next(c for c in RESEARCH["categories"] if c["id"] == "tier")["options"]}@@ -69,6 +83,8 @@ shuffle_out = {"keepsWithReference": shuffle["keepsWithReference"],"weights": {"gender": weights(shuffle["gender"]), "aesthetic": weights(shuffle["aesthetic"]), "hair": weights(shuffle["hair"])},}+if any(g not in {o["id"] for o in GENDER_OPTIONS} for g in shuffle_out["weights"]["gender"]):+ raise SystemExit(f"gender weights name an option Fuobe does not show: {shuffle_out['weights']['gender']}")conflicts = [re.sub(r"\s*\(.*\)\s*$", "", r).strip() for r in RESEARCH["rules"] if "cannot be combined" in r]heavy = next(m for m in conflicts if m.startswith("Heavy"))@@ -84,7 +100,7 @@ if errors:OUT.write_text("// GENERATED by scripts/gen-influencer-options.py from docs/research/higgsfield-delta-4.json (aiInfluencerBuilder) — do not edit.\n"- "// Higgsfield's AI Influencer builder: its option ids, labels, tiers, swatches and Shuffle weights.\n\n"+ "// Higgsfield's AI Influencer builder: its option ids, labels, tiers, swatches and Shuffle weights (Gender is Fuobe's own: Male, Female, Other).\n\n""/** Human tiers: Average (normal), Bold (freak), Extreme (total). */\n""export type HumanTier = \"normal\" | \"freak\" | \"total\";\n"f"export type CreatureType = {' | '.join(json.dumps(c['id']) for c in creatures)};\n"@@ -103,7 +119,11 @@ OUT.write_text("/** Shuffle (function `ae` in the bundle): weighted picks (the rest of each category is uniform) and what a reference photo keeps. */\n"f"export const SHUFFLE_RESEARCH = {ts(shuffle_out)} as const;\n\n""/** Higgsfield's conflict messages, word for word. */\n"- f"export const CONFLICT_MESSAGES = {ts({'heavyTall': heavy, 'buildLegs': legs})} as const;\n"+ f"export const CONFLICT_MESSAGES = {ts({'heavyTall': heavy, 'buildLegs': legs})} as const;\n\n"+ "/** Option ids Fuobe no longer shows, per category: the option a saved pick or link that carries one becomes. */\n"+ f"export const RETIRED_OPTIONS: Record<string, Record<string, string>> = {ts(RETIRED_OPTIONS)};\n",+ encoding="utf-8",+ newline="\n",)n = sum(len(c["options"]) for c in categories)print(f"wrote {OUT.relative_to(ROOT)}: {len(categories)} categories, {n} options, {len(creatures)} creature types")diff --git a/src/lib/catalog/influencer-options.generated.ts b/src/lib/catalog/influencer-options.generated.tsindex 24f5c817..0131972c 100644--- a/src/lib/catalog/influencer-options.generated.ts+++ b/src/lib/catalog/influencer-options.generated.ts@@ -1,5 +1,5 @@// GENERATED by scripts/gen-influencer-options.py from docs/research/higgsfield-delta-4.json (aiInfluencerBuilder) — do not edit.-// Higgsfield's AI Influencer builder: its option ids, labels, tiers, swatches and Shuffle weights.+// Higgsfield's AI Influencer builder: its option ids, labels, tiers, swatches and Shuffle weights (Gender is Fuobe's own: Male, Female, Other)./** Human tiers: Average (normal), Bold (freak), Extreme (total). */export type HumanTier = "normal" | "freak" | "total";@@ -83,15 +83,6 @@ export const INFLUENCER_CATEGORIES: InfluencerCategory[] = ["kind": "media","max": 1,"options": [- {- "id": "female",- "label": "Female",- "visibleIn": [- "normal",- "freak",- "total"- ]- },{"id": "male","label": "Male",@@ -102,17 +93,8 @@ export const INFLUENCER_CATEGORIES: InfluencerCategory[] = []},{- "id": "trans_man",- "label": "Trans man",- "visibleIn": [- "normal",- "freak",- "total"- ]- },- {- "id": "trans_woman",- "label": "Trans woman",+ "id": "female",+ "label": "Female","visibleIn": ["normal","freak",@@ -120,8 +102,8 @@ export const INFLUENCER_CATEGORIES: InfluencerCategory[] = []},{- "id": "non_binary",- "label": "Non-binary",+ "id": "other",+ "label": "Other","visibleIn": ["normal","freak",@@ -2007,3 +1989,12 @@ export const CONFLICT_MESSAGES = {"heavyTall": "Heavy build cannot be combined with Tall or Very tall.","buildLegs": "This build cannot be combined with Short legs or Long limbs in this mode."} as const;++/** Option ids Fuobe no longer shows, per category: the option a saved pick or link that carries one becomes. */+export const RETIRED_OPTIONS: Record<string, Record<string, string>> = {+ "gender": {+ "trans_man": "male",+ "trans_woman": "female",+ "non_binary": "other"+ }+};diff --git a/src/lib/influencer.ts b/src/lib/influencer.tsindex b51f6fed..41a8b182 100644--- a/src/lib/influencer.ts+++ b/src/lib/influencer.ts@@ -12,6 +12,7 @@ import {CREATURE_TYPES,DISPLAY_ORDER_FIRST,INFLUENCER_CATEGORIES,+ RETIRED_OPTIONS,SHUFFLE_RESEARCH,type CreatureType,type HumanTier,@@ -23,7 +24,7 @@ import type { PlanCaps } from "@/lib/catalog/packs";import { CAST_LOOK } from "@/lib/catalog/soul-cards";import type { ChainSlot, Engine, GenerationRequest } from "@/lib/catalog/types";-export { CONFLICT_MESSAGES, CREATURE_TYPES, INFLUENCER_CATEGORIES };+export { CONFLICT_MESSAGES, CREATURE_TYPES, INFLUENCER_CATEGORIES, RETIRED_OPTIONS };export type { CreatureType, HumanTier, InfluencerCategory, InfluencerOption, InfluencerTier };export const HUMAN_TIERS: { id: HumanTier; label: string; hint: string }[] = [@@ -267,7 +268,7 @@ const one = (id: string | undefined): string[] => (id ? [id] : []);* Curvy, never Ultra Muscular in Average, never Heavy with Tall heights or a Tiny waist, never Centaur with* an Egg body or Ultra Muscular with a Long neck (nor any pick that would conflict). Those pairs hold whichever* side is kept: with a locked Heavy, Shuffle picks no tall height and no Tiny waist. Facial hair is Clean- * unless the gender is male or trans man. How many multi-pick options it adds is Fuobe's choice (up to 1+ * unless the gender is male. How many multi-pick options it adds is Fuobe's choice (up to 1* proportion, 1–2 features, up to 1 distinctive feature, 1 accessory).*/export function shuffleInfluencer(state: InfluencerState, rand: () => number, opts: ShuffleOptions = {}): InfluencerState {@@ -299,7 +300,7 @@ export function shuffleInfluencer(state: InfluencerState, rand: () => number, opbreak;case "facial_hair": {const g = picks.gender?.[0];- pick = g === "male" || g === "trans_man" ? one(uniform(ids, rand)) : ids.includes("fh_none") ? ["fh_none"] : [];+ pick = g === "male" ? one(uniform(ids, rand)) : ids.includes("fh_none") ? ["fh_none"] : [];break;}case "proportions":@@ -330,9 +331,7 @@ export const PHRASES: Record<string, string> = {// gender (people; creatures read CREATURE_GENDER)female: "woman",male: "man",- trans_man: "trans man",- trans_woman: "trans woman",- non_binary: "non-binary person",+ other: "androgynous person",// ethnicityafrican: "African",east_asian: "East Asian",@@ -518,7 +517,7 @@ export const PHRASES: Record<string, string> = {acc_bag: "a bag",};-const CREATURE_GENDER: Record<string, string> = { female: "female", male: "male", trans_man: "trans-masculine", trans_woman: "trans-feminine", non_binary: "non-binary" };+const CREATURE_GENDER: Record<string, string> = { female: "female", male: "male", other: "androgynous" };const CREATURE_NOUN: Record<CreatureType, string> = { insects: "insect", frogs: "frog", cats: "cat", dogs: "dog", capybaras: "capybara", birds: "bird" };const CREATURE_COAT: Record<CreatureType, string> = { insects: "body", frogs: "skin", cats: "fur", dogs: "fur", capybaras: "fur", birds: "feathers" };@@ -650,9 +649,9 @@ export function describeInfluencer(state: InfluencerState): string {].filter((x): x is string => !!x);const accessories = state.picks.accessory ?? [];const parts = [subject(state), ...body];- // "Clean" is what Shuffle gives everyone but men and trans men: said only where it means something.+ // "Clean" is what Shuffle gives everyone but men: said only where it means something.const g = pick1(state, "gender");- if (pick1(state, "facial_hair") === "fh_none" && (g === "male" || g === "trans_man" || !g)) parts.push("clean-shaven");+ if (pick1(state, "facial_hair") === "fh_none" && (g === "male" || !g)) parts.push("clean-shaven");if (withs.length) parts.push(`with ${list(withs)}`);const outfit = phrases(state, "aesthetic")[0];if (outfit) parts.push(`wearing ${outfit}`);@@ -770,8 +769,9 @@ export function influencerName(state: InfluencerState): string {const HEX = /^#[0-9a-f]{6}$/i;/**- * A state from the browser made safe: unknown categories and options, options the tier doesn't show and- * picks over a category's limit are dropped (Features: one per slot). A conflict is reported, not fixed.+ * A state from the browser made safe: a retired option id becomes its new option (an old Trans man pick is+ * Male, Trans woman is Female, Non-binary is Other); unknown categories and options, options the tier doesn't+ * show and picks over a category's limit are dropped (Features: one per slot). A conflict is reported, not fixed.*/export function cleanState(raw: unknown): { state: InfluencerState; problem: string | null } {const r = (raw && typeof raw === "object" ? raw : {}) as Record<string, unknown>;@@ -779,7 +779,8 @@ export function cleanState(raw: unknown): { state: InfluencerState; problem: strconst picks: Record<string, string[]> = {};const rawPicks = (r.picks && typeof r.picks === "object" ? r.picks : {}) as Record<string, unknown>;for (const c of categoriesFor(tier)) {- const ids = Array.isArray(rawPicks[c.id]) ? (rawPicks[c.id] as unknown[]).filter((x): x is string => typeof x === "string") : [];+ const retired = RETIRED_OPTIONS[c.id] ?? {};+ const ids = Array.isArray(rawPicks[c.id]) ? (rawPicks[c.id] as unknown[]).filter((x): x is string => typeof x === "string").map((id) => (Object.hasOwn(retired, id) ? retired[id] : id)) : [];let next: string[] = [];for (const id of ids) if (c.options.some((o) => o.id === id) && !next.includes(id)) next = picked(c, next, id).next;if (next.length) picks[c.id] = next;diff --git a/tests/influencer.test.ts b/tests/influencer.test.tsindex b8dfc6de..120997bc 100644--- a/tests/influencer.test.ts+++ b/tests/influencer.test.ts@@ -28,6 +28,7 @@ import {planInfluencer,RAIL_ORDER,resetPicks,+ RETIRED_OPTIONS,seededRandom,setTier,shuffleInfluencer,@@ -57,7 +58,8 @@ describe("option data (generated from the research JSON)", () => {it("has the 19 categories, every option with its id, label, swatch and slot, and the 6 creature types", () => {expect(INFLUENCER_CATEGORIES).toHaveLength(19);expect(INFLUENCER_CATEGORIES.map((c) => [c.id, c.label, c.max])).toEqual(research.categories.map((c) => [c.id, c.label, c.max]));- for (const c of research.categories) {+ // Gender is Fuobe's own (Male, Female, Other: see "gender" below); the rest is the research's.+ for (const c of research.categories.filter((x) => x.id !== "gender")) {const ours = INFLUENCER_CATEGORIES.find((x) => x.id === c.id)!;expect(ours.options.map((o) => [o.id, o.label, o.swatch, o.slot])).toEqual(c.options.map((o) => [o.id, o.label, o.swatch?.toLowerCase(), o.slot]));}@@ -109,6 +111,44 @@ describe("what each tier shows", () => {});});+describe("gender", () => {+ it("is exactly Male, Female and Other, in that order, in every human tier", () => {+ for (const t of HUMAN) {+ const gender = categoriesFor(t).find((c) => c.id === "gender")!;+ expect(gender.options.filter((o) => optionVisible(o, t, "gender")).map((o) => [o.id, o.label])).toEqual([+ ["male", "Male"],+ ["female", "Female"],+ ["other", "Other"],+ ]);+ }+ expect(INFLUENCER_CATEGORIES.find((c) => c.id === "gender")!.options.map((o) => o.id)).toEqual(["male", "female", "other"]);+ });++ it("words each option in the prompt", () => {+ expect(describeInfluencer(S("normal", { gender: ["male"] }))).toBe("A man.");+ expect(describeInfluencer(S("normal", { gender: ["female"] }))).toBe("A woman.");+ expect(describeInfluencer(S("normal", { gender: ["other"] }))).toBe("An androgynous person.");+ expect(describeInfluencer(S("normal", { gender: ["other"], age: ["senior"] }))).toContain("androgynous person");+ expect(describeInfluencer(S("cats", { gender: ["other"] }))).toBe("An androgynous anthropomorphic cat.");+ for (const id of ["male", "female", "other"]) expect(compileSheetPrompt({ state: S("freak", { gender: [id] }), direction: "" })).toContain(PHRASES[id]);+ });++ it("turns old Trans man, Trans woman and Non-binary picks into Male, Female and Other", () => {+ expect(RETIRED_OPTIONS.gender).toEqual({ trans_man: "male", trans_woman: "female", non_binary: "other" });+ for (const [old, now] of [["trans_man", "male"], ["trans_woman", "female"], ["non_binary", "other"]]) {+ for (const tier of HUMAN) expect(cleanState({ tier, picks: { gender: [old] } }).state.picks).toEqual({ gender: [now] });+ expect(cleanState({ tier: "cats", picks: { gender: [old] } }).state.picks).toEqual({ gender: [now] });+ }+ expect(cleanState({ tier: "normal", picks: { gender: ["trans_man", "male"] } }).state.picks).toEqual({ gender: ["male"] });+ expect(cleanState({ tier: "normal", picks: { gender: ["toString"] } }).state.picks).toEqual({});+ });++ it("Shuffle picks only shown options", () => {+ const shown = new Set(["male", "female", "other"]);+ for (let i = 1; i <= 200; i++) expect(shown.has(shuffleInfluencer(S("normal"), seededRandom(i)).picks.gender[0])).toBe(true);+ });+});+describe("pick rules", () => {it("one-pick categories replace the pick, and a second click unpicks", () => {let s = pickAll(INFLUENCER_START, ["gender", "male"], ["gender", "female"]);@@ -301,25 +341,25 @@ describe("Shuffle", () => {for (const s of check(lock("normal", { body_type: ["body_heavy"], proportions: ["pr_waist"] }))) expect(tall).not.toContain(s.picks.height?.[0]);});- it("gives facial hair only to men and trans men", () => {+ it("gives facial hair only to men", () => {for (const s of runs(S("total"), 600)) {const g = s.picks.gender[0];- if (g !== "male" && g !== "trans_man") expect(s.picks.facial_hair).toEqual(["fh_none"]);+ if (g !== "male") expect(s.picks.facial_hair).toEqual(["fh_none"]);}expect(new Set(runs(S("total"), 600).filter((s) => s.picks.gender[0] === "male").map((s) => s.picks.facial_hair[0])).size).toBeGreaterThan(4);});it("keeps locked picks, and what a photo decides", () => {- const locked = toggleLock(S("freak", { gender: ["non_binary"], hair: ["hs_wings"] }), "hair");+ const locked = toggleLock(S("freak", { gender: ["other"], hair: ["hs_wings"] }), "hair");for (const s of runs(locked, 50)) expect(s.picks.hair).toEqual(["hs_wings"]);- const fixed = S("normal", { gender: ["trans_woman"], ethnicity_origin_base: ["indian"], skin_tone: ["st_tan"], age: ["senior"], eye_color: ["eye_green"] });+ const fixed = S("normal", { gender: ["other"], ethnicity_origin_base: ["indian"], skin_tone: ["st_tan"], age: ["senior"], eye_color: ["eye_green"] });for (const s of runs(fixed, 50, { reference: true })) expect(s.picks).toMatchObject(fixed.picks);// Bold keeps gender, ethnicity and age; skin and eyes shuffle.const bold = runs({ ...fixed, tier: "freak" }, 50, { reference: true });- for (const s of bold) expect(s.picks).toMatchObject({ gender: ["trans_woman"], ethnicity_origin_base: ["indian"], age: ["senior"] });+ for (const s of bold) expect(s.picks).toMatchObject({ gender: ["other"], ethnicity_origin_base: ["indian"], age: ["senior"] });expect(bold.some((s) => s.picks.skin_tone[0] !== "st_tan")).toBe(true);// Without a photo nothing is kept.- expect(runs(fixed, 50).some((s) => s.picks.gender[0] !== "trans_woman")).toBe(true);+ expect(runs(fixed, 50).some((s) => s.picks.gender[0] !== "other")).toBe(true);});it("leaves the type, species and body colour alone", () => {