Spaces:
Sleeping
Sleeping
Miquel Farre
commited on
Commit
·
4a445e6
1
Parent(s):
3148909
fixing font
Browse files
app.py
CHANGED
|
@@ -11,35 +11,7 @@ import time
|
|
| 11 |
import torch
|
| 12 |
import spaces
|
| 13 |
import os
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# def setup_hf_auth():
|
| 17 |
-
# """
|
| 18 |
-
# Set up Hugging Face authentication using a token stored as a secret.
|
| 19 |
-
# Returns authenticated HfApi instance if successful.
|
| 20 |
-
# """
|
| 21 |
-
# try:
|
| 22 |
-
# # First try to get token from environment variable
|
| 23 |
-
# hf_token = os.getenv('HF_TOKEN')
|
| 24 |
-
|
| 25 |
-
# if not hf_token:
|
| 26 |
-
# raise ValueError("HF_TOKEN not found in environment variables or .env file")
|
| 27 |
-
|
| 28 |
-
# # Login to Hugging Face
|
| 29 |
-
# login(token=hf_token)
|
| 30 |
-
|
| 31 |
-
# # Initialize API client
|
| 32 |
-
# api = HfApi()
|
| 33 |
-
|
| 34 |
-
# # Verify authentication by trying to get user info
|
| 35 |
-
# user_info = api.whoami()
|
| 36 |
-
# print(f"Successfully authenticated as: {user_info.name}")
|
| 37 |
-
|
| 38 |
-
# return api
|
| 39 |
-
|
| 40 |
-
# except Exception as e:
|
| 41 |
-
# print(f"Authentication failed: {str(e)}")
|
| 42 |
-
# return None
|
| 43 |
|
| 44 |
from video_highlight_detector import (
|
| 45 |
load_model,
|
|
@@ -59,10 +31,18 @@ def format_duration(seconds: int) -> str:
|
|
| 59 |
return f"{hours}:{minutes:02d}:{secs:02d}"
|
| 60 |
return f"{minutes}:{secs:02d}"
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
def add_watermark(video_path: str, output_path: str):
|
| 63 |
watermark_text = "🤗 SmolVLM2 Highlight"
|
| 64 |
command = f"""ffmpeg -i {video_path} -vf \
|
| 65 |
-
"drawtext=text='{watermark_text}':
|
|
|
|
| 66 |
boxborderw=5:x=w-tw-10:y=h-th-10" \
|
| 67 |
-codec:a copy {output_path}"""
|
| 68 |
os.system(command)
|
|
@@ -208,9 +188,5 @@ if __name__ == "__main__":
|
|
| 208 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 209 |
zero = torch.Tensor([0]).to(device)
|
| 210 |
|
| 211 |
-
# hf_api = setup_hf_auth()
|
| 212 |
-
# if not hf_api:
|
| 213 |
-
# raise RuntimeError("Failed to authenticate with Hugging Face")
|
| 214 |
-
|
| 215 |
app = create_ui("video_spec.json")
|
| 216 |
app.launch()
|
|
|
|
| 11 |
import torch
|
| 12 |
import spaces
|
| 13 |
import os
|
| 14 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
from video_highlight_detector import (
|
| 17 |
load_model,
|
|
|
|
| 31 |
return f"{hours}:{minutes:02d}:{secs:02d}"
|
| 32 |
return f"{minutes}:{secs:02d}"
|
| 33 |
|
| 34 |
+
# def add_watermark(video_path: str, output_path: str):
|
| 35 |
+
# watermark_text = "🤗 SmolVLM2 Highlight"
|
| 36 |
+
# command = f"""ffmpeg -i {video_path} -vf \
|
| 37 |
+
# "drawtext=text='{watermark_text}':fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5:\
|
| 38 |
+
# boxborderw=5:x=w-tw-10:y=h-th-10" \
|
| 39 |
+
# -codec:a copy {output_path}"""
|
| 40 |
+
# os.system(command)
|
| 41 |
def add_watermark(video_path: str, output_path: str):
|
| 42 |
watermark_text = "🤗 SmolVLM2 Highlight"
|
| 43 |
command = f"""ffmpeg -i {video_path} -vf \
|
| 44 |
+
"drawtext=text='{watermark_text}':fontfile=NotoColorEmoji.ttf:\
|
| 45 |
+
fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5:\
|
| 46 |
boxborderw=5:x=w-tw-10:y=h-th-10" \
|
| 47 |
-codec:a copy {output_path}"""
|
| 48 |
os.system(command)
|
|
|
|
| 188 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 189 |
zero = torch.Tensor([0]).to(device)
|
| 190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
app = create_ui("video_spec.json")
|
| 192 |
app.launch()
|