
    䁞h8F                     t    d Z ddlZddlZddlZddlZddlmZ ddlmZ  G d d      Zd Z	e
dk(  r e	        yy)	z
Generate professional stock images for CleanKitchens using DALL-E 3
Version 2: Strict no people, no text except basic caution tape
    N)OpenAI)datetimec                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
StockImageGeneratorc                     t        t        j                  d            | _        d| _        d| _        d| _        dddd| _        d| _        y )	NOPENAI_API_KEY)api_keyzJ/var/www/twin-digital-media/public_html/_sites/cleankitchens/assets/images	1792x1024hdr   )	generatedfailed
total_costaC  Professional photography of empty commercial kitchen, industrial setting, dramatic lighting, high contrast, cinematic quality, photorealistic, ABSOLUTELY NO PEOPLE, NO HUMAN FIGURES, NO SILHOUETTES, NO TEXT, NO WRITING, NO SIGNS WITH WORDS, NO FOREIGN LANGUAGE, plain yellow caution tape only if needed, no logos, no brands)	r   osgetenvclientbase_dir
image_sizequalitystats
style_baseselfs    k/var/www/twin-digital-media/public_html/_sites/cleankitchens/production/scripts/generate_stock_images_v2.py__init__zStockImageGenerator.__init__   sP    RYY/?%@A e & 

 `    c                     g d}|D ]Q  }t         j                  j                  | j                  |      }t        j                  |d       t        d|        S y)z%Create directory structure for images)
violationschainscuisine	summariesT)exist_okzCreated directory: N)r   pathjoinr   makedirsprint)r   
categoriescategoryr"   s       r   create_directoriesz&StockImageGenerator.create_directories$   sL    E
" 	0H77<<x8DKKt,'v./	0r   c                 
   d| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gd	| j                    d
| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d | j                    gd!| j                    d"| j                    d#| j                    d$| j                    gd%| j                    d&| j                    d'| j                    d(| j                    d)| j                    gd*| j                    d+| j                    d,| j                    d-| j                    gd.S )/z5Get prompts for violation images - NO PEOPLE, NO TEXTzEmpty dark industrial kitchen corner with visible mouse droppings scattered on floor near stainless steel equipment, plain yellow caution tape stretched across area, zxDeserted commercial kitchen floor showing rat droppings and gnawed cardboard boxes, no text on boxes, dramatic shadows, zAbandoned restaurant storage area with holes chewed in food containers, pest control bait stations visible, no labels or text, zhEmpty industrial kitchen with mouse tracks in flour dust on stainless steel counter, overhead lighting, zuDeserted commercial kitchen dark corner with cockroaches visible on stainless steel wall, plain yellow barrier tape, zkEmpty industrial dishwashing area with dead roaches on floor, glue traps visible, harsh overhead lighting, zgAbandoned restaurant prep station with roach egg cases in crevices, dramatic shadows, no text visible, z\Vacant commercial kitchen showing roaches near floor drain, industrial lighting from above, u   Empty commercial refrigerator interior with digital thermometer display showing 55°F in red numbers only, frost buildup on walls, zuDeserted industrial kitchen with steam rising from overheated food warming station, red warning lights only no text, zxAbandoned walk-in cooler with ice crystals and condensation, temperature gauge showing red zone, numbers only no words, zhEmpty commercial kitchen hot holding unit with visible temperature problems, steam and heat distortion, zyGrimy empty commercial kitchen with grease buildup on surfaces, plain yellow caution tape blocking area, harsh lighting, zeDeserted industrial dishwashing area with dirty standing water on floor, overhead dramatic lighting, zaAbandoned restaurant prep area with food debris and grime on surfaces, no text or signs visible, z]Empty commercial kitchen with clogged floor drains and accumulated dirt, industrial setting, zwDark empty commercial kitchen corner with black mold growth spreading on walls, moisture dripping, plain barrier tape, zkDeserted industrial refrigerator with fuzzy mold on rubber door seals, close-up detail, dramatic lighting, zgAbandoned restaurant with water-stained ceiling tiles showing mold growth, looking upward perspective, zdEmpty walk-in cooler with green and black mold on walls, condensation visible, industrial lighting, zrEmpty commercial kitchen with raw chicken and vegetables on same cutting board, plain yellow tape dividing areas, zhDeserted prep area with raw meat dripping onto produce below, no labels or text visible, overhead view, z^Abandoned restaurant station with mixed raw and cooked foods stored together, dramatic angle, zdEmpty industrial kitchen with improper food storage, raw above ready-to-eat, no text on containers, zlEmpty commercial kitchen with broken sink fixture, plain yellow caution tape across it, no signs with text, z^Deserted restaurant with empty soap dispensers and missing paper towels, industrial lighting, z\Abandoned handwashing station blocked by stacked boxes, no text on boxes, dramatic shadows, z\Empty industrial kitchen sink area with no soap or towels present, overhead harsh lighting, zkEmpty commercial kitchen with large hole in ceiling exposing pipes and wires, plain caution tape barriers, z]Deserted restaurant with severely cracked floor tiles creating trip hazards, dramatic angle, z^Abandoned industrial kitchen with broken equipment and exposed sharp edges, yellow tape only, zWEmpty commercial space with collapsed ceiling tiles and water damage, no text visible, zkEmpty commercial kitchen with dark water backing up from floor drain, plain yellow caution tape perimeter, zeDeserted restaurant with sewage overflow on floor, industrial lighting from above, no text or signs, zOAbandoned kitchen area with broken pipes leaking dark water, dramatic shadows, zZEmpty dishwashing area with backed up drains and standing murky water, overhead lighting, zrLocked glass restaurant door at night with red paper notice (no readable text), dramatic lighting through window, znEmpty darkened restaurant interior viewed through front window, plain yellow tape across door, evening light, zdClosed restaurant entrance with padlock and chain on handles, red tag attached but no text visible, ziDark empty restaurant with chairs stacked on tables visible through window, yellow barrier tape on door, ziShuttered restaurant storefront with metal grate down, plain red notice shape on door, dramatic shadows, zrWide angle empty industrial kitchen with multiple plain yellow caution tape sections, dramatic overhead lighting, zkDeserted commercial restaurant kitchen with red tags on equipment but no text visible, professional angle, zpAbandoned stainless steel kitchen with inspection clipboard on counter (blank/no text), high contrast lighting, zaEmpty restaurant prep area with plain colored violation tags on equipment, industrial aesthetic, rodentroachtemperaturecleanlinessmoldcross_contaminationhandwashing
structuralsewageclosuregeneralr   r   s    r   get_violation_promptsz)StockImageGenerator.get_violation_prompts-   s=    y  z~  zI  zI  yJ  K K  LP  L[  L[  K\  ] R  SW  Sb  Sb  Rc  dz{  |K  |K  {L  M	 H  IM  IX  IX  HY  Z}  C  N  N  ~O  Pyz~  {J  {J  zK  Lnoso~o~n  A	 V  W[  Wf  Wf  Vg  h H  IM  IX  IX  HY  Z K  LP  L[  L[  K\  ]z{  |K  |K  {L  M	 L  MQ  M\  M\  L]  ^wx|  yH  yH  xI  Jstx  uD  uD  tE  Foptpp  pA  B	 J  KO  KZ  KZ  J[  \}  C  N  N  ~O  Pyz~  {J  {J  zK  Lvw{  xG  xG  wH  I	 E  FJ  FU  FU  EV  Wz{  |K  |K  {L  Mpqu  rA  rA  qB  Cvw{  xG  xG  wH  I	$   @D  @O  @O  P  Qpqu  rA  rA  qB  Cnoso~o~n  Anoso~o~n  A	 ~  C  N  N  ~O  Poptpp  pA  Bpqu  rA  rA  qB  Cijnjyjyiz{	 ~  C  N  N  ~O  Pwx|  yH  yH  xI  Jabfbqbqarslmqm|m|l}~	 E  FJ  FU  FU  EV  W A  BF  BQ  BQ  AR  Svw{  xG  xG  wH  I{  }A  }L  }L  |M  N{  }A  }L  }L  |M  N E  FJ  FU  FU  EV  W}  C  N  N  ~O  P C  DH  DS  DS  CT  Ustx  uD  uD  tE  F	}D
 D	
r   c                    d| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gd	| j                    d
| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d| j                    gdS )z3Get prompts for chain restaurant images - NO PEOPLEzaEmpty generic fast food burger kitchen with grill and fryer equipment, stainless steel surfaces, zbDeserted commercial burger station with flat-top grill and warming lamps, industrial ventilation, zOAbandoned fast food prep counter with burger assembly area, overhead lighting, zREmpty chain restaurant freezer with stacked unmarked boxes, commercial equipment, z^Deserted commercial coffee shop with espresso machines and grinders, stainless steel counter, zPEmpty coffee store prep area with syrup pumps and blenders, industrial setting, zMAbandoned coffee roasting area with commercial equipment, dramatic lighting, zPVacant coffee shop storage with bags of beans (no labels), commercial shelving, zMEmpty industrial pizza kitchen with brick oven glowing, no branding visible, zWDeserted pizzeria prep station with dough mixer and ingredient containers (no labels), zUAbandoned commercial pizza kitchen with multiple deck ovens, industrial ventilation, zDEmpty pizza restaurant cold storage with unmarked ingredient boxes, zZDeserted industrial kitchen with commercial pressure fryers for chicken, stainless steel, zUEmpty chain restaurant with breading station and fryer equipment, overhead lighting, zTAbandoned commercial chicken kitchen with multiple fryer units, industrial setting, zDVacant fast food chicken prep area with freezers and thawing sinks, )burger_chaincoffee_chainpizza_chainchicken_chainr6   r   s    r   get_chain_promptsz%StockImageGenerator.get_chain_promptsu   sy    ttx  uD  uD  tE  Ftuy  vE  vE  uF  Gabfbqbqarsdeietetduv	 qqu  rA  rA  qB  Cbcgcrcrbst_`d`o`o_pqbcgcrcrbst	 ``d`o`o_pqijnjyjyiz{ghlhwhwgxyVW[WfWfVgh	 mmqm|m|l}~ghlhwhwgxyfgkgvgvfwxVW[WfWfVgh	'
 	
r   c                 $   d| j                    d| j                    d| j                    d| j                    d| j                    gd| j                    d| j                    d| j                    d	| j                    d
| j                    gdS )z8Get prompts for summary images - NO PEOPLE, MINIMAL TEXTzwBlank clipboard with inspection checklist grid (no text) on stainless steel surface, pen beside it, overhead lighting, zOStack of blank inspection forms on industrial kitchen counter, dramatic angle, zVDigital tablet showing graph bars only (no text) in empty commercial kitchen setting, z]Red and green inspection grade cards (letter grades A, B, C only) arranged on metal surface, zgInspector's toolkit with clipboard and thermometer on empty stainless steel table, professional angle, zaMultiple blank inspection sheets spread on industrial surface, overhead view, dramatic lighting, zMCalendar grid with red X marks only (no text) in commercial kitchen setting, z\Series of colored grade cards (A, B, C, F only) showing progression, industrial background, zSBlank clipboard with bar chart drawn (no text) in empty kitchen, dramatic shadows, zPDigital screen showing pie chart only (no text) in deserted commercial kitchen, )daily_summaryweekly_summaryr6   r   s    r   get_summary_promptsz'StockImageGenerator.get_summary_prompts   s    J  KO  KZ  KZ  J[  \abfbqbqarshimixixhyzoptpp  pA  Byz~  {J  {J  zK  L ttx  uD  uD  tE  F_`d`o`o_pqnoso~o~n  Aefjfufuevwbcgcrcrbst
 	
r   c           	      l   	 t        d| d| d       |dz   }| j                  j                  j                  d|| j                  | j
                  d      }|j                  d   j                  }t        j                  |      }|j                  d	k(  r|d
v rd}nd|v rd}n	d|v rd}nd}| d| d}	t        j                  j                  | j                  ||	      }
t        |
d      5 }|j!                  |j"                         ddd       t        d|
        | j$                  dxx   dz  cc<   | j$                  dxx   dz  cc<   ||	||
|dS 	 t)        j*                  d       y# 1 sw Y   dxY w# t&        $ r5}t        d| d| d|        | j$                  dxx   dz  cc<   Y d}~yd}~ww xY w)z&Generate a single image using DALL-E 3zGenerating _z...z CRITICAL: Absolutely no people, no human figures, no cartoon characters, no human silhouettes, no text except single letters for grades or plain yellow caution tape, everything must be photorealistic not illustratedzdall-e-3   )modelpromptsizer   nr      r*   r   _chainr   _summaryr    r5   z.jpgwbNu   ✓ Saved: r   r   g{Gz?)r'   filename	subfolderfilepathrF   u   ✗ Failed to generate z: r      )r%   r   imagesgenerater   r   dataurlrequestsgetstatus_coder   r"   r#   r   openwritecontentr   	Exceptiontimesleep)r   rF   r'   indexenhanced_promptresponse	image_urlimg_responserN   rM   rO   fes                r   generate_imagez"StockImageGenerator.generate_image   s   6	Kz5'56 %  (B  BO{{))22 &__ 3 H !a(,,I $<<	2L''3.  ? ? !-I) (I8+ +I )I 'Zqt477<<y(K(D) 2QGGL0012 H:./

;'1,'

<(D0( !) (!* (- 1 /L 	

1+2 2  	+H:QugRsCDJJx A% 	s1   C(E5 *E)AE5 )E2.E5 5	F3>+F..F3c                     g }t        d| d       t        |d      D ],  \  }}| j                  |||      }|s|j                  |       . |S )z"Generate all images for a categoryz
=== Generating z images ===rD   )r%   	enumeratere   append)r   category_namepromptsresultsirF   results          r   generate_categoryz%StockImageGenerator.generate_category   s]    !-<="7A. 	'IAv((BFv&	'
 r   c                 z   t        d       t        d       t        d| j                          t        d| j                          | j                          g }| j	                         }|j                         D ](  \  }}| j                  ||      }|j                  |       * | j                         }|j                         D ](  \  }}| j                  ||      }|j                  |       * | j                         }|j                         D ](  \  }}| j                  ||      }|j                  |       * t        j                         j                         d| j                  |d}t        j                  j!                  | j"                  d      }	t%        |	d      5 }
t'        j(                  ||
d	
       ddd       t        d       t        d| j                  d    d       t        d| j                  d    d       t        d| j                  d   d       t        d|	        |S # 1 sw Y   xxY w)zGenerate all stock imagesz3Starting CleanKitchens stock image generation V2...z.STRICT: No people, no text except caution tapezImage size: z	Quality: v2_no_people_no_text)generated_atversionr   rQ   zgeneration_metadata_v2.jsonwrP   )indentNz
=== Generation Complete ===zGenerated: r   z imageszFailed: r   zTotal cost: $r   z.2fzMetadata saved to: )r%   r   r   r(   r7   itemsrn   extendr=   rA   r   now	isoformatr   r   r"   r#   r   rX   jsondump)r   all_resultsviolation_promptsr'   rj   rk   chain_promptssummary_promptsmetadatametadata_pathrc   s              r   generate_all_imagesz'StockImageGenerator.generate_all_images   s   CD>?T__-./	$,,() 	! !668!2!8!8!: 	(Hg,,Xw?Gw'	(
 ..0!.!4!4!6 	(Hg,,Xw?Gw'	(
 224!0!6!6!8 	(Hg,,Xw?Gw'	( %LLN446-ZZ!	
 T]]4QR-% 	-IIh!,	- 	-/DJJ{34G<=H-.g67djj6s;<=#M?34	- 	-s   !H11H:N)__name__
__module____qualname__r   r(   r7   r=   rA   re   rn   r    r   r   r   r      s.    `*0F
P
:
&;z0r   r   c                      dt         j                  d<   t               } t        d       t        d       t	        d      }|j                         dk(  r| j                          yt        d       y)	zMain executionzsk-proj-xrTd5ca5qle0l_v7Adj8aTnfs1pHmsMMch_5jezaMmuw3rIiGzAUTKu_DKW7pzxj_SgdS15PHVT3BlbkFJJbRPXZD4QtRTgBrK8mWNay93cHQQQNGHx7sExlcuX1W3ihPfKxtMy3bjfi3NUMSa5rmAY8tpMAr   zDThis will generate ~100+ images with STRICT no people/no text policyzCost: approximately $8-10zProceed? (y/n): y	CancelledN)r   environr   r%   inputlowerr   )	generatorr`   s     r   mainr   !  s\     $JBJJ #%I	
PQ	
%&'(H~~3%%'kr   __main__)__doc__r   ry   r\   rU   openair   r   r   r   r   r   r   r   <module>r      sD   
 
     Q Qf  zF r   