
    h-?                     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
Industrial, realistic style with caution tape, commercial kitchens, violations
    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_costzProfessional photography, industrial commercial kitchen setting, dramatic lighting, high contrast, cinematic quality, photorealistic, no people, no text, no logos)	r   osgetenvclientbase_dir
image_sizequalitystats
style_baseselfs    h/var/www/twin-digital-media/public_html/_sites/cleankitchens/production/scripts/generate_stock_images.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 )/z Get prompts for violation imagesztDark industrial kitchen corner with visible mouse droppings near food prep area, yellow caution tape in foreground, z\Commercial kitchen floor with rat shadows and gnawed food packaging, warning signs visible, z]Stainless steel kitchen shelving with rodent evidence, pest control boxes, dramatic shadows, zeRestaurant storage area with compromised food containers showing rodent damage, industrial lighting, z\Commercial kitchen dark corner with cockroach silhouettes on stainless steel, caution tape, z[Industrial dishwashing area with pest evidence, dramatic overhead lighting, warning signs, zZRestaurant prep station with insect traps and warning indicators, high contrast lighting, zbDark commercial kitchen crevices with pest activity indicators, professional inspection lighting, zfCommercial refrigerator with digital thermometer showing danger zone temperature, red warning lights, zdIndustrial kitchen heat lamp station with temperature violation indicators, steam and condensation, zVWalk-in cooler with frost buildup and temperature gauge in red zone, caution signage, zVStainless steel food warming station with visible temperature problems, warning tape, zaGrimy commercial kitchen surfaces with visible buildup, harsh inspection lighting, caution tape, zSDirty industrial dishwashing area with standing water, overhead dramatic lighting, zNNeglected restaurant prep area with accumulated debris, warning signs posted, zPCommercial kitchen floor drains with visible contamination, industrial setting, zaDark commercial kitchen corner with visible mold growth on walls, moisture damage, warning tape, zSIndustrial refrigerator seals with black mold, close-up detail, dramatic lighting, zTRestaurant ceiling tiles with water damage and mold stains, looking up perspective, zQWalk-in cooler with mold on surfaces, condensation visible, industrial lighting, z[Commercial cutting boards with raw and cooked foods dangerously close, warning indicators, zXIndustrial kitchen prep area with improper food storage, color-coded violation markers, zTRestaurant work station showing contamination risks, caution tape sectioning areas, zWStainless steel surfaces with mixed food preparation hazards, overhead warning lights, zXBroken commercial sink in industrial kitchen, caution tape across it, dramatic shadows, zUEmpty soap dispensers and paper towel holders in restaurant washroom, warning signs, zSBlocked handwashing station with supplies stored in sink, violation notice posted, zTIndustrial kitchen with missing handwashing supplies, inspection checklist visible, zWDamaged commercial kitchen ceiling with exposed infrastructure, caution tape barriers, zPCracked restaurant floor tiles with safety hazards marked, industrial lighting, zGBroken industrial kitchen equipment with warning tags, dramatic angle, zVRestaurant wall damage with exposed areas, temporary barriers, construction lighting, zKCommercial floor drain backup in industrial kitchen, warning cones placed, zYRestaurant basement with water damage indicators, caution tape barriers, harsh lighting, zGIndustrial kitchen with plumbing issues visible, warning signs posted, zUCommercial dishwashing area with drainage problems, standing water, warning markers, zYRestaurant entrance with official red closure notice on door, dramatic evening lighting, zQCommercial kitchen with red tags on all equipment, caution tape across entrance, zPLocked restaurant doors with health department closure signs, reflective glass, zODark restaurant interior visible through window with closure notice prominent, zXYellow caution tape across restaurant entrance with official notices, dramatic shadows, zcWide angle industrial kitchen with multiple violation indicators, caution tape, dramatic lighting, zaCommercial restaurant kitchen under inspection, warning signs visible, professional photography, z]Stainless steel commercial kitchen with health code violation markers, industrial aesthetic, zPRestaurant prep area with inspection tags and warnings, high contrast lighting, rodentroachtemperaturecleanlinessmoldcross_contaminationhandwashing
structuralsewageclosuregeneralr   r   s    r   get_violation_promptsz)StockImageGenerator.get_violation_prompts-   s0    G  HL  HW  HW  GX  Ynoso~o~n  Aoptpp  pA  Bwx|  yH  yH  xI  J	 ooso~o~n  Amnrn}n}m~lmqm|m|l}~tuy  vE  vE  uF  G	 yy}  zI  zI  yJ  Kvw{  xG  xG  wH  Ihimixixhyzhimixixhyz	 ttx  uD  uD  tE  Fefjfufuevw`aeapap`qrbcgcrcrbst	 ttx  uD  uD  tE  Fefjfufuevwfgkgvgvfwxcdhdsdsctu	 nnrn}n}m~jkokzkzj{|fgkgvgvfwxijnjyjyiz{	$ kkokzkzj{|ghlhwhwgxyefjfufuevwfgkgvgvfwx	 jjnjyjyiz{bcgcrcrbstYZ^ZiZiYjkhimixixhyz	 ^^b^m^m]noklpl{l{k|}YZ^ZiZiYjkghlhwhwgxy	 llpl{l{k|}cdhdsdsctubcgcrcrbstabfbqbqarsjkokzkzj{| vvz  wF  wF  vG  Hstx  uD  uD  tE  Foptpp  pA  Bbcgcrcrbst	}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 )z'Get prompts for chain restaurant imagesz^Generic fast food burger restaurant kitchen, industrial fryer area, stainless steel surfaces, zWCommercial burger grill station with ventilation hoods, professional kitchen lighting, zCFast food prep area with burger assembly line, industrial setting, zMChain restaurant freezer with burger supplies, commercial equipment visible, zNCommercial coffee shop equipment area, espresso machines, industrial counter, zQChain coffee store prep area with syrups and supplies, stainless steel surfaces, zOIndustrial coffee roasting equipment in commercial setting, dramatic lighting, zHCoffee chain storage area with beans and supplies, commercial shelving, zIIndustrial pizza oven in commercial kitchen, high temperature equipment, zOChain pizzeria prep station with dough and toppings, stainless steel surfaces, zFCommercial pizza kitchen with multiple ovens, industrial ventilation, zFPizza chain refrigeration units with ingredients, commercial storage, zGIndustrial deep fryer station for chicken, commercial kitchen setting, zGChain restaurant chicken prep area, breading station, stainless steel, zACommercial pressure fryer equipment, industrial chicken kitchen, z:Fast food chicken storage freezers, commercial equipment, )burger_chaincoffee_chainpizza_chainchicken_chainr6   r   s    r   get_chain_promptsz%StockImageGenerator.get_chain_promptsu   sX    qqu  rA  rA  qB  Cijnjyjyiz{UVZVeVeUfg_`d`o`o_pq	 aaeapap`qrcdhdsdsctuabfbqbqarsZ[_[j[jZkl	 \\`\k\k[lmabfbqbqarsXY]YhYhXijXY]YhYhXij	 ZZ^ZiZiYjkYZ^ZiZiYjkSTXTcTcSdeLT__L]^	'
 	
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 )zGet prompts for summary imagesz\Clipboard with inspection checklist on stainless steel surface, dramatic overhead lighting, zXHealth inspection grade cards arranged on industrial surface, professional photography, zFDigital tablet showing inspection data in commercial kitchen setting, zMStack of violation notices on industrial kitchen counter, dramatic lighting, zNInspector's toolkit and reports on stainless steel table, professional angle, zIMultiple inspection reports spread on industrial surface, overhead view, zOWeek calendar with violation markers in commercial setting, dramatic lighting, zPSeries of health grade cards showing weekly progression, industrial background, zNInspection clipboard with weekly summary charts, commercial kitchen backdrop, zIDigital display showing weekly violation statistics, industrial setting, )daily_summaryweekly_summaryr6   r   s    r   get_summary_promptsz'StockImageGenerator.get_summary_prompts   s     ooso~o~n  Ajkokzkzj{|XY]YhYhXij_`d`o`o_pq`aeapap`qr \\`\k\k[lmabfbqbqarsbcgcrcrbst`aeapap`qr[\`\k\k[lm
 	
r   c           	      b   	 t        d| d| d       | 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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response	image_urlimg_responserN   rM   rO   fes               r   generate_imagez"StockImageGenerator.generate_image   s   3	Kz5'56{{))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#E0 %E$AE0 $E-)E0 0	F.9+F))F.c                     g }t        d| d       t        |d      D ],  \  }}| j                  |||      }|s|j                  |       . |S )z"Generate all images for a categoryz
=== Generating z images ===rD   )r%   	enumeraterd   append)r   category_namepromptsresultsirF   results          r   generate_categoryz%StockImageGenerator.generate_category   s]    !-<="7A. 	'IAv((BFv&	'
 r   c                 b   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                         | 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 imagesz0Starting CleanKitchens stock image generation...zImage size: z	Quality: )generated_atr   rQ   zgeneration_metadata.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   itemsrm   extendr=   rA   r   now	isoformatr   r   r"   r#   r   rX   jsondump)r   all_resultsviolation_promptsr'   ri   rj   chain_promptssummary_promptsmetadatametadata_pathrb   s              r   generate_all_imagesz'StockImageGenerator.generate_all_images   s   @A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]]4NO-% 	-IIh!,	- 	-/DJJ{34G<=H-.g67djj6s;<=#M?34	- 	-s   H%%H.N)__name__
__module____qualname__r   r(   r7   r=   rA   rd   rm   r~    r   r   r   r      s.    *0F
P
:
&8t.r   r   c                      t        j                  d      st        d       t        d       yt               } t        d       t	        d      }|j                         dk(  r| j                          yt        d       y)	zMain executionr   z2Error: OPENAI_API_KEY environment variable not setz*Run: export OPENAI_API_KEY='your-key-here'Nz<This will generate ~100+ images and cost approximately $8-10zProceed? (y/n): y	Cancelled)r   r   r%   r   inputlowerr~   )	generatorr_   s     r   mainr     se     99%&BC:;#%I	
HI'(H~~3%%'kr   __main__)__doc__r   rv   r\   rU   openair   r   r   r   r   r   r   r   <module>r      sD   
 
     L L\$ zF r   