Fix video background removal to use only allowed RGBA values

- Remove Transparent option [0,0,0,0] which is not allowed by API
- Update background color options to show RGBA values in dropdown names
- Change default background color from Transparent to White
- Update fallback RGBA value to White [255,255,255,0]
This commit is contained in:
Sirshendu Ganguly
2025-10-24 10:40:14 -04:00
parent f292b8ce12
commit e22bbc050c
2 changed files with 13 additions and 14 deletions
+12 -13
View File
@@ -8,17 +8,16 @@ class videoBgRemoval:
}
BACKGROUND_COLORS = {
"Transparent": [0, 0, 0, 0],
"Black": [0, 0, 0, 1],
"White": [255, 255, 255, 0],
"Gray": [128, 128, 128, 0],
"Red": [255, 0, 0, 0],
"Green": [0, 255, 0, 0],
"Blue": [0, 0, 255, 0],
"Yellow": [255, 255, 0, 0],
"Cyan": [0, 255, 255, 0],
"Magenta": [255, 0, 255, 0],
"Orange": [255, 165, 0, 0],
"Black [0, 0, 0, 1]": [0, 0, 0, 1],
"White [255, 255, 255, 0]": [255, 255, 255, 0],
"Gray [128, 128, 128, 0]": [128, 128, 128, 0],
"Red [255, 0, 0, 0]": [255, 0, 0, 0],
"Green [0, 255, 0, 0]": [0, 255, 0, 0],
"Blue [0, 0, 255, 0]": [0, 0, 255, 0],
"Yellow [255, 255, 0, 0]": [255, 255, 0, 0],
"Cyan [0, 255, 255, 0]": [0, 255, 255, 0],
"Magenta [255, 0, 255, 0]": [255, 0, 255, 0],
"Orange [255, 165, 0, 0]": [255, 165, 0, 0],
}
@@ -36,7 +35,7 @@ class videoBgRemoval:
},
"optional": {
"Background Color": (list(cls.BACKGROUND_COLORS.keys()), {
"default": "Transparent",
"default": "White",
"tooltip": "Background color preset to use. Hex values are not supported.",
}),
"Output Format": (["mp4", "webm", "mov"], {
@@ -66,7 +65,7 @@ class videoBgRemoval:
modelAIR = self.RUNWARE_VRMBG_MODELS.get(modelName, "bria:51@1")
# Get background color RGBA
rgba_color = self.BACKGROUND_COLORS.get(backgroundColor, [0, 0, 0, 0])
rgba_color = self.BACKGROUND_COLORS.get(backgroundColor, [255, 255, 255, 0])
# Build the API request
genConfig = [