Download ui/src/helpers/captionJobConfig.ts from michaelu0826/ai_toolkit_code: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/datasets/michaelu0826/ai_toolkit_code/resolve/main/ui/src/helpers/captionJobConfig.ts
- Command line
-
hf download hf://datasets/michaelu0826/ai_toolkit_code/ui/src/helpers/captionJobConfig.ts
-
curl -L -o captionJobConfig.ts https://huggingface.co/datasets/michaelu0826/ai_toolkit_code/resolve/main/ui/src/helpers/captionJobConfig.ts
2.03 kB
| import { CaptionJobConfig } from "@/types"; | |
| import { captionerTypes } from "./captionOptions"; | |
| export const defaultCaptionJobConfig: CaptionJobConfig = { | |
| job: 'extension', | |
| config: { | |
| name: 'Caption Directory', | |
| process: [ | |
| { | |
| type: 'AceStepCaptioner', | |
| sqlite_db_path: './aitk_db.db', | |
| device: 'cuda', | |
| caption: { | |
| model_name_or_path: "ACE-Step/acestep-transcriber", | |
| model_name_or_path2: "ACE-Step/acestep-captioner", | |
| dtype: 'bf16', | |
| quantize: true, | |
| qtype: 'float8', | |
| low_vram: true, | |
| extensions: ['mp3', 'wav', 'flac', 'ogg'], | |
| path_to_caption: '', | |
| recaption: false, | |
| }, | |
| }, | |
| ], | |
| }, | |
| }; | |
| const repairDefaults = (defaults: { [key: string]: any }) => { | |
| let newDefaults: { [key: string]: any } = {}; | |
| // if the key doesnt start with config.process[0]., then add it | |
| for (const key in defaults) { | |
| if (!key.startsWith('config.process[0].')) { | |
| newDefaults[`config.process[0].${key}`] = defaults[key]; | |
| } else { | |
| newDefaults[key] = defaults[key]; | |
| } | |
| } | |
| return newDefaults; | |
| } | |
| export const handleCaptionerTypeChange = ( | |
| currentTypeName: string, | |
| newTypeName: string, | |
| jobConfig: CaptionJobConfig, | |
| setJobConfig: (value: any, key: string) => void, | |
| ) => { | |
| const currentType = captionerTypes.find(a => a.name === currentTypeName); | |
| if (!currentType || currentType.name === newTypeName) { | |
| return; | |
| } | |
| // update the defaults when a model is selected | |
| const newType = captionerTypes.find(model => model.name === newTypeName); | |
| let currentDefaults = repairDefaults(currentType.defaults || {}); | |
| let newDefaults = repairDefaults(newType?.defaults || {}); | |
| // set new model | |
| setJobConfig(newTypeName, 'config.process[0].type'); | |
| // revert defaults from previous model | |
| for (const key in currentDefaults) { | |
| setJobConfig(currentDefaults[key][1], key); | |
| } | |
| for (const key in newDefaults) { | |
| setJobConfig(newDefaults[key][0], key); | |
| } | |
| }; | |