
    X5jY                     r   d dl Zd dlZd dlZd dlZd dlZd dlZd dlmZ  ed          Z	 ed          Z
e	dz  Ze	dz  Ze	dz  Ze	dz  Ze	d	z  Ze	d
z  Z eej                            dd                    ZdZdZdZe	dz  e	dz  e	dz  e	dz  dZd Zd Zd Zd Zd Zd Zd Ze dk    r e             dS dS )    N)PathzZ/data/video-pipeline/Youtube-Video-Maker/Project/28052026-002-Tran-Quang-Dieu-Bui-Thi-XuanzD/home/hermes/.hermes/skills/media/gen-img-gpt/scripts/gen_img_gpt.pyzscript/scenes.jsonz$script/character_reference_plan.jsonzimages/sceneszoutput/thumbnailszlogs/step06_images_run.logz logs/step06_images_manifest.jsonSTEP06_WORKERS7a  16:9 horizontal historical storytelling image, centered irregular ink-wash narrative window on warm antique cream paper, painted content occupies only about 65-70 percent of page with 30-35 percent clean antique paper negative space, handcrafted Vietnamese co phong feeling, muted brown black charcoal watercolor wash, not modern, not full-frame glossy digital poster, not fantasy splash art, not 3D game key art, no text, no watermark.z16:9 horizontal light Vietnamese old-calligraphy title-card on warm antique paper, subtle ink wash and small red seal stamp accent, airy text with breathing room, not heavy black title slam, not clean modern typography.a'  Avoid modern objects, wrong culture, Chinese opera costume, European armor, fantasy armor, samurai, gun unless historically contextualized, character sheet layout, model sheet, multiple views, floating costume parts, text labels, watermark, logo, glossy poster, edge-to-edge full-frame painting.z#images/refs/tran_quang_dieu_ref.pngz images/refs/bui_thi_xuan_ref.pngzimages/refs/quang_trung_ref.pngzimages/refs/nguyen_anh_ref.png)tran_quang_dieubui_thi_xuanquang_trung
nguyen_anhc                 2   t          j        d          | z   }t          |d           t          j                            dd           t                              dd          5 }|                    |dz              d d d            d S # 1 swxY w Y   d S )	Nz%Y-%m-%d %H:%M:%S T)flushparentsexist_okautf-8encoding
)timestrftimeprintLOGparentmkdiropenwrite)msglinefs      x/data/video-pipeline/Youtube-Video-Maker/Project/28052026-002-Tran-Quang-Dieu-Bui-Thi-Xuan/scripts_run_step_06_images.pylogr       s    =-..4D	$dJTD111	#	(	( A	t                 s   &BBBc                 v   |                                  }g }d|v r |                    t          d                    d|v r |                    t          d                    d|v sd|v r |                    t          d                    d|v sd	|v r |                    t          d
                    d |D             S )Nu   trần quang diệur   u   bùi thị xuânr   zquang trungu   nguyễn huệr   u   nguyễn ánhzgia longr	   c                 :    g | ]}|                                 |S  )exists).0ps     r   
<listcomp>zscene_refs.<locals>.<listcomp>(   s%    ***!qxxzz*A***    )lowerappendREFS)texttrefss      r   
scene_refsr/   !   s    

AD!!4;;t4E/F#G#G#GQD,@ A A A-22DKK]@S4T4T4T!zQD<N0O0O0O**t****r(   c           	      ~   |                      d          dk    rt           d| d          dt           S t          |                      dd          dz   |                      dd          z             }d}|rd	}t           d
| d          d|                      d          p|                      d           d| dt           	S )Ntypeheadingz>
Vietnamese title card text to depict accurately if possible: 	narrationz>
No character portraits unless subtle silhouettes are needed.   summaryzUse attached character reference image(s) only to keep identity, age, face, costume language, and temperament consistent. Do not reproduce a reference sheet. Create one cinematic story scene with environment and action. u   
Historical context: late 18th century Vietnam, Tây Sơn era, Bình Định martial land, war and political upheaval.
Narration beat: z
Visual direction: visual_beatvisual_promptr   zOne cinematic narrative scene, historically grounded Vietnamese clothing, armor, weapons, architecture, terrain, and atmosphere.
Negative exclusions: )getSTYLE_HEADINGNEGr/   STYLE_SCENE)scener.   ref_notes      r   
prompt_forr?   *   sb   yyI%%  y  y`efq`r  y  y  tw  y  y  	yeiiB//#5		)B8O8OOPPDH r r  m  m  ej  kv  ew  m  m  MR  MV  MV  Wd  Me  Me  MC  in  ir  ir  sB  iC  iC  m  m  GO  m  m  hk  m  m  mr(   c                 h   t           | d          dz  }|                                rN|                                j        dk    r1| d         dt	          |          |                                j        dS t
          j        t	          t                    dt          |           dt	          |          dd	d
