CoolFace
Apppublic

Suyiran66/webpages

sourceHugging Faceafl-3.0updated 3y agoView on Hugging Face
1likes
main_program.cpython-38.pyc25 linesDownload Raw Back to __pycache__
1U

2���bC�@s\ddlmZddlmZdZddlZddlmZddlTddlTdd�Z	d	d3�Z4dd�ZdS)
�)�absolute_import)�print_functionz"Taneem Jan, taneemishere.github.ioN��basename)�*c	Cs�d}d}|}d}d}tjd�|�dd�}|d}|d	}t|||�}	|	�|�t|||t�}5d6}t|�dt|��d��}t�	|t7�}|dkr�|8�|	t�|g��\}
}t
d�|
��td
�||�d�� }|�|
�td��td��W5QRX||fS)Nzclasses/model/bin�9Main_Model�data/output/�greedyz{}/meta_dataset.npyT)�allow_pickler�zinput_image_from_interface.png�.zResult greedy: 10 {}z	{}/{}.gui�w�)�np�load�formatrZSamplerZCONTEXT_LENGTHr�find�UtilsZget_preprocessed_imgZ11IMAGE_SIZEZpredict_greedy�array�print�open�write�replaceZSTART_TOKENZ	END_TOKEN)�input_imageZtrained_weights_pathZtrained_model_name�12input_path�output_pathZ
search_methodZmeta_datasetZinput_shape�output_size�modelZsampler�	file_nameZevaluation_img�result�_�out_f�r"�}/Users/taneemishere/Projects/fyp-huggingface-space/html-code-generation-from-images-with-deep-neural-networks/main_program.py�dsl_code_generation
s(13$r$cs�ddlm}ddlm�ddlm}||}tj�|�}tj�|�d}d|d}|}d�d�d	}||�}���fd14d�}	||�d||��	d��}15|d|�	|16��}d
�17||18�}d�19||20�}
|j||
|	d�}td�|S)Nrr)r)�Compilerrz.guiTz[]z$compiler/assets/web-dsl-mapping.jsoncst�rp|�d�dkr$|������}nL|�d�dkrJ|���jddd��}n&|�d�dkrp|���jdd	d21d��}|S)NZbtn������title�r)�length_text�space_number�text�8�F)r)r*Zwith_upper_case)rrZget_random_text)�key�value�ZFILL_WITH_RANDOM_TEXTZTEXT_PLACE_HOLDERrr"r#�render_content_with_text@s�z-compile_gui.<locals>.render_content_with_textrz{}{}.guiz	{}{}.html)Zrendering_functionzGenerated code is compiled..!!)
�os.pathrZcompiler.UtilsrZcompiler.Compilerr%�os�path�splitextrr�compiler)�	file_path�filenamerr%rZfile_�22input_fileZdsl_path�compilerr1Zfile_uidr4Zinput_file_pathZoutput_file_pathZ	html_coder"r0r#�compile_gui*s(r;cCst|�\}}t||�}|S)N)r$r;)Zinput_image_from_interfacerZfile_output_pathrr"r"r#�main_methodVs23r<)�24__future__rr�25__author__r2r3rZclasses.SamplerZclasses.model.Main_Modelr$r;r<r"r"r"r#�<module>s,