Skip to content

Commit

Permalink
func: ink_depth_sigma
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Sep 17, 2023
1 parent 31dae94 commit 2a3177e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def generate_handwriting():
font=font,
line_spacing=int(data["line_spacing"]), # + int(data["font_size"])
# fill=ast.literal_eval(data["fill"])[:3], # Ignore the alpha value
fill=(0),
# fill=(0),#如果feel是只有一个颜色的话那么在改变墨水的时候会导致R变化而GB不变化,颜色会变红 9.17
left_margin=int(data["left_margin"]),
top_margin=int(data["top_margin"]),
right_margin=int(data["right_margin"]) - int(data["word_spacing"]) * 2,
Expand All @@ -307,6 +307,7 @@ def generate_handwriting():
strikethrough_width_sigma=float(data["strikethrough_width_sigma"]), # 删除线宽度随机扰动
strikethrough_angle_sigma=float(data["strikethrough_angle_sigma"]), # 删除线角度随机扰动
strikethrough_width=float(data["strikethrough_width"]), # 删除线宽度
ink_depth_sigma=float(data["ink_depth_sigma"]), # 墨水深度随机扰动
)
images = handwrite(text_to_generate, template)
logger.info("images generated successfully")
Expand Down
Binary file modified backend/requirements.txt
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const messages = {
strikethrough_angle_sigma:
"Standard deviation of the strikethrough angle",
strikethrough_width: "Width of strikethrough",
ink_depth_sigma: "Standard deviation of ink depth",
},
},
cn: {
Expand Down Expand Up @@ -105,6 +106,7 @@ const messages = {
strikethrough_width_sigma: "涂改线宽度的标准差",
strikethrough_angle_sigma: "涂改线角度的标准差",
strikethrough_width: "涂改线宽度",
ink_depth_sigma: "墨汁深度标准差",
},
},
};
Expand Down
19 changes: 16 additions & 3 deletions frontend/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@
<input type="number" v-model="strikethrough_width" />
</label>
</div>


<div class='label-container'>
<label>{{ $t('message.ink_depth_sigma') }}:
<input type="number" v-model="ink_depth_sigma" />
</label>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -281,8 +286,9 @@ export default {
strikethrough_width_sigma: 2,
strikethrough_probability: 0.08,
strikethrough_width: 8,
ink_depth_sigma: 10,
isExpanded: false,
localStorageItems: ['text', 'fontFile', 'fontSize', 'lineSpacing', 'fill', 'width', 'height', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight', 'selectedFontFileName', 'selectedOption', 'lineSpacingSigma', 'fontSizeSigma', 'wordSpacingSigma', 'perturbXSigma', 'perturbYSigma', 'perturbThetaSigma', 'wordSpacing', 'strikethrough_length_sigma', 'strikethrough_angle_sigma', 'strikethrough_width_sigma', 'strikethrough_probability', 'strikethrough_width'],
localStorageItems: ['text', 'fontFile', 'fontSize', 'lineSpacing', 'fill', 'width', 'height', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight', 'selectedFontFileName', 'selectedOption', 'lineSpacingSigma', 'fontSizeSigma', 'wordSpacingSigma', 'perturbXSigma', 'perturbYSigma', 'perturbThetaSigma', 'wordSpacing', 'strikethrough_length_sigma', 'strikethrough_angle_sigma', 'strikethrough_width_sigma', 'strikethrough_probability', 'strikethrough_width', 'ink_depth_sigma'],
};
},
created() {
Expand Down Expand Up @@ -498,6 +504,12 @@ export default {
},
deep: true
},
ink_depth_sigma: {
handler(newVal) {
localStorage.setItem('ink_depth_sigma', JSON.stringify(newVal));
},
deep: true
},
},
methods: {
Expand All @@ -506,7 +518,7 @@ export default {
},
async generateHandwriting(preview = false) {
// 验证输入
const Items = ['text', 'backgroundImage', 'fontSize', 'lineSpacing', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight', 'lineSpacingSigma', 'fontSizeSigma', 'wordSpacingSigma', 'perturbXSigma', 'perturbYSigma', 'perturbThetaSigma', 'wordSpacing', 'strikethrough_length_sigma', 'strikethrough_angle_sigma', 'strikethrough_width_sigma', 'strikethrough_probability', 'strikethrough_width'];
const Items = ['text', 'backgroundImage', 'fontSize', 'lineSpacing', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight', 'lineSpacingSigma', 'fontSizeSigma', 'wordSpacingSigma', 'perturbXSigma', 'perturbYSigma', 'perturbThetaSigma', 'wordSpacing', 'strikethrough_length_sigma', 'strikethrough_angle_sigma', 'strikethrough_width_sigma', 'strikethrough_probability', 'strikethrough_width', 'ink_depth_sigma'];
Items.forEach(item => {
let value = this[item];
// if (!value) {
Expand Down Expand Up @@ -605,6 +617,7 @@ export default {
formData.append("strikethrough_width_sigma", this.strikethrough_width_sigma);
formData.append("strikethrough_probability", this.strikethrough_probability);
formData.append("strikethrough_width", this.strikethrough_width);
formData.append("ink_depth_sigma", this.ink_depth_sigma);
for (let pair of formData.entries()) {
console.log(pair[0] + ', ' + pair[1]);
Expand Down
Binary file removed requirements.txt
Binary file not shown.

0 comments on commit 2a3177e

Please sign in to comment.