d	dd	ddddddg}t          | 
                    dd          dz   | 
                    dd          z             d d         D ]}|dt	          |          gz  }t          j        |ddd          }|j        dk    r.| d         dt	          |          |j        p|j        dd          dS | d         dt	          |          |                                r|                                j        nddS ) Nscene_idz.png  skipped_exists)rA   statusoutputbytes--prompt--output--sizeauto	--quality--background--image-detailhigh--output-formatpng--n1r3   r4   r5   r6      --input-refT  r,   capture_outputtimeoutr   failed0)rA   rD   rE   errorok)
OUT_SCENESr$   statst_sizestrsys
executable
GEN_SCRIPTr?   r/   r9   
subprocessrun
returncodestderrstdout)r=   outcmdrefr&   s        r   run_onerl   3   s   
%
+111
1C
zz|| |

*T11!*-9IUXY\U]U]hkhphphrhrhz{{{>3z??J
58I8I:WZ[^W_W_aikqs~  AG  IW  Y_  aq  sy  {L  NS  UZ  \_  `C%))K33c9EIIiPR<S<SSTTUWVWUWX ) )s3xx((sdDIIIA|q!*-SQTXXabaiaumnmuw|w}w}`~j)TSXXnqnxnxnznz  YBX[X`X`XbXbXjXj  AB  C  C  Cr(   c                      | dk    rdnd}| dS )N16x9z!16:9 YouTube thumbnail, 1920x1080z/9:16 vertical short thumbnail/poster, 1080x1920u  . Cinematic Vietnamese historical biography poster for the story title 'HAI NGỌN GIÁO GIỮA BÃO TÂY SƠN'. Large dramatic portraits of Trần Quang Diệu and Bùi Thị Xuân, husband and wife Tây Sơn generals, with smoky battlefield, war elephant silhouette, Tây Sơn banners, parchment manuscript texture, dark sepia bronze black palette, large readable metallic-gold Vietnamese brush lettering over irregular black ink-splash title panel. Historically grounded late 18th century Vietnam, not modern, not fantasy, no watermark.r#   )kindaspects     r   thumb_promptrq   ?   s1    48FNN00HyF  r  r  r  rr(   c                    |                                 rH|                                j        dk    r+| dt          |          |                                j        dS t          j        t          t                    dt          |           dt          |          ddddd	dd
ddddddt          t          d                   dt          t          d                   g}t          j
        |ddd          }|j        dk    r(| dt          |          |j        p|j        dd          dS | dt          |          |                                 r|                                j        nddS )NrB   rC   )ro   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rT   r   r   TrU   rV   r   rY   rZ   )ro   rD   rE   r[   r\   )r$   r^   r_   r`   ra   rb   rc   rq   r+   rd   re   rf   rg   rh   )ro   ri   rj   r&   s       r   	gen_thumbrs   C   s   
zz|| k

*T11(8CHHWZW_W_WaWaWijjj>3z??JT8J8JJX[\_X`X`bjlrt  BH  JX  Z`  br  tz  |M  OT  V[  ]`  bo  qt  uy  zK  uL  qM  qM  O\  ^a  bf  gu  bv  ^w  ^w  xCsdDIIIA|qCHHPQPXPd\]\dfkflflOmnnnDCHH]`]g]g]i]iGpsxxzzGYGYopqqqr(   c                    	 t                               dd           t                              dd           t          j                            dd           t          j        t                              d                    } | d         }g }t          dt          |           dt                      t          j                            t                    5 		fd	|D             }t          j                            |          D ]}|                                }|                    |           t          d
|v r6|d          d|                    d
           d|                    d           nt'          |                     |d         dk    r:t          d|d
         z   dz   |                    dd          d d         z              	 d d d            n# 1 swxY w Y   g }t)          d |D                       st          d           |                    t+          dt          dz                       t          t'          |d                              |                    t+          dt          dz                       t          t'          |d                              t-          d |D                       r.t-          d |D                       rt          |          dk    rdnd}t.          j        d |t          t          |          ||t'          t                     t'          t                    d!d"}t2                              t          j        |d#d$          d           t          d%t          j        |t9          d& |D                       t          |          t          |          d'd#(          z              |dk    rt;          d          d S ))NTr   r   r   sceneszSTART step6 scenes=z	 workers=)max_workersc                 H    i | ]}                     t          |          |S r#   )submitrl   )r%   sexs     r   
