SketchCode手稿生成 HTML 代碼
SketchCode是一種深度學(xué)習(xí)模型,它采用手繪的Web原型并將其轉(zhuǎn)換為有效的HTML代碼,使用圖像字幕體系結(jié)構(gòu)從手繪網(wǎng)站線框生成HTML標(biāo)記。
注意:此項(xiàng)目是概念驗(yàn)證;該模型性能依賴于類似于核心數(shù)據(jù)集的線框。
依賴
- Python 3 (not compatible with python 2)
- pip
安裝依賴
pip install -r requirements.txt
用法示例
下載數(shù)據(jù)和預(yù)訓(xùn)練的權(quán)重:
# Getting the data, 1,700 images, 342mb git clone https://github.com/ashnkumar/sketch-code.git cd sketch-code cd scripts # Get the data and pretrained weights sh get_data.sh sh get_pretrained_model.sh
使用預(yù)訓(xùn)練的權(quán)重將示例繪制的圖像轉(zhuǎn)換為HTML代碼:
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
一般用法
使用權(quán)重將單個(gè)圖像轉(zhuǎn)換為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}
將文件夾中的一批圖像轉(zhuǎn)換為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}
訓(xùn)練模型:
cd src
# training from scratch
# <augment_training_data> 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分?jǐn)?shù)評(píng)估生成的預(yù)測
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}
評(píng)論
圖片
表情
