#186 Feature: Allow lora weight to go negative

功能:允许lora权重数为负数
This commit is contained in:
Physton
2023-08-25 11:43:51 +08:00
parent 6b23c27d8f
commit f250ca9741
5 changed files with 12 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -327,7 +327,7 @@
@mousemove.stop=""
@mouseup.stop="">
<vue-number-input class="input-number" :model-value="tag.weightNum" center controls
:min="0" :step="0.1" size="small"
:min="tag.isLora || tag.isLyco ? -100 : 0" :step="0.1" size="small"
@update:model-value="onTagWeightNumChange(tag.id, $event)"></vue-number-input>
<button type="button" v-tooltip="getLang('increase_weight_add_parentheses')"
@click="onIncWeightClick(tag.id, +1)">

View File

@@ -382,11 +382,11 @@ export default {
this._setTag(tag)
}
} else {
// 如果原来的括号是<>那么最小权重数只能是0.1
const bracket = common.hasBrackets(value)
if (bracket[0] === '<' && bracket[1] === '>') {
weightNum = 0.1
if (tag.isLora || tag.isLyco) {
tag.value = value.replace(common.weightNumRegex, '$1:' + weightNum)
if (localValue !== '') tag.localValue = tag.localValue.replace(common.weightNumRegex, '$1:' + weightNum)
} else {
if (weightNum <= 0) weightNum = 0
if (this.autoKeepWeightZero) {
// 保留权重数
tag.value = value.replace(common.weightNumRegex, '$1:0')

View File

@@ -5,9 +5,9 @@ import tinycolor from "tinycolor2";
export default {
loraRegex: /^\<lora:\s*([^\:]+)\s*(:)?\s*([0-9\.]+)?\>$/,
lycoRegex: /^\<lyco:\s*([^\:]+)\s*(:)?\s*([0-9\.]+)?\>$/,
weightNumRegex: /(.*):([0-9\.]+)/,
weightNumRegexEN: /(.*):\s*([0-9\.]+)/,
weightNumRegexCN: /(.*)\s*([0-9\.]+)/,
weightNumRegex: /(.*):(-?[0-9\.]+)/,
weightNumRegexEN: /(.*):\s*(-?[0-9\.]+)/,
weightNumRegexCN: /(.*)\s*(-[0-9\.]+)/,
bracketsEN: [
{'(': '(', ')': ')'},
{'[': '[', ']': ']'},