| 5 | const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "bmp", "tiff", "tif", "tga", "webp"] |
| 6 | |
| 7 | function parseBoolean(stringValue) { |
| 8 | if (typeof stringValue === "boolean") { |
| 9 | return stringValue |
| 10 | } |
| 11 | if (typeof stringValue === "number") { |
| 12 | return stringValue !== 0 |
| 13 | } |
| 14 | if (typeof stringValue !== "string") { |
| 15 | return false |
| 16 | } |
| 17 | switch (stringValue?.toLowerCase()?.trim()) { |
| 18 | case "true": |
| 19 | case "yes": |
| 20 | case "on": |
| 21 | case "1": |
| 22 | return true |
| 23 | |
| 24 | case "false": |
| 25 | case "no": |
| 26 | case "off": |
| 27 | case "0": |
| 28 | case "none": |
| 29 | case null: |
| 30 | case undefined: |
| 31 | return false |
| 32 | } |
| 33 | try { |
| 34 | return Boolean(JSON.parse(stringValue)) |
| 35 | } catch { |
| 36 | return Boolean(stringValue) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // keep in sync with `ui/easydiffusion/utils/save_utils.py` |
| 41 | const TASK_MAPPING = { |