设计稿自动生成html,SketchCode

该博客介绍了如何利用Python脚本将单个或批量PNG图像转换为HTML代码,使用的模型可以通过训练数据进行更新。训练过程包括从头开始训练和使用预训练模型继续训练。此外,还提供了评估生成的GUI预测的工具,使用BLEU分数作为指标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cd src

python convert_single_image.py --png_path ../examples/drawn_example1.png \

--output_folder ./generated_html \

--model_json_file ../bin/model_json.json \

--model_weights_file ../bin/weights.h5

一般用法

使用权重将单个图像转换为HTML代码:

cd src

python convert_single_image.py --png_path {path/to/img.png} \

--output_folder {folder/to/output/html} \

--model_json_file {path/to/model/json_file.json} \

--model_weights_file {path/to/model/weights.h5}

将文件夹中的一批图像转换为HTML:

cd src

python convert_batch_of_images.py --pngs_path {path / to / folder / with / pngs} \

--output_folder {folder / to / output / html} \

--model_json_file {path / to / model / json_file.json} \

- -model_weights_file {path / to / model / weights.h5}

训练模型:

cd src

# training from scratch

# adds Keras ImageDataGenerator augmentation for training images

python train.py --data_input_path {path/to/folder/with/pngs/guis} \

--validation_split 0.2 \

--epochs 10 \

--model_output_path {path/to/output/model}

--augment_training_data 1

# training starting with pretrained model

python train.py --data_input_path {path/to/folder/with/pngs/guis} \

--validation_split 0.2 \

--epochs 10 \

--model_output_path {path/to/output/model} \

--model_json_file ../bin/model_json.json \

--model_weights_file ../bin/pretrained_weights.h5 \

--augment_training_data 1

使用BLEU分数评估生成的预测

cd src

# evaluate single GUI prediction

python evaluate_single_gui.py --original_gui_filepath {path/to/original/gui/file} \

--predicted_gui_filepath {path/to/predicted/gui/file}

# training starting with pretrained model

python evaluate_batch_guis.py --original_guis_filepath {path/to/folder/with/original/guis} \

--predicted_guis_filepath {path/to/folder/with/predicted/guis}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值