<dictcomp>zmain.<locals>.<dictcomp>S   s)    999Q		'1%%q999r(   rA   rD   r5   z bytes=rF   rY   zERROR r[   r4   i  c              3   .   K   | ]}|d          dk    V  dS )rD   rY   Nr#   r%   rs     r   	<genexpr>zmain.<locals>.<genexpr>Z   s+      66q{H$666666r(   zSTART thumbnailsrn   zthumb_16x9_final.png9x16zthumb_9x16_final.pngc              3   *   K   | ]}|d          dv V  dS rD   r\   rC   Nr#   r}   s     r   r   zmain.<locals>.<genexpr>`   s,      XX1(/F FXXXXXXr(   c              3   *   K   | ]}|d          dv V  dS r   r#   r}   s     r   r   zmain.<locals>.<genexpr>`   s\        a`  a`  MNabckal  qH  bH  a`  a`  a`  a`  a`  a`r(   rS   	completedneeds_retry   )
scenes_dirthumbnails_dir)
project_idsteprD   workerstotal_scenesscene_resultsthumbnail_resultsoutputsF)ensure_asciiindentzDONE c              3   .   K   | ]}|d          dv dV  dS )rD   r      Nr#   r}   s     r   r   zmain.<locals>.<genexpr>c   s4      ={={ATUV^T_czTzTzaTzTzTzTz={={r(   )rD   scenes_donescenes_totalthumbs)r   )r]   r   
OUT_THUMBSr   r   jsonloadsSCENES	read_textr    lenWORKERS
concurrentfuturesThreadPoolExecutoras_completedresultr*   r9   r`   anyrs   allPROJECTnameMANIFEST
write_textdumpssum
SystemExit)
docru   resultsfutsfutr~   thumb_resultsrD   manifestrz   s
            @r   mainr   L   s   TD111:3C3CD[_3C3`3`3`beblbrbr{  KObr  cP  cP  cP
*V%%w%77
8
8C]FG=c&kk==G==>>>			.	.7	.	C	C Hr9999&999%22488 	H 	HC

AgnnQ///z]^1X;KKz!2!2KK155>>KKKdghidjdjkkk{h&&HQz]*3.quuWR/@/@#/FFGGG		HH H H H H H H H H H H H H H H M66g66666 $Yvz:P/PQQRRRCb!""###Yvz:P/PQQRRRCb!""###XXPWXXXXX  M]`  a`  a`  R_  a`  a`  a`  ^`  ^`  M  eh  iv  ew  ew  yz  ez  ez[[  @MF"<q&7beflbmbm  F  [h  AD  EO  AP  AP  be  fp  bq  bq  sr  sr  s  sH
8aHHHRYZZZ
V#={={={={={:{:{  LO  PV  LW  LW  ad  er  as  as  t  t  BG  H  H  H  	H  I  I  I''' s   C6G!!G%(G%__main__)!concurrent.futuresr   r   osrd   ra   r   pathlibr   r   rc   r   PLANr]   r   r   r   intenvironr9   r   r<   r:   r;   r+   r    r/   r?   rl   rq   rs   r   __name__r#   r(   r   <module>r      s   : : : : : : : : : : : : : : : : : : : : : : : :      
$k
l
lTXYY
	'	'77&
**
,,77
#bjnn-s33
4
4 E n p DD>><<::	   + + +m m m
C 
C 
Cr r rr r r( ( (6 zDFFFFF r(   