Spaces:
Sleeping
Sleeping
csjhonathan
commited on
Commit
·
713fb63
1
Parent(s):
62b7ddd
ajusta verificação de conteúdo
Browse files
app.py
CHANGED
|
@@ -131,11 +131,17 @@ def analyze_image(image):
|
|
| 131 |
"grave", "tombstone", "funeral", "coffin", "burial"
|
| 132 |
]
|
| 133 |
|
|
|
|
| 134 |
suspicious_keywords = [
|
| 135 |
-
"
|
| 136 |
-
"
|
| 137 |
-
"
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
]
|
| 140 |
|
| 141 |
if eva02_model is not None:
|
|
@@ -149,9 +155,20 @@ def analyze_image(image):
|
|
| 149 |
abuse = any(keyword in combined_labels for keyword in abuse_keywords)
|
| 150 |
death = any(keyword in combined_labels for keyword in death_keywords)
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
sensitive = adult_content or violence or suffering or abuse or death or suspicious_animal or dead_dog
|
| 157 |
|
|
@@ -195,8 +212,11 @@ def analyze_image(image):
|
|
| 195 |
|
| 196 |
detected_human_tags = [tag for tag in human_keywords if tag in combined_labels]
|
| 197 |
detected_dog_tags = [tag for tag in dog_keywords if tag in combined_labels]
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
-
debug_info = f" [Debug: Human({human_count}): {detected_human_tags}, Dog({dog_count}): {detected_dog_tags}]"
|
| 200 |
|
| 201 |
return {
|
| 202 |
"content": content_type,
|
|
|
|
| 131 |
"grave", "tombstone", "funeral", "coffin", "burial"
|
| 132 |
]
|
| 133 |
|
| 134 |
+
# Palavras-chave para comportamento SUSPEITO (não normal)
|
| 135 |
suspicious_keywords = [
|
| 136 |
+
"unconscious", "motionless", "lifeless", "rigid", "cold", "pale",
|
| 137 |
+
"injured", "wounded", "bleeding", "hurt", "pain", "distress",
|
| 138 |
+
"abandoned", "neglected", "starving", "malnourished", "chained", "caged"
|
| 139 |
+
]
|
| 140 |
+
|
| 141 |
+
# Palavras-chave para comportamento NORMAL de cachorros (não suspeito)
|
| 142 |
+
normal_dog_behavior = [
|
| 143 |
+
"sleeping", "resting", "lying", "sitting", "playing", "running", "walking",
|
| 144 |
+
"happy", "excited", "alert", "awake", "active", "energetic", "playful"
|
| 145 |
]
|
| 146 |
|
| 147 |
if eva02_model is not None:
|
|
|
|
| 155 |
abuse = any(keyword in combined_labels for keyword in abuse_keywords)
|
| 156 |
death = any(keyword in combined_labels for keyword in death_keywords)
|
| 157 |
|
| 158 |
+
# Detecção mais inteligente para cachorros
|
| 159 |
+
has_suspicious_behavior = any(keyword in combined_labels for keyword in suspicious_keywords)
|
| 160 |
+
has_normal_behavior = any(keyword in combined_labels for keyword in normal_dog_behavior)
|
| 161 |
+
has_death_indicators = any(keyword in combined_labels for keyword in death_keywords)
|
| 162 |
+
|
| 163 |
+
# Se é um cachorro, só marcar como suspeito se:
|
| 164 |
+
# 1. Tem indicadores de morte OU
|
| 165 |
+
# 2. Tem comportamento suspeito E NÃO tem comportamento normal
|
| 166 |
+
if is_dog:
|
| 167 |
+
suspicious_animal = has_death_indicators or (has_suspicious_behavior and not has_normal_behavior)
|
| 168 |
+
dead_dog = has_death_indicators
|
| 169 |
+
else:
|
| 170 |
+
suspicious_animal = has_suspicious_behavior
|
| 171 |
+
dead_dog = False
|
| 172 |
|
| 173 |
sensitive = adult_content or violence or suffering or abuse or death or suspicious_animal or dead_dog
|
| 174 |
|
|
|
|
| 212 |
|
| 213 |
detected_human_tags = [tag for tag in human_keywords if tag in combined_labels]
|
| 214 |
detected_dog_tags = [tag for tag in dog_keywords if tag in combined_labels]
|
| 215 |
+
detected_suspicious = [tag for tag in suspicious_keywords if tag in combined_labels]
|
| 216 |
+
detected_normal = [tag for tag in normal_dog_behavior if tag in combined_labels]
|
| 217 |
+
detected_death = [tag for tag in death_keywords if tag in combined_labels]
|
| 218 |
|
| 219 |
+
debug_info = f" [Debug: Human({human_count}): {detected_human_tags}, Dog({dog_count}): {detected_dog_tags}, Suspicious: {detected_suspicious}, Normal: {detected_normal}, Death: {detected_death}]"
|
| 220 |
|
| 221 |
return {
|
| 222 |
"content": content_type,
|