Hug0endob commited on
Commit
3f8bbcc
·
verified ·
1 Parent(s): 0f16c98

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +17 -4
streamlit_app.py CHANGED
@@ -28,9 +28,9 @@ DATA_DIR.mkdir(exist_ok=True)
28
 
29
  DEFAULT_MODEL = "gemini-2.0-flash-lite"
30
  DEFAULT_PROMPT = (
31
- "Watch the video and provide a detailed behavioral report focusing on human actions, "
32
- "interactions, posture, movement, and apparent intent. Keep language professional. "
33
- "Include a list of observations for notable events."
34
  )
35
 
36
  MODEL_OPTIONS = [
@@ -198,7 +198,15 @@ def generate_report(video_path: Path, prompt: str, model_id: str, timeout: int =
198
  generation_config={"max_output_tokens": 1024},
199
  request_options={"timeout": timeout},
200
  )
201
- return getattr(resp, "text", str(resp))
 
 
 
 
 
 
 
 
202
 
203
 
204
  def _strip_prompt_echo(prompt: str, text: str, threshold: float = 0.68) -> str:
@@ -211,6 +219,11 @@ def _strip_prompt_echo(prompt: str, text: str, threshold: float = 0.68) -> str:
211
  return text[cut:].lstrip(" \n:-")
212
  return text
213
 
 
 
 
 
 
214
 
215
  # ----------------------------------------------------------------------
216
  # UI helpers
 
28
 
29
  DEFAULT_MODEL = "gemini-2.0-flash-lite"
30
  DEFAULT_PROMPT = (
31
+ "Analyze the video and summarize the overall themes and patterns observed, "
32
+ "focusing on abstract representations of human actions without explicit details. "
33
+ "Describe the emotional context, dynamics of movement, and interactions using metaphorical language."
34
  )
35
 
36
  MODEL_OPTIONS = [
 
198
  generation_config={"max_output_tokens": 1024},
199
  request_options={"timeout": timeout},
200
  )
201
+
202
+ # Applying the filter right after generating the response
203
+ output_text = getattr(resp, "text", str(resp))
204
+
205
+ # Define keywords that you want to filter out
206
+ keywords = ["explicit", "graphic", "violence", "nudity"] # Add any other terms if necessary
207
+
208
+ filtered_text = filter_output(output_text, keywords) # Use the filtering function here
209
+ return filtered_text
210
 
211
 
212
  def _strip_prompt_echo(prompt: str, text: str, threshold: float = 0.68) -> str:
 
219
  return text[cut:].lstrip(" \n:-")
220
  return text
221
 
222
+ def filter_output(text: str, keywords: list) -> str:
223
+ for keyword in keywords:
224
+ if keyword.lower() in text.lower():
225
+ text = text.replace(keyword, "[REDACTED]")
226
+ return text
227
 
228
  # ----------------------------------------------------------------------
229
  # UI helpers