feat: Allow LoRA weights to be more than sliders via input

Found some LoRA's that need it.
This commit is contained in:
blessedcoolant 2023-07-26 19:08:32 +12:00
parent f5139b174a
commit 397604a094
2 changed files with 10 additions and 5 deletions

View File

@ -114,6 +114,11 @@ const IAISlider = (props: IAIFullSliderProps) => {
setLocalInputValue(value); setLocalInputValue(value);
}, [value]); }, [value]);
const numberInputMin = useMemo(
() => (sliderNumberInputProps?.min ? sliderNumberInputProps.min : min),
[min, sliderNumberInputProps?.min]
);
const numberInputMax = useMemo( const numberInputMax = useMemo(
() => (sliderNumberInputProps?.max ? sliderNumberInputProps.max : max), () => (sliderNumberInputProps?.max ? sliderNumberInputProps.max : max),
[max, sliderNumberInputProps?.max] [max, sliderNumberInputProps?.max]
@ -129,24 +134,23 @@ const IAISlider = (props: IAIFullSliderProps) => {
const handleInputBlur = useCallback( const handleInputBlur = useCallback(
(e: FocusEvent<HTMLInputElement>) => { (e: FocusEvent<HTMLInputElement>) => {
if (e.target.value === '') { if (e.target.value === '') {
e.target.value = String(min); e.target.value = String(numberInputMin);
} }
const clamped = clamp( const clamped = clamp(
isInteger isInteger
? Math.floor(Number(e.target.value)) ? Math.floor(Number(e.target.value))
: Number(localInputValue), : Number(localInputValue),
min, numberInputMin,
numberInputMax numberInputMax
); );
const quantized = roundDownToMultiple(clamped, step); const quantized = roundDownToMultiple(clamped, step);
onChange(quantized); onChange(quantized);
setLocalInputValue(quantized); setLocalInputValue(quantized);
}, },
[isInteger, localInputValue, min, numberInputMax, onChange, step] [isInteger, localInputValue, numberInputMin, numberInputMax, onChange, step]
); );
const handleInputChange = useCallback((v: number | string) => { const handleInputChange = useCallback((v: number | string) => {
console.log('input');
setLocalInputValue(v); setLocalInputValue(v);
}, []); }, []);
@ -310,7 +314,7 @@ const IAISlider = (props: IAIFullSliderProps) => {
{withInput && ( {withInput && (
<NumberInput <NumberInput
min={min} min={numberInputMin}
max={numberInputMax} max={numberInputMax}
step={step} step={step}
value={localInputValue} value={localInputValue}

View File

@ -48,6 +48,7 @@ const ParamLora = (props: Props) => {
handleReset={handleReset} handleReset={handleReset}
withSliderMarks withSliderMarks
sliderMarks={[-1, 0, 1, 2]} sliderMarks={[-1, 0, 1, 2]}
sliderNumberInputProps={{ min: -50, max: 50 }}
/> />
<IAIIconButton <IAIIconButton
size="sm" size="sm"