← back to Trending Dw

scripts/__pycache__/heal-tile.cpython-314.pyc

66 lines

+
#WMjI���Rt^RIt^RIt^RIt^RIt^RIHt^RIt]!R4t	]Pt^t^ t
RRltRtRtRt]R	8Xd
]!4R#R#)
u�
heal-tile.py — file-based seam healer for trending-dw gap candidates.

The gapgen pipeline is self-host + file-based (candidates are PNGs in /tmp/gap-cand,
no DB). wallco-ai's heal-seam-region.py does the same joint-healing but is coupled
to the all_designs DB table, so it can't be used here. This lifts its pure-numpy
heal algorithm (heal_band_mid / heal_edge_wrap) and drives it from a PNG PATH:

  1. scan the tile via wallco-ai/scripts/seam-defect-boxes.py --path  (get FAIL/WARN boxes)
  2. heal each flagged joint in-place  (v_mid/h_mid band-average, *_edge mirror-wrap)
  3. save <name>_healed.png  (NEVER overwrites the source — round-1 output is sacred)
  4. re-scan the healed file and print before/after JSON

This is the motif-lane rescue the DTD panel required before motif generation resumes:
figural motifs (leopard/paisley/deco) tile badly (seam 15-46); healing their joints
can pull a near-miss under the <=5 gate without re-rolling (which discards the design).

Usage:
  python3 scripts/heal-tile.py --path /tmp/gap-cand/TR-020__s123.png
  python3 scripts/heal-tile.py --path <png> --kinds v_mid,h_mid   # heal only these joints
Exit 0 if the healed tile PASSES seam (overall_max <= 5), else 1.
N)�PathzA/Users/macstudio3/Projects/wallco-ai/scripts/seam-defect-boxes.pyc�0�V^8�dQhR\R\/#)��png�return)r�dict)�formats"�scripts/heal-tile.py�__annotate__r
#s��M�M�d�M�t�M�c��\P!\\\4R\V4.RR^<R7pVP
^8wd.\
RVPP4R,24h\P!VP4# \Pd&p\
RTPR,24ThRp?ii;i)�--pathT)�capture_output�text�timeoutzseam scan failed: :N��Nzseam scan bad JSON: N)
�
subprocess�run�PY�str�WALLCO_SEAM�
returncode�RuntimeError�stderr�strip�json�loads�stdout�JSONDecodeError)r�r�excs&  r	�scanr!#s�������C��,�h��C��A�RV�]a�km�n�A��|�|�q���/������0@��0F�/G�H�I�I�M��z�z�!�(�(�#�#�����M��1�!�(�(�4�.�1A�B�C��L��M�s�8B�C�- C
�
Cc���VPR,wrVVR8XEdf\^V\^,,
4p\Wb\^,,4pWV1\^V\,
^,
4V1R3,P^R7p	WV1V\Wb\,41R3,P^R7p
W�,^,P
4PR4p\Wx4Fp\R\R^\W�,
4\^,,,
44p
W�,WV1VR3,^V
,
,,PR4WV1VR3&K�	R#\^V\^,,
4p\WR\^,,4pV\^V\,
^,
4V1W41R3,P^R7pW\WR\,41W41R3,P^R7pVV,^,P
4PR4p\W�4F�p\R\R^\VV,
4\^,,,
44p
W�,VVW41R3,^V
,
,,PR4VVW41R3&K�	R#)	zyaxis='v': vertical seam at x=idx, healing rows [start:end];
axis='h': horizontal seam at y=idx, healing cols [start:end].�NrN�v�NNN)�axis�uint8gg�?N)
�shape�max�BAND_PX�min�BLEND_PX�mean�round�astype�range�abs)�arrr&�idx�start�end�H�W�x0�x1�left�right�avg�x�w�y0�y1�top�bot�ys&&&&&              r	�
heal_band_midrD.sU���9�9�R�=�D�A��s�{�
��C�'�Q�,�&�
'��c�!�7�a�<�5G�.H���#�I�s�1�c�H�n�q�&8�9�#�=�q�@�A�F�F�A�F�N���#�I�s�3�q��.�#9�9�1�<�=�B�B��B�J�����!�(�(�*�1�1�'�:���r��A��C��S�!�c�!�'�l�g��k�&B�"B�C�D�A�$'�G�c��)�Q��/�.B�a�!�e�.L�$L�#T�#T�U\�#]�C�c�	�1�a�� ����C�'�Q�,�&�
'��c�!�7�a�<�5G�.H���#�a��x��!�+�,�S�0�%�)�Q�>�?�D�D�!�D�L���c�!�8�^�,�,�e�i��:�;�@�@�a�@�H���c�	�Q��%�%�'�.�.�w�7���r��A��C��S�!�c�!�c�'�l�g��k�&B�"B�C�D�A�$'�G�c�!�U�Y��/�.B�a�!�e�.L�$L�#T�#T�U\�#]�C��5�9�a�� �rc��VPR,wrE^pVR9d�Y#r�V^V1Wx1R3,PR4p	WV,
V1Wx1R3,PR4p
W�RRR1RR3,,^,PR4pW�^V1Wx1R3&VRRR1RR3,WV,
V1Wx1R3&R#VR9d�Y#r�WV
1^V1R3,PR4pWV
1WV,
V1R3,PR4pW�RRRR1R3,,^,PR4pW�W�1^V1R3&VRRRR1R3,WV
1WV,
V1R3&R#R#)	z�Average each edge strip with its opposite-edge mirror so the tile-repeat
boundary is invisible. kind in {top,bottom,left,right}_edge.r#r%�float32Nr'��top_edge�bottom_edge�������	left_edge�
right_edge)r(r/)r2�kindr4r5r6r7�Sr8r9rA�bottom�blendr?r@r:r;s&&&&            r	�heal_edge_wraprRDs����9�9�R�=�D�A�
�A��*�*��B��!�A�#�r�u�a�-� �'�'�	�2����U�1�W�b�e�Q�&�'�.�.�y�9���t��t�Q��z�*�*�a�/�7�7��@��"�A�a�C����M��!&�t��t�Q��z�!2���E�!�G�R�U�A���	
�,�	,��B��b�5�!�A�#�q�=�!�(�(��3���r�E�1�5��7�A�%�&�-�-�i�8���q�$�B�$��z�*�*�a�/�7�7��@��"�B�E�1�Q�3��M��!&�q�$�B�$��z�!2��r�E�1�5��7�A���

-rc��\P!4pVPRRRR7VPRRR7VP4p\	VP
4pVP
4'g=\\P!RRR	R
V2/44\P!^4\V4pVPR.4pVP'dE\VPP!R44pVUu.uFqfR
,V9gKVNK	ppV'g^\\P!RRRRRVR,RVR,R^/44\P!VR,R8Xd^M^4^RIHp\&P(!VP+V4P-R44P/4pVP0R,wr�VF�pVR
,q�R,VR,VR,VR,3wr�r�VR8Xd\3VRV
^,W�V,4KUVR8Xd\3VRV	^,W�V,4KzVR(9d\5W�W�V,4K�VR)9gK�\5W�W�V,4K�	VP7VP8R,4pVP;V4P=VRR7\V4pVR,PR ^c4R!8*p\\P!RRR"\?V4R#\?V4R\AV4R$RVR,R \CVR,PR ^4^4/R%RVR,R \CVR,PR ^4^4/R&V/44\P!V'd	^4R'#^4R'#uupi)*r
TzPNG candidate to heal)�required�helpz--kindsz:comma-separated joint kinds to heal (default: all flagged))rU�okF�errorznot found: �boxes�,rN�notezno joints to heal�verdict�scores�healed_boxes�PASS)�Image�RGBr#r=rCr>�h�v_midr$�h_midz_healed.png)�optimize�overall_maxg@�src�healed�before�after�passes_seam_gateNrGrK)"�argparse�ArgumentParser�add_argument�
parse_argsr�path�exists�printr�dumps�sys�exitr!�get�kinds�set�split�PILr_�np�asarray�open�convert�copyr(rDrR�	with_name�stem�	fromarray�saver�lenr.)�ap�argsrfrhrX�wanted�br_r2r6r7�kr=rCr>ra�outri�passeds                   r	�mainr�Ys��	�	 �	 �	"�B��O�O�H�t�2I�O�J��O�O�I�$`�O�a�
�=�=�?�D�
�t�y�y�/�C��:�:�<�<�
�d�j�j�$��w�+�c�U�0C�D�E�F����QR��
�#�Y�F��J�J�w��#�E��z�z�z��T�Z�Z�%�%�c�*�+��!�9�E�q�v�Y�&�%8���E��9��
�d�j�j�$��f�.A�9�f�U^�N_�"�F�8�$4�n�a�I�J�	K����f�Y�'�6�1��q�9��
�*�*�U�Z�Z��_�,�,�U�3�
4�
9�
9�
;�C��9�9�R�=�D�A�
��
�f�I��c�F�A�c�F�A�c�F�A�c�F�$B�z�q�Q���<��#�s�A��F�A�1�u�5�
�'�\��#�s�A��F�A�1�u�5�
�-�
-��3�1�!�e�,�
�-�
-��3�1�!�e�,���-�-����=�0�
1�C�	�O�O�C����c�D��1���I�E�
�8�_�
 �
 ���
3�s�
:�F�	�$�*�*��d�E�3�s�8�X�s�3�x���U���9�f�Y�/���f�X�FV�FZ�FZ�[h�jk�Fl�no�@p�q��9�e�I�.���e�H�o�FY�FY�Zg�ij�Fk�mn�@o�p��F�	����H�H�&�Q� �a� ��A:s�O�O�__main__)�__doc__rkrrrs�pathlibr�numpyrzr�
executablerr,r*r!rDrRr��__name__�rr	�<module>r�sa���,'�&����V�W���^�^����
��M�^�,3�*.!�b�z���F�r