Malaji71 commited on
Commit
ad6905a
·
verified ·
1 Parent(s): 201936e

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +151 -108
models.py CHANGED
@@ -1,31 +1,8 @@
1
- else: # multimodal analysis
2
- return f"""Analyze this image using complete professional cinematography expertise for multi-platform prompt generation. Apply the full 30+ years cinema knowledge base. Provide exactly two sections:
3
-
4
- 1. DESCRIPTION: Complete professional visual analysis using full framework:
5
-
6
- CAMERA ANGLES - Identify and specify exact angle with professional rationale:
7
- • {camera_angles.get("eye_level_normal", {}).get("description", "Camera at subject's eye level")}: {camera_angles.get("eye_level_normal", {}).get("effect", "neutral, natural perspective")}, psychological impact: {camera_angles.get("eye_level_normal", {}).get("psychological_impact", "equality, relatability")}, best for: {camera_angles.get("eye_level_normal", {}).get("best_for", "portraits, documentary, street photography")}
8
- • {camera_angles.get("low_angle_worms_eye", {}).get("description", "Camera below subject looking up")}: {camera_angles.get("low_angle_worms_eye", {}).get("effect", "subject appears larger, more powerful")}, psychological impact: {camera_angles.get("low_angle_worms_eye", {}).get("psychological_impact", "dominance, strength, heroic")}, technical: {camera_angles.get("low_angle_worms_eye", {}).get("technical", "watch for distortion with wide lenses")}, best for: {camera_angles.get("low_angle_worms_eye", {}).get("best_for", "architecture, powerful portraits, dramatic scenes")}
9
- • {camera_angles.get("high_angle_birds_eye", {}).get("description", "Camera above subject looking down")}: {camera_angles.get("high_angle_birds_eye", {}).get("effect", "subject appears smaller, vulnerable")}, psychological impact: {camera_angles.get("high_angle_birds_eye", {}).get("psychological_impact", "submission, overview, context")}, aerial version: {camera_angles.get("high_angle_birds_eye", {}).get("aerial_version", "complete overhead view")}, best for: {camera_angles.get("high_angle_birds_eye", {}).get("best_for", "environmental context, patterns, vulnerability")}
10
- • {camera_angles.get("dutch_angle", {}).get("description", "Camera tilted off horizontal")}: {camera_angles.get("dutch_angle", {}).get("effect", "dynamic tension, unease")}, psychological impact: {camera_angles.get("dutch_angle", {}).get("psychological_impact", "instability, energy, confusion")}, usage: {camera_angles.get("dutch_angle", {}).get("use_sparingly", "can become gimmicky if overused")}, best for: {camera_angles.get("dutch_angle", {}).get("best_for", "creative portraits, dynamic scenes")}
11
-
12
- PHOTOGRAPHIC PLANES - Apply exact framing classification:
13
- • {photographic_planes.get("extreme_wide_shot", {}).get("framing", "Subject very small in environment")}: {photographic_planes.get("extreme_wide_shot", {}).get("purpose", "establish location and context")}, best for: {photographic_planes.get("extreme_wide_shot", {}).get("best_for", "landscapes, establishing shots")}, composition focus: {photographic_planes.get("extreme_wide_shot", {}).get("composition_focus", "environment tells the story")}
14
- • {photographic_planes.get("wide_shot", {}).get("framing", "Full body visible with environment")}: {photographic_planes.get("wide_shot", {}).get("purpose", "show subject in context")}, best for: {photographic_planes.get("wide_shot", {}).get("best_for", "environmental portraits, action")}, composition balance: {photographic_planes.get("wide_shot", {}).get("composition_balance", "subject and environment both important")}
15
- • {photographic_planes.get("medium_shot", {}).get("framing", "From waist up approximately")}: {photographic_planes.get("medium_shot", {}).get("purpose", "balance between subject and environment")}, best for: {photographic_planes.get("medium_shot", {}).get("best_for", "conversation, interaction, casual portraits")}, composition focus: {photographic_planes.get("medium_shot", {}).get("composition_focus", "subject is primary, environment secondary")}
16
- • {photographic_planes.get("close_up", {}).get("framing", "Head and shoulders, tight on face")}: {photographic_planes.get("close_up", {}).get("purpose", "show emotion and expression clearly")}, best for: {photographic_planes.get("close_up", {}).get("best_for", "emotional portraits, interviews")}, technical focus: {photographic_planes.get("close_up", {}).get("technical_focus", "eyes must be perfectly sharp")}
17
- • {photographic_planes.get("extreme_close_up", {}).get("framing", "Part of face or specific detail")}: {photographic_planes.get("extreme_close_up", {}).get("purpose", "intense emotion or specific detail")}, best for: {photographic_planes.get("extreme_close_up", {}).get("best_for", "artistic portraits, product details")}, technical challenge: {photographic_planes.get("extreme_close_up", {}).get("technical_challenge", "depth of field very shallow")}
18
- • {photographic_planes.get("detail_shot", {}).get("framing", "Specific small element")}: {photographic_planes.get("detail_shot", {}).get("purpose", "highlight particular aspect")}, best for: {photographic_planes.get("detail_shot", {}).get("best_for", "hands, jewelry, textures, products")}, technical requirements: {photographic_planes.get("detail_shot", {}).get("technical_requirements", "macro capabilities often needed")}
19
-
20
- LIGHTING PRINCIPLES - Complete lighting analysis:
21
- Natural Light Types:
22
- • {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("timing", "First hour after sunrise, last hour before sunset")}: {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("characteristics", "warm, soft, directional")}, best for: {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("best_for", "portraits, landscapes, architecture")}, camera settings: {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("camera_settings", "lower ISO, wider aperture possible")}
23
- • {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("timing", "20-30 minutes after sunset")}: {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("characteristics", "even blue light, dramatic mood")}, best for: {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("best_for", "cityscapes, architecture with lights")}, camera settings: {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("camera_settings", "tripod required, longer exposures")}
24
- • {lighting_principles.get("natural_light_types", {}).get("overcast", {}).get("characteristics", "soft, even, diffused light")}: best"""
25
  Model management for Phramer AI
26
  By Pariente AI, for MIA TV Series
27
 
28
- else: # multimodal analysis - BAGEL 7B integration with professional photography knowledge enhancement
29
  """
30
 
31
  import spaces
@@ -122,117 +99,114 @@ class BagelAPIAnalyzer(BaseImageAnalyzer):
122
  logger.warning("Professional photography knowledge not available")
123
  return self._create_fallback_prompt(analysis_type)
124
 
125
- # Extract complete knowledge sections
126
- scene_types = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("scene_types", {})
127
- lighting_principles = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("lighting_principles", {})
128
- composition_rules = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("composition_rules", {})
129
- camera_angles = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("camera_angles", {})
130
- photographic_planes = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("photographic_planes", {})
131
- focus_techniques = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("focus_techniques", {})
132
- camera_modes = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("camera_modes", {})
133
- iso_guidelines = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("iso_guidelines", {})
134
- lighting_situations = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("lighting_situations", {})
135
- movement_techniques = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("movement_techniques", {})
136
- specialized_techniques = EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("specialized_techniques", {})
 
 
137
 
 
138
  if analysis_type == "cinematic":
139
- return f"""Analyze this image as a master cinematographer with 30+ years of cinema experience. Apply complete professional photography knowledge. Provide exactly two sections:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  1. DESCRIPTION: Create a concise, technical analysis for cinematic reproduction using these professional frameworks:
142
 
143
  CAMERA ANGLES - Identify and apply:
144
- • {camera_angles.get("eye_level_normal", {}).get("description", "Eye level normal")}: {camera_angles.get("eye_level_normal", {}).get("effect", "neutral perspective")}, {camera_angles.get("eye_level_normal", {}).get("psychological_impact", "relatability")}, best for: {camera_angles.get("eye_level_normal", {}).get("best_for", "portraits, documentary")}
145
- • {camera_angles.get("low_angle_worms_eye", {}).get("description", "Low angle worms eye")}: {camera_angles.get("low_angle_worms_eye", {}).get("effect", "subject appears larger")}, {camera_angles.get("low_angle_worms_eye", {}).get("psychological_impact", "dominance, strength")}, best for: {camera_angles.get("low_angle_worms_eye", {}).get("best_for", "architecture, powerful portraits")}
146
- • {camera_angles.get("high_angle_birds_eye", {}).get("description", "High angle birds eye")}: {camera_angles.get("high_angle_birds_eye", {}).get("effect", "subject appears smaller")}, {camera_angles.get("high_angle_birds_eye", {}).get("psychological_impact", "submission, overview")}, best for: {camera_angles.get("high_angle_birds_eye", {}).get("best_for", "environmental context, patterns")}
147
- • {camera_angles.get("dutch_angle", {}).get("description", "Dutch angle")}: {camera_angles.get("dutch_angle", {}).get("effect", "dynamic tension")}, {camera_angles.get("dutch_angle", {}).get("psychological_impact", "instability, energy")}, best for: {camera_angles.get("dutch_angle", {}).get("best_for", "creative portraits, dynamic scenes")}
148
 
149
  PHOTOGRAPHIC PLANES - Apply appropriate framing:
150
- • {photographic_planes.get("extreme_wide_shot", {}).get("framing", "Subject very small in environment")}: {photographic_planes.get("extreme_wide_shot", {}).get("purpose", "establish location and context")}
151
- • {photographic_planes.get("wide_shot", {}).get("framing", "Full body visible with environment")}: {photographic_planes.get("wide_shot", {}).get("purpose", "show subject in context")}
152
- • {photographic_planes.get("medium_shot", {}).get("framing", "From waist up approximately")}: {photographic_planes.get("medium_shot", {}).get("purpose", "balance between subject and environment")}
153
- • {photographic_planes.get("close_up", {}).get("framing", "Head and shoulders, tight on face")}: {photographic_planes.get("close_up", {}).get("purpose", "show emotion and expression clearly")}
154
- • {photographic_planes.get("extreme_close_up", {}).get("framing", "Part of face or specific detail")}: {photographic_planes.get("extreme_close_up", {}).get("purpose", "intense emotion or specific detail")}
155
 
156
  COMPOSITION RULES - Apply these techniques:
157
- • {composition_rules.get("rule_of_thirds", {}).get("principle", "Divide frame into 9 equal sections")}: {composition_rules.get("rule_of_thirds", {}).get("application", "place key elements on intersection points")}
158
- • {composition_rules.get("leading_lines", {}).get("purpose", "Guide viewer's eye through the image")}: sources include {', '.join(composition_rules.get("leading_lines", {}).get("sources", ["roads", "rivers", "architecture"]))}
159
- • {composition_rules.get("vanishing_points", {}).get("single_point", "All lines converge to one point")}: {composition_rules.get("vanishing_points", {}).get("application", "create depth and draw attention")}
160
- • {composition_rules.get("depth_layers", {}).get("foreground", "Nearest elements to camera")}, {composition_rules.get("depth_layers", {}).get("middle_ground", "Main subject area")}, {composition_rules.get("depth_layers", {}).get("background", "Context and environment")}
161
 
162
  LIGHTING ANALYSIS - Identify lighting type and quality:
163
  Natural Light Types:
164
- • {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("timing", "First hour after sunrise, last hour before sunset")}: {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("characteristics", "warm, soft, directional")}
165
- • {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("timing", "20-30 minutes after sunset")}: {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("characteristics", "even blue light, dramatic mood")}
166
- • {lighting_principles.get("natural_light_types", {}).get("overcast", {}).get("characteristics", "soft, even, diffused light")}: advantage - {lighting_principles.get("natural_light_types", {}).get("overcast", {}).get("advantage", "no harsh shadows")}
167
-
168
- Artificial Light Setups:
169
- • {lighting_principles.get("artificial_light_setups", {}).get("three_point_lighting", {}).get("key_light", "Primary light source at 45 degrees")}: {lighting_principles.get("artificial_light_setups", {}).get("three_point_lighting", {}).get("fill_light", "Softer light to reduce shadows")}: {lighting_principles.get("artificial_light_setups", {}).get("three_point_lighting", {}).get("rim_light", "Separation from background")}
170
 
171
  2. CAMERA_SETUP: Recommend specific professional equipment based on scene analysis using these configurations:
172
 
173
  SCENE TYPES - Match scene to appropriate setup:
174
- Portrait Studio: {scene_types.get("portrait_studio", {}).get("equipment", {}).get("camera", "Canon EOS R5")}, {scene_types.get("portrait_studio", {}).get("equipment", {}).get("lens", "85mm f/1.4")}, settings: {scene_types.get("portrait_studio", {}).get("camera_settings", {}).get("mode", "AV/A")}, {scene_types.get("portrait_studio", {}).get("camera_settings", {}).get("aperture", "f/2.8")}, {scene_types.get("portrait_studio", {}).get("camera_settings", {}).get("iso", "100-400")}
175
-
176
- Street Photography: {scene_types.get("street_photography", {}).get("equipment", {}).get("camera", "Leica M11")}, {scene_types.get("street_photography", {}).get("equipment", {}).get("lens", "35mm f/1.4")}, settings: {scene_types.get("street_photography", {}).get("camera_settings", {}).get("mode", "TV/S or Program")}, {scene_types.get("street_photography", {}).get("camera_settings", {}).get("aperture", "f/5.6-f/8")}, {scene_types.get("street_photography", {}).get("camera_settings", {}).get("iso", "400-1600")}
177
 
178
- Landscape: {scene_types.get("landscape", {}).get("equipment", {}).get("camera", "Phase One XT")}, {scene_types.get("landscape", {}).get("equipment", {}).get("lens", "24-70mm f/4")}, settings: {scene_types.get("landscape", {}).get("camera_settings", {}).get("mode", "AV/A or Manual")}, {scene_types.get("landscape", {}).get("camera_settings", {}).get("aperture", "f/8-f/11")}, {scene_types.get("landscape", {}).get("camera_settings", {}).get("iso", "100-400")}
179
 
180
- Architecture: {scene_types.get("architecture", {}).get("equipment", {}).get("camera", "Canon EOS R5")}, {scene_types.get("architecture", {}).get("equipment", {}).get("lens", "24-70mm f/2.8")}, settings: {scene_types.get("architecture", {}).get("camera_settings", {}).get("mode", "AV/A")}, {scene_types.get("architecture", {}).get("camera_settings", {}).get("aperture", "f/8-f/11")}, {scene_types.get("architecture", {}).get("camera_settings", {}).get("iso", "100-400")}
181
 
182
- Action Sports: {scene_types.get("action_sports", {}).get("equipment", {}).get("camera", "Sony A1")}, {scene_types.get("action_sports", {}).get("equipment", {}).get("lens", "70-200mm f/2.8")}, settings: {scene_types.get("action_sports", {}).get("camera_settings", {}).get("mode", "TV/S")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("aperture", "f/2.8-f/4")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("iso", "800-3200")}
183
 
184
- ISO GUIDELINES - Apply appropriate sensitivity:
185
- • {iso_guidelines.get("base_iso", {}).get("range", "100-200")}: {iso_guidelines.get("base_iso", {}).get("quality", "maximum image quality, lowest noise")}, lighting needed: {iso_guidelines.get("base_iso", {}).get("lighting_needed", "bright daylight, studio lighting")}
186
- • {iso_guidelines.get("low_iso", {}).get("range", "400-800")}: {iso_guidelines.get("low_iso", {}).get("quality", "excellent quality, minimal noise")}, lighting needed: {iso_guidelines.get("low_iso", {}).get("lighting_needed", "good available light")}
187
- • {iso_guidelines.get("medium_iso", {}).get("range", "1600-3200")}: {iso_guidelines.get("medium_iso", {}).get("quality", "good quality, manageable noise")}, lighting needed: {iso_guidelines.get("medium_iso", {}).get("lighting_needed", "indoor available light, overcast outdoor")}
188
- • {iso_guidelines.get("high_iso", {}).get("range", "6400-12800")}: {iso_guidelines.get("high_iso", {}).get("quality", "acceptable quality, visible noise")}, lighting needed: {iso_guidelines.get("high_iso", {}).get("lighting_needed", "low light situations")}
189
-
190
- FOCUS TECHNIQUES - Apply depth of field control:
191
- • {focus_techniques.get("shallow_depth_of_field", {}).get("aperture_range", "f/1.4 - f/2.8")}: {focus_techniques.get("shallow_depth_of_field", {}).get("effect", "subject sharp, background blurred")}, best for: {focus_techniques.get("shallow_depth_of_field", {}).get("best_for", "portraits, product photography, subject isolation")}
192
- • {focus_techniques.get("deep_depth_of_field", {}).get("aperture_range", "f/8 - f/16")}: {focus_techniques.get("deep_depth_of_field", {}).get("effect", "everything sharp from front to back")}, best for: {focus_techniques.get("deep_depth_of_field", {}).get("best_for", "landscapes, architecture, group photos")}
193
 
194
  Apply complete professional cinematography knowledge to generate concise, technically accurate prompt for cinema-quality generation."""
 
 
195
 
196
- 1. DESCRIPTION: Create a detailed, flowing paragraph describing the image for cinematic reproduction:
197
- - Scene composition and visual storytelling elements
198
- - Lighting quality, direction, and dramatic mood
199
- - Color palette, tonal relationships, and atmospheric elements
200
- - Subject positioning, environmental context, and framing
201
- - Cinematic qualities: film grain, depth of field, visual style
202
- - Technical photographic elements that enhance realism
203
-
204
- 2. CAMERA_SETUP: Recommend professional cinema/photography equipment based on scene analysis:
205
- - Camera body: Choose from Canon EOS R5/R6, Sony A7R/A1, Leica M11, ARRI Alexa, RED cameras
206
- - Lens: Specific focal length and aperture (e.g., "85mm f/1.4", "35mm anamorphic f/2.8")
207
- - Technical settings: Aperture consideration for depth of field and story mood
208
- - Lighting setup: Professional lighting rationale (key, fill, rim, practical lights)
209
- - Shooting style: Documentary, portrait, landscape, architectural, or cinematic approach
210
-
211
- Apply professional cinematography principles: rule of thirds, leading lines, depth layering, lighting direction for mood, and technical excellence. Focus on creating prompts optimized for photorealistic, cinema-quality generation."""
212
-
213
- elif analysis_type == "flux_optimized":
214
- return """Analyze this image for FLUX prompt generation with professional cinematography expertise. You have 30+ years of cinema experience. Provide exactly two sections:
215
-
216
- elif analysis_type == "flux_optimized":
217
- return f"""Analyze this image for FLUX prompt generation using complete professional photography expertise. Apply the full knowledge base for photorealistic output. Provide exactly two sections:
218
 
219
  1. DESCRIPTION: Professional technical analysis using complete photography framework:
220
 
221
  CAMERA ANGLES - Identify specific angle and apply professional knowledge:
222
- • {camera_angles.get("eye_level_normal", {}).get("description", "Eye level normal")}: {camera_angles.get("eye_level_normal", {}).get("effect", "neutral perspective")}, {camera_angles.get("eye_level_normal", {}).get("best_for", "portraits, documentary")}
223
- • {camera_angles.get("low_angle_worms_eye", {}).get("description", "Low angle worms eye")}: {camera_angles.get("low_angle_worms_eye", {}).get("effect", "subject appears larger")}, {camera_angles.get("low_angle_worms_eye", {}).get("best_for", "architecture, powerful portraits")}
224
- • {camera_angles.get("high_angle_birds_eye", {}).get("description", "High angle birds eye")}: {camera_angles.get("high_angle_birds_eye", {}).get("effect", "subject appears smaller")}, {camera_angles.get("high_angle_birds_eye", {}).get("best_for", "environmental context, patterns")}
225
 
226
  LIGHTING SITUATIONS - Match to appropriate lighting condition:
227
- • {lighting_situations.get("bright_daylight", {}).get("iso", "100-200")}: challenge - {lighting_situations.get("bright_daylight", {}).get("challenge", "harsh shadows")}, solutions: {', '.join(lighting_situations.get("bright_daylight", {}).get("solutions", ["use reflectors", "find open shade"]))}
228
- • {lighting_situations.get("overcast_day", {}).get("iso", "200-400")}: {lighting_situations.get("overcast_day", {}).get("characteristics", "soft, even light but dimmer")}, advantage: {lighting_situations.get("overcast_day", {}).get("advantage", "natural diffusion")}
229
- • {lighting_situations.get("indoor_natural_light", {}).get("iso", "800-1600")}: {lighting_situations.get("indoor_natural_light", {}).get("window_light", "excellent for portraits")}, technique: {lighting_situations.get("indoor_natural_light", {}).get("technique", "position subject relative to window")}
230
- • {lighting_situations.get("low_light_available", {}).get("iso", "1600-6400")}: {lighting_situations.get("low_light_available", {}).get("stabilization", "essential for sharp images")}, technique: {lighting_situations.get("low_light_available", {}).get("technique", "wider apertures, slower movements")}
231
 
232
  COMPOSITION APPLICATION - Apply these specific rules:
233
- • {composition_rules.get("rule_of_thirds", {}).get("principle", "Divide frame into 9 equal sections")}: {composition_rules.get("rule_of_thirds", {}).get("subject_placement", "eyes on upper third line for portraits")}, {composition_rules.get("rule_of_thirds", {}).get("horizon_placement", "upper or lower third for landscapes")}
234
- • {composition_rules.get("leading_lines", {}).get("purpose", "Guide viewer's eye through the image")}: types include {', '.join(composition_rules.get("leading_lines", {}).get("types", ["diagonal lines", "curved lines"]))}, technique: {composition_rules.get("leading_lines", {}).get("technique", "use lines to lead to main subject")}
235
- • {composition_rules.get("depth_layers", {}).get("technique", "Create separation between layers")}: {composition_rules.get("depth_layers", {}).get("foreground", "Nearest elements")}, {composition_rules.get("depth_layers", {}).get("middle_ground", "Main subject area")}, {composition_rules.get("depth_layers", {}).get("background", "Context and environment")}
236
 
237
  2. CAMERA_SETUP: Apply complete professional equipment knowledge:
238
 
@@ -250,14 +224,83 @@ Architecture: Equipment: {scene_types.get("architecture", {}).get("equipment", {
250
  Action Sports: Equipment: {scene_types.get("action_sports", {}).get("equipment", {}).get("camera", "Sony A1")}, {scene_types.get("action_sports", {}).get("equipment", {}).get("lens", "70-200mm f/2.8")}, Camera settings: {scene_types.get("action_sports", {}).get("camera_settings", {}).get("mode", "TV/S")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("shutter_speed", "1/500s+ to freeze motion")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("aperture", "f/2.8-f/4")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("iso", "800-3200")}
251
 
252
  CAMERA MODES - Apply appropriate control:
253
- • {camera_modes.get("aperture_priority", {}).get("mode_designation", "AV (Canon) / A (Nikon)")}: photographer sets {camera_modes.get("aperture_priority", {}).get("photographer_sets", "aperture value")}, camera sets {camera_modes.get("aperture_priority", {}).get("camera_sets", "shutter speed")}, best for: {camera_modes.get("aperture_priority", {}).get("best_for", "controlling depth of field")}
254
- • {camera_modes.get("shutter_priority", {}).get("mode_designation", "TV (Canon) / S (Nikon)")}: photographer sets {camera_modes.get("shutter_priority", {}).get("photographer_sets", "shutter speed")}, camera sets {camera_modes.get("shutter_priority", {}).get("camera_sets", "aperture")}, best for: {camera_modes.get("shutter_priority", {}).get("best_for", "controlling motion")}
255
- • {camera_modes.get("manual_mode", {}).get("photographer_sets", "Both aperture and shutter speed")}: when to use: {', '.join(camera_modes.get("manual_mode", {}).get("when_to_use", ["consistent lighting", "studio work"]))}, advantage: {camera_modes.get("manual_mode", {}).get("advantage", "complete creative control")}
256
 
257
  Generate technically precise content optimized for FLUX's photorealistic capabilities using complete professional knowledge."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  else: # multimodal analysis
260
- return """Analyze this image with professional cinematography expertise for multi-platform prompt generation. You are a master cinematographer with extensive technical and artistic knowledge from 30+ years in cinema. Provide exactly two sections:
261
 
262
  1. DESCRIPTION: Expert visual analysis for prompt generation:
263
  - Comprehensive scene description with photographic insight
 
1
+ """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  Model management for Phramer AI
3
  By Pariente AI, for MIA TV Series
4
 
5
+ BAGEL 7B integration with professional photography knowledge enhancement
6
  """
7
 
8
  import spaces
 
99
  logger.warning("Professional photography knowledge not available")
100
  return self._create_fallback_prompt(analysis_type)
101
 
102
+ # Extract complete knowledge sections safely
103
+ knowledge_sections = {
104
+ 'scene_types': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("scene_types", {}),
105
+ 'lighting_principles': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("lighting_principles", {}),
106
+ 'composition_rules': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("composition_rules", {}),
107
+ 'camera_angles': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("camera_angles", {}),
108
+ 'photographic_planes': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("photographic_planes", {}),
109
+ 'focus_techniques': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("focus_techniques", {}),
110
+ 'camera_modes': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("camera_modes", {}),
111
+ 'iso_guidelines': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("iso_guidelines", {}),
112
+ 'lighting_situations': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("lighting_situations", {}),
113
+ 'movement_techniques': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("movement_techniques", {}),
114
+ 'specialized_techniques': EXPERT_PHOTOGRAPHY_KNOWLEDGE.get("specialized_techniques", {})
115
+ }
116
 
117
+ # Build prompt based on analysis type
118
  if analysis_type == "cinematic":
119
+ return self._build_cinematic_prompt(knowledge_sections)
120
+ elif analysis_type == "flux_optimized":
121
+ return self._build_flux_prompt(knowledge_sections)
122
+ else:
123
+ return self._build_multimodal_prompt(knowledge_sections)
124
+
125
+ def _build_cinematic_prompt(self, knowledge: Dict[str, Any]) -> str:
126
+ """Build cinematic analysis prompt with complete professional knowledge"""
127
+
128
+ camera_angles = knowledge.get('camera_angles', {})
129
+ photographic_planes = knowledge.get('photographic_planes', {})
130
+ lighting_principles = knowledge.get('lighting_principles', {})
131
+ composition_rules = knowledge.get('composition_rules', {})
132
+ scene_types = knowledge.get('scene_types', {})
133
+ iso_guidelines = knowledge.get('iso_guidelines', {})
134
+ focus_techniques = knowledge.get('focus_techniques', {})
135
+ camera_modes = knowledge.get('camera_modes', {})
136
+
137
+ prompt = f"""Analyze this image as a master cinematographer with 30+ years of cinema experience. Apply complete professional photography knowledge. Provide exactly two sections:
138
 
139
  1. DESCRIPTION: Create a concise, technical analysis for cinematic reproduction using these professional frameworks:
140
 
141
  CAMERA ANGLES - Identify and apply:
142
+ Eye Level Normal: {camera_angles.get("eye_level_normal", {}).get("description", "Camera at subject's eye level")} - {camera_angles.get("eye_level_normal", {}).get("effect", "neutral perspective")}, best for: {camera_angles.get("eye_level_normal", {}).get("best_for", "portraits, documentary")}
143
+ Low Angle: {camera_angles.get("low_angle_worms_eye", {}).get("description", "Camera below subject looking up")} - {camera_angles.get("low_angle_worms_eye", {}).get("effect", "subject appears larger")}, psychological impact: {camera_angles.get("low_angle_worms_eye", {}).get("psychological_impact", "dominance, strength")}
144
+ High Angle: {camera_angles.get("high_angle_birds_eye", {}).get("description", "Camera above subject looking down")} - {camera_angles.get("high_angle_birds_eye", {}).get("effect", "subject appears smaller")}, best for: {camera_angles.get("high_angle_birds_eye", {}).get("best_for", "environmental context")}
145
+ Dutch Angle: {camera_angles.get("dutch_angle", {}).get("description", "Camera tilted off horizontal")} - {camera_angles.get("dutch_angle", {}).get("effect", "dynamic tension")}, creates: {camera_angles.get("dutch_angle", {}).get("psychological_impact", "instability, energy")}
146
 
147
  PHOTOGRAPHIC PLANES - Apply appropriate framing:
148
+ Extreme Wide: {photographic_planes.get("extreme_wide_shot", {}).get("framing", "Subject very small in environment")} - {photographic_planes.get("extreme_wide_shot", {}).get("purpose", "establish location and context")}
149
+ Wide Shot: {photographic_planes.get("wide_shot", {}).get("framing", "Full body visible with environment")} - {photographic_planes.get("wide_shot", {}).get("purpose", "show subject in context")}
150
+ Medium Shot: {photographic_planes.get("medium_shot", {}).get("framing", "From waist up approximately")} - {photographic_planes.get("medium_shot", {}).get("purpose", "balance between subject and environment")}
151
+ Close-up: {photographic_planes.get("close_up", {}).get("framing", "Head and shoulders, tight on face")} - {photographic_planes.get("close_up", {}).get("purpose", "show emotion and expression clearly")}
152
+ Extreme Close-up: {photographic_planes.get("extreme_close_up", {}).get("framing", "Part of face or specific detail")} - {photographic_planes.get("extreme_close_up", {}).get("purpose", "intense emotion or specific detail")}
153
 
154
  COMPOSITION RULES - Apply these techniques:
155
+ Rule of Thirds: {composition_rules.get("rule_of_thirds", {}).get("principle", "Divide frame into 9 equal sections")} - {composition_rules.get("rule_of_thirds", {}).get("application", "place key elements on intersection points")}
156
+ Leading Lines: {composition_rules.get("leading_lines", {}).get("purpose", "Guide viewer's eye through the image")} - technique: {composition_rules.get("leading_lines", {}).get("technique", "use lines to lead to main subject")}
157
+ Depth Layers: {composition_rules.get("depth_layers", {}).get("foreground", "Nearest elements")}, {composition_rules.get("depth_layers", {}).get("middle_ground", "Main subject area")}, {composition_rules.get("depth_layers", {}).get("background", "Context and environment")}
 
158
 
159
  LIGHTING ANALYSIS - Identify lighting type and quality:
160
  Natural Light Types:
161
+ Golden Hour: {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("timing", "First hour after sunrise, last hour before sunset")} - {lighting_principles.get("natural_light_types", {}).get("golden_hour", {}).get("characteristics", "warm, soft, directional")}
162
+ Blue Hour: {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("timing", "20-30 minutes after sunset")} - {lighting_principles.get("natural_light_types", {}).get("blue_hour", {}).get("characteristics", "even blue light, dramatic mood")}
163
+ Overcast: {lighting_principles.get("natural_light_types", {}).get("overcast", {}).get("characteristics", "soft, even, diffused light")} - advantage: {lighting_principles.get("natural_light_types", {}).get("overcast", {}).get("advantage", "no harsh shadows")}
 
 
 
164
 
165
  2. CAMERA_SETUP: Recommend specific professional equipment based on scene analysis using these configurations:
166
 
167
  SCENE TYPES - Match scene to appropriate setup:
168
+ Portrait Studio: Equipment: {scene_types.get("portrait_studio", {}).get("equipment", {}).get("camera", "Canon EOS R5")}, {scene_types.get("portrait_studio", {}).get("equipment", {}).get("lens", "85mm f/1.4")}, Settings: {scene_types.get("portrait_studio", {}).get("camera_settings", {}).get("mode", "AV/A")}, {scene_types.get("portrait_studio", {}).get("camera_settings", {}).get("aperture", "f/2.8")}, {scene_types.get("portrait_studio", {}).get("camera_settings", {}).get("iso", "100-400")}
 
 
169
 
170
+ Street Photography: Equipment: {scene_types.get("street_photography", {}).get("equipment", {}).get("camera", "Leica M11")}, {scene_types.get("street_photography", {}).get("equipment", {}).get("lens", "35mm f/1.4")}, Settings: {scene_types.get("street_photography", {}).get("camera_settings", {}).get("mode", "TV/S or Program")}, {scene_types.get("street_photography", {}).get("camera_settings", {}).get("aperture", "f/5.6-f/8")}, {scene_types.get("street_photography", {}).get("camera_settings", {}).get("iso", "400-1600")}
171
 
172
+ Landscape: Equipment: {scene_types.get("landscape", {}).get("equipment", {}).get("camera", "Phase One XT")}, {scene_types.get("landscape", {}).get("equipment", {}).get("lens", "24-70mm f/4")}, Settings: {scene_types.get("landscape", {}).get("camera_settings", {}).get("mode", "AV/A or Manual")}, {scene_types.get("landscape", {}).get("camera_settings", {}).get("aperture", "f/8-f/11")}, {scene_types.get("landscape", {}).get("camera_settings", {}).get("iso", "100-400")}
173
 
174
+ Architecture: Equipment: {scene_types.get("architecture", {}).get("equipment", {}).get("camera", "Canon EOS R5")}, {scene_types.get("architecture", {}).get("equipment", {}).get("lens", "24-70mm f/2.8")}, Settings: {scene_types.get("architecture", {}).get("camera_settings", {}).get("mode", "AV/A")}, {scene_types.get("architecture", {}).get("camera_settings", {}).get("aperture", "f/8-f/11")}, {scene_types.get("architecture", {}).get("camera_settings", {}).get("iso", "100-400")}
175
 
176
+ Action Sports: Equipment: {scene_types.get("action_sports", {}).get("equipment", {}).get("camera", "Sony A1")}, {scene_types.get("action_sports", {}).get("equipment", {}).get("lens", "70-200mm f/2.8")}, Settings: {scene_types.get("action_sports", {}).get("camera_settings", {}).get("mode", "TV/S")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("aperture", "f/2.8-f/4")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("iso", "800-3200")}
 
 
 
 
 
 
 
 
177
 
178
  Apply complete professional cinematography knowledge to generate concise, technically accurate prompt for cinema-quality generation."""
179
+
180
+ return prompt
181
 
182
+ def _build_flux_prompt(self, knowledge: Dict[str, Any]) -> str:
183
+ """Build FLUX-optimized prompt with complete professional knowledge"""
184
+
185
+ camera_angles = knowledge.get('camera_angles', {})
186
+ lighting_situations = knowledge.get('lighting_situations', {})
187
+ composition_rules = knowledge.get('composition_rules', {})
188
+ scene_types = knowledge.get('scene_types', {})
189
+ camera_modes = knowledge.get('camera_modes', {})
190
+
191
+ prompt = f"""Analyze this image for FLUX prompt generation using complete professional photography expertise. Apply the full knowledge base for photorealistic output. Provide exactly two sections:
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
  1. DESCRIPTION: Professional technical analysis using complete photography framework:
194
 
195
  CAMERA ANGLES - Identify specific angle and apply professional knowledge:
196
+ Eye Level: {camera_angles.get("eye_level_normal", {}).get("description", "Eye level normal")} - {camera_angles.get("eye_level_normal", {}).get("effect", "neutral perspective")}, best for: {camera_angles.get("eye_level_normal", {}).get("best_for", "portraits, documentary")}
197
+ Low Angle: {camera_angles.get("low_angle_worms_eye", {}).get("description", "Low angle worms eye")} - {camera_angles.get("low_angle_worms_eye", {}).get("effect", "subject appears larger")}, best for: {camera_angles.get("low_angle_worms_eye", {}).get("best_for", "architecture, powerful portraits")}
198
+ High Angle: {camera_angles.get("high_angle_birds_eye", {}).get("description", "High angle birds eye")} - {camera_angles.get("high_angle_birds_eye", {}).get("effect", "subject appears smaller")}, best for: {camera_angles.get("high_angle_birds_eye", {}).get("best_for", "environmental context, patterns")}
199
 
200
  LIGHTING SITUATIONS - Match to appropriate lighting condition:
201
+ Bright Daylight: ISO {lighting_situations.get("bright_daylight", {}).get("iso", "100-200")} - challenge: {lighting_situations.get("bright_daylight", {}).get("challenge", "harsh shadows")}, solutions: use reflectors, find open shade
202
+ Overcast Day: ISO {lighting_situations.get("overcast_day", {}).get("iso", "200-400")} - {lighting_situations.get("overcast_day", {}).get("characteristics", "soft, even light but dimmer")}, advantage: {lighting_situations.get("overcast_day", {}).get("advantage", "natural diffusion")}
203
+ Indoor Natural: ISO {lighting_situations.get("indoor_natural_light", {}).get("iso", "800-1600")} - {lighting_situations.get("indoor_natural_light", {}).get("window_light", "excellent for portraits")}, technique: {lighting_situations.get("indoor_natural_light", {}).get("technique", "position subject relative to window")}
204
+ Low Light: ISO {lighting_situations.get("low_light_available", {}).get("iso", "1600-6400")} - {lighting_situations.get("low_light_available", {}).get("stabilization", "essential for sharp images")}, technique: {lighting_situations.get("low_light_available", {}).get("technique", "wider apertures, slower movements")}
205
 
206
  COMPOSITION APPLICATION - Apply these specific rules:
207
+ Rule of Thirds: {composition_rules.get("rule_of_thirds", {}).get("principle", "Divide frame into 9 equal sections")} - {composition_rules.get("rule_of_thirds", {}).get("subject_placement", "eyes on upper third line for portraits")}, {composition_rules.get("rule_of_thirds", {}).get("horizon_placement", "upper or lower third for landscapes")}
208
+ Leading Lines: {composition_rules.get("leading_lines", {}).get("purpose", "Guide viewer's eye through the image")} - technique: {composition_rules.get("leading_lines", {}).get("technique", "use lines to lead to main subject")}
209
+ Depth Layers: {composition_rules.get("depth_layers", {}).get("technique", "Create separation between layers")} - {composition_rules.get("depth_layers", {}).get("foreground", "Nearest elements")}, {composition_rules.get("depth_layers", {}).get("middle_ground", "Main subject area")}, {composition_rules.get("depth_layers", {}).get("background", "Context and environment")}
210
 
211
  2. CAMERA_SETUP: Apply complete professional equipment knowledge:
212
 
 
224
  Action Sports: Equipment: {scene_types.get("action_sports", {}).get("equipment", {}).get("camera", "Sony A1")}, {scene_types.get("action_sports", {}).get("equipment", {}).get("lens", "70-200mm f/2.8")}, Camera settings: {scene_types.get("action_sports", {}).get("camera_settings", {}).get("mode", "TV/S")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("shutter_speed", "1/500s+ to freeze motion")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("aperture", "f/2.8-f/4")}, {scene_types.get("action_sports", {}).get("camera_settings", {}).get("iso", "800-3200")}
225
 
226
  CAMERA MODES - Apply appropriate control:
227
+ Aperture Priority: {camera_modes.get("aperture_priority", {}).get("mode_designation", "AV (Canon) / A (Nikon)")} - photographer sets {camera_modes.get("aperture_priority", {}).get("photographer_sets", "aperture value")}, camera sets {camera_modes.get("aperture_priority", {}).get("camera_sets", "shutter speed")}, best for: {camera_modes.get("aperture_priority", {}).get("best_for", "controlling depth of field")}
228
+ Shutter Priority: {camera_modes.get("shutter_priority", {}).get("mode_designation", "TV (Canon) / S (Nikon)")} - photographer sets {camera_modes.get("shutter_priority", {}).get("photographer_sets", "shutter speed")}, camera sets {camera_modes.get("shutter_priority", {}).get("camera_sets", "aperture")}, best for: {camera_modes.get("shutter_priority", {}).get("best_for", "controlling motion")}
229
+ Manual Mode: {camera_modes.get("manual_mode", {}).get("photographer_sets", "Both aperture and shutter speed")} - when to use: consistent lighting, studio work, advantage: {camera_modes.get("manual_mode", {}).get("advantage", "complete creative control")}
230
 
231
  Generate technically precise content optimized for FLUX's photorealistic capabilities using complete professional knowledge."""
232
+
233
+ return prompt
234
+
235
+ def _build_multimodal_prompt(self, knowledge: Dict[str, Any]) -> str:
236
+ """Build multimodal analysis prompt with complete professional knowledge"""
237
+
238
+ prompt = """Analyze this image with professional cinematography expertise for multi-platform prompt generation. You are a master cinematographer with extensive technical and artistic knowledge from 30+ years in cinema. Provide exactly two sections:
239
+
240
+ 1. DESCRIPTION: Expert visual analysis for prompt generation:
241
+ - Comprehensive scene description with photographic insight
242
+ - Subject matter, composition, and visual hierarchy
243
+ - Lighting analysis: quality, direction, mood, technical setup
244
+ - Color palette, contrast, and tonal relationships
245
+ - Artistic elements: style, mood, atmosphere, visual impact
246
+ - Technical photographic qualities and execution
247
+
248
+ 2. CAMERA_SETUP: Professional equipment and technique recommendation:
249
+ - Camera system recommendation based on scene requirements
250
+ - Lens selection with specific focal length and aperture range
251
+ - Technical shooting parameters and considerations
252
+ - Lighting setup and methodology for scene recreation
253
+ - Professional approach: shooting style and technical execution
254
+
255
+ Apply master-level cinematography knowledge: advanced composition techniques, professional lighting principles, camera system expertise, lens characteristics, and technical excellence. Create content suitable for multiple generative engines (Flux, Midjourney, etc.) with emphasis on photorealistic quality."""
256
+
257
+ return prompt
258
+
259
+ def _create_fallback_prompt(self, analysis_type: str) -> str:
260
+ """Create fallback prompt when professional knowledge is not available"""
261
+
262
+ if analysis_type == "cinematic":
263
+ return """Analyze this image as a professional cinematographer. Provide exactly two sections:
264
+
265
+ 1. DESCRIPTION: Create a detailed, flowing paragraph describing the image for cinematic reproduction:
266
+ - Scene composition and visual storytelling elements
267
+ - Lighting quality, direction, and dramatic mood
268
+ - Color palette, tonal relationships, and atmospheric elements
269
+ - Subject positioning, environmental context, and framing
270
+ - Cinematic qualities: film grain, depth of field, visual style
271
+ - Technical photographic elements that enhance realism
272
+
273
+ 2. CAMERA_SETUP: Recommend professional cinema/photography equipment based on scene analysis:
274
+ - Camera body: Choose from Canon EOS R5/R6, Sony A7R/A1, Leica M11, ARRI Alexa, RED cameras
275
+ - Lens: Specific focal length and aperture (e.g., "85mm f/1.4", "35mm anamorphic f/2.8")
276
+ - Technical settings: Aperture consideration for depth of field and story mood
277
+ - Lighting setup: Professional lighting rationale (key, fill, rim, practical lights)
278
+ - Shooting style: Documentary, portrait, landscape, architectural, or cinematic approach
279
+
280
+ Apply professional cinematography principles: rule of thirds, leading lines, depth layering, lighting direction for mood, and technical excellence. Focus on creating prompts optimized for photorealistic, cinema-quality generation."""
281
+
282
+ elif analysis_type == "flux_optimized":
283
+ return """Analyze this image for FLUX prompt generation with professional cinematography expertise. Provide exactly two sections:
284
+
285
+ 1. DESCRIPTION: Create a detailed technical description optimized for FLUX generation:
286
+ - Scene elements and composition with precise technical language
287
+ - Lighting setup and quality with specific technical terms
288
+ - Camera angle and perspective with professional terminology
289
+ - Color grading and tonal balance for photorealistic output
290
+ - Depth of field and focus characteristics
291
+ - Professional photographic style and execution
292
+
293
+ 2. CAMERA_SETUP: Recommend specific professional equipment for FLUX optimization:
294
+ - Professional camera body with model specifications
295
+ - Lens specifications with focal length and aperture
296
+ - ISO settings and technical parameters
297
+ - Professional lighting setup and rationale
298
+ - Shooting technique and professional approach
299
+
300
+ Focus on technical precision and professional terminology optimized for FLUX's photorealistic capabilities."""
301
 
302
  else: # multimodal analysis
303
+ return """Analyze this image with professional cinematography expertise for multi-platform prompt generation. Provide exactly two sections:
304
 
305
  1. DESCRIPTION: Expert visual analysis for prompt generation:
306
  - Comprehensive scene description with photographic insight