Rtop0726 commited on
Commit
b6b19f4
Β·
verified Β·
1 Parent(s): 156d7e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -56,10 +56,27 @@ def _get_capacity_snapshot() -> dict:
56
  # there's no position bias and it's faster than even a 2-token LLM call β€”
57
  # just one forward pass per script+candidate pair, batched.
58
  # ══════════════════════════════════════════════════════════════════════════
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  def _select_best_position(script: str, videos: list) -> int:
60
  if not videos:
61
  return None
62
- tag_strings = [v.get("tags", "") for v in videos]
63
 
64
  script_emb = embedder.encode(script, convert_to_tensor=True)
65
  tag_embs = embedder.encode(tag_strings, convert_to_tensor=True)
 
56
  # there's no position bias and it's faster than even a 2-token LLM call β€”
57
  # just one forward pass per script+candidate pair, batched.
58
  # ══════════════════════════════════════════════════════════════════════════
59
+ # Pixabay boilerplate/metadata tags that describe the *asset* rather than
60
+ # its visual content, and can falsely spike similarity (e.g. "ai generated"
61
+ # just means the clip was made with generative AI tools β€” it says nothing
62
+ # about the subject matter β€” but it collides hard with any script mentioning
63
+ # "AI"). Stripped before embedding.
64
+ _NOISE_TAGS = {
65
+ "ai generated", "live wallpaper", "background", "wallpaper",
66
+ "beautiful wallpaper", "backdrop",
67
+ }
68
+
69
+
70
+ def _clean_tags(tags: str) -> str:
71
+ parts = [t.strip() for t in tags.split(",")]
72
+ kept = [t for t in parts if t.lower() not in _NOISE_TAGS]
73
+ return ", ".join(kept) if kept else tags # never return empty
74
+
75
+
76
  def _select_best_position(script: str, videos: list) -> int:
77
  if not videos:
78
  return None
79
+ tag_strings = [_clean_tags(v.get("tags", "")) for v in videos]
80
 
81
  script_emb = embedder.encode(script, convert_to_tensor=True)
82
  tag_embs = embedder.encode(tag_strings, convert_to_tensor=True)