Malaji71 commited on
Commit
8c92505
·
verified ·
1 Parent(s): 6ee37e6

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +22 -39
models.py CHANGED
@@ -97,53 +97,36 @@ class BagelAPIAnalyzer(BaseImageAnalyzer):
97
  from professional_photography import EXPERT_PHOTOGRAPHY_KNOWLEDGE
98
 
99
  # Create the teaching prompt with the complete structure
100
- prompt = f"""Analiza esta imagen con conocimiento cinematográfico profesional completo. Estructura tu respuesta así:
101
 
102
- GRAMÁTICA: [PLANO] of [SUJETO] [ACCIÓN] [CONTEXTO], [ILUMINACIÓN], [COMPOSICIÓN], shot on [CÁMARA], [LENTE], [CONFIGURACIÓN]
103
 
104
- BUSCA ESTOS CAMPOS:
 
 
 
 
 
 
105
 
106
- PLANO: Consulta photographic_planes completo:
107
- {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('photographic_planes', {})}
108
- - Encuentra el plano que coincida exactamente
109
-
110
- SUJETO + ACCIÓN: Describe exactamente lo que ves - persona, objeto, qué está haciendo
111
-
112
- CONTEXTO: Describe el ambiente/entorno completamente - ubicación, elementos del fondo
113
-
114
- ILUMINACIÓN: Consulta lighting_principles completo:
115
- {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('lighting_principles', {})}
116
- - Encuentra el tipo de iluminación que coincida
117
-
118
- COMPOSICIÓN: Consulta composition_rules completo:
119
- {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('composition_rules', {})}
120
- - Encuentra la técnica de composición que se aplica
121
-
122
- CONFIGURACIÓN TÉCNICA: Consulta scene_types completo:
123
- {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('scene_types', {})}
124
- - Encuentra el setup de cámara apropiado para el tipo de escena
125
-
126
- USA TODA LA BASE DE DATOS EXPERT_PHOTOGRAPHY_KNOWLEDGE COMPLETA.
127
-
128
- Completa cada campo con la información específica que encuentres. Responde en el formato de gramática especificado."""
129
 
130
  return prompt
131
 
132
  except Exception as e:
133
  logger.warning(f"Professional knowledge base access failed: {e}")
134
- return """Analiza esta imagen con conocimiento cinematográfico profesional. Estructura tu respuesta así:
135
 
136
- GRAMÁTICA: [PLANO] of [SUJETO] [ACCIÓN] [CONTEXTO], [ILUMINACIÓN], [COMPOSICIÓN], shot on [CÁMARA], [LENTE], [CONFIGURACIÓN]
137
 
138
- BUSCA Y COMPLETA CADA CAMPO:
139
- - PLANO: wide shot, medium shot, close-up, etc.
140
- - SUJETO + ACCIÓN: exactamente lo que ves
141
- - CONTEXTO: ambiente y entorno
142
- - ILUMINACIÓN: tipo de luz
143
- - COMPOSICIÓN: técnica utilizada
144
- - CONFIGURACIÓN TÉCNICA: cámara y lente apropiados
145
 
146
- Usa tu conocimiento profesional completo para completar cada campo."""
147
 
148
  def _save_temp_image(self, image: Image.Image) -> str:
149
  """Save image to temporary file for API call"""
@@ -202,13 +185,13 @@ Usa tu conocimiento profesional completo para completar cada campo."""
202
 
203
  logger.info("Calling BAGEL API with professional_photography.py prompt...")
204
 
205
- # Call BAGEL API with professional prompt - let it do its work
206
  result = self.client.predict(
207
  image=handle_file(temp_path),
208
  prompt=prompt,
209
  show_thinking=False,
210
- do_sample=True, # Allow creativity
211
- text_temperature=0.7, # Higher temperature for richer descriptions
212
  max_new_tokens=1024, # More tokens for detailed analysis
213
  api_name=self.api_endpoint
214
  )
 
97
  from professional_photography import EXPERT_PHOTOGRAPHY_KNOWLEDGE
98
 
99
  # Create the teaching prompt with the complete structure
100
+ prompt = f"""Analyze this image using complete professional cinematography knowledge.
101
 
102
+ STRUCTURE: [PLANE] of [SUBJECT] [ACTION] [CONTEXT], [LIGHTING], [COMPOSITION], shot on [CAMERA], [LENS], [SETTINGS]
103
 
104
+ PLANE: From {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('photographic_planes', {})}
105
+ SUBJECT + ACTION: Define accurately what you see
106
+ CONTEXT: Define the environment accurately
107
+ LIGHTING: From {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('lighting_principles', {})}
108
+ COMPOSITION: From {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('composition_rules', {})}
109
+ CAMERA ANGLES: From {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('camera_angles', {})}
110
+ TECHNICAL SETUP: From {EXPERT_PHOTOGRAPHY_KNOWLEDGE.get('scene_types', {})}
111
 
112
+ Complete the structure using the appropriate elements from each section."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  return prompt
115
 
116
  except Exception as e:
117
  logger.warning(f"Professional knowledge base access failed: {e}")
118
+ return """Analyze this image using complete professional cinematography knowledge.
119
 
120
+ STRUCTURE: [PLANE] of [SUBJECT] [ACTION] [CONTEXT], [LIGHTING], [COMPOSITION], shot on [CAMERA], [LENS], [SETTINGS]
121
 
122
+ PLANE: wide_shot, medium_shot, close_up, extreme_wide_shot, extreme_close_up, detail_shot
123
+ SUBJECT + ACTION: Define accurately what you see
124
+ CONTEXT: Define the environment accurately
125
+ LIGHTING: golden_hour, natural_daylight, dramatic_lighting, soft_natural, blue_hour, studio_lighting
126
+ COMPOSITION: rule_of_thirds, leading_lines, symmetrical, centered_composition, dynamic_composition
127
+ TECHNICAL SETUP: Professional camera and lens specifications
 
128
 
129
+ Complete the structure using the appropriate elements."""
130
 
131
  def _save_temp_image(self, image: Image.Image) -> str:
132
  """Save image to temporary file for API call"""
 
185
 
186
  logger.info("Calling BAGEL API with professional_photography.py prompt...")
187
 
188
+ # Call BAGEL API with professional prompt - FORCE NEW READING
189
  result = self.client.predict(
190
  image=handle_file(temp_path),
191
  prompt=prompt,
192
  show_thinking=False,
193
+ do_sample=True, # Allow creativity and variation
194
+ text_temperature=0.8, # Higher temperature for different responses each time
195
  max_new_tokens=1024, # More tokens for detailed analysis
196
  api_name=self.api_endpoint
197
  )