Smasduq commited on
Commit
54c1cd0
·
1 Parent(s): 2156b71

added dockerfile and some config

Browse files
Files changed (3) hide show
  1. deploy_hf.sh +59 -0
  2. rustfinity.json +4 -0
  3. scripts/video_recognition.py +68 -0
deploy_hf.sh ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Exit immediately if a command exits with a non-zero status.
3
+ set -e
4
+
5
+ echo -e "\033[1;34m=== Monteeq Video Service HF Space Deployer ===\033[0m"
6
+
7
+ # Ensure we are in the correct directory
8
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9
+ cd "$DIR"
10
+
11
+ # 1. Initialize git repo if not already done
12
+ if [ ! -d ".git" ]; then
13
+ echo "Initializing new Git repository inside video-service..."
14
+ git init -b master
15
+ else
16
+ echo "Git repository already initialized."
17
+ fi
18
+
19
+ # 2. Check/Setup Hugging Face remote
20
+ HF_REMOTE=$(git remote get-url hf 2>/dev/null || echo "")
21
+
22
+ if [ -z "$HF_REMOTE" ]; then
23
+ echo -e "\033[1;33mNo Hugging Face remote found.\033[0m"
24
+ echo -e "Please enter your Hugging Face Space Git URL (e.g., git@hf.co:spaces/username/space-name or https://huggingface.co/spaces/username/space-name):"
25
+ read -r user_url
26
+ if [ -z "$user_url" ]; then
27
+ echo -e "\033[1;31mError: URL cannot be empty.\033[0m"
28
+ exit 1
29
+ fi
30
+ git remote add hf "$user_url"
31
+ echo -e "\033[1;32mRemote 'hf' successfully added!\033[0m"
32
+ else
33
+ echo -e "Current Hugging Face remote is set to: \033[1;32m$HF_REMOTE\033[0m"
34
+ echo "Do you want to change it? (y/n)"
35
+ read -r change_remote
36
+ if [[ "$change_remote" =~ ^[Yy]$ ]]; then
37
+ echo "Enter new Hugging Face Space Git URL:"
38
+ read -r user_url
39
+ if [ -n "$user_url" ]; then
40
+ git remote set-url hf "$user_url"
41
+ echo -e "\033[1;32mRemote 'hf' updated!\033[0m"
42
+ fi
43
+ fi
44
+ fi
45
+
46
+ # 3. Stage and commit
47
+ echo "Staging files..."
48
+ git add .gitignore Dockerfile README.md Cargo.toml Cargo.lock src/
49
+
50
+ echo "Creating commit..."
51
+ git commit -m "Deploy Monteeq Video Service to Hugging Face Spaces" || echo "No changes to commit"
52
+
53
+ # 4. Push
54
+ echo -e "\033[1;33mPushing to Hugging Face Space...\033[0m"
55
+ echo -e "Note: If this is the first push, it might require SSH authentication or a HF Access Token."
56
+ git push hf master --force
57
+
58
+ echo -e "\033[1;32m=== Deployment completed successfully! ===\033[0m"
59
+ echo "Go to your Hugging Face Space page to monitor the build progress."
rustfinity.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "project_id": "7e79819c-4200-467e-915f-105da78161b2",
3
+ "name": "monteeq-video-service"
4
+ }
scripts/video_recognition.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import subprocess
3
+ import json
4
+ import os
5
+
6
+ def get_video_stats(video_path):
7
+ # Use ffmpeg to extract some basic visual/audio stats without heavy ML
8
+ # We'll use the 'ebur128' for audio loudness and 'signalstats' for visual metadata
9
+
10
+ cmd = [
11
+ "ffmpeg", "-i", video_path,
12
+ "-vf", "signalstats,metadata=mode=print",
13
+ "-af", "ebur128=metadata=1",
14
+ "-f", "null", "-"
15
+ ]
16
+
17
+ # This might be too slow for full video, let's just do first 30 seconds
18
+ cmd = [
19
+ "ffmpeg", "-ss", "0", "-t", "30", "-i", video_path,
20
+ "-vf", "signalstats",
21
+ "-af", "ebur128=metadata=1",
22
+ "-f", "null", "-"
23
+ ]
24
+
25
+ try:
26
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
27
+ output = result.stderr
28
+ except Exception as e:
29
+ return {"error": str(e)}
30
+
31
+ # Extract tags based on characteristics
32
+ tags = []
33
+
34
+ # 1. PHONK DETECTION (High LUFS, distorted base)
35
+ # We look for high loudness and peaks
36
+ if "I:" in output:
37
+ try:
38
+ # Simple heuristic for phonk: very loud and compressed
39
+ loudness = float(output.split("I:")[1].split("LUFS")[0].strip())
40
+ if loudness > -8.0:
41
+ tags.append("Phonk / Drift")
42
+ except:
43
+ pass
44
+
45
+ # 2. VELOCITY DETECTION (Flicker/Motion)
46
+ # We check for high variations in 'lavfi.signalstats.YAVG' or similar
47
+ if "YAVG" in output:
48
+ # If we see high entropy or specific signal stats, it might be Velocity
49
+ tags.append("Velocity")
50
+
51
+ # 3. AESTHETIC / MOOD (Saturation/Brightness)
52
+ if "SATMIN" in output:
53
+ tags.append("Aesthetic")
54
+
55
+ # Default if nothing found but it's an edit
56
+ if not tags:
57
+ tags.append("Smooth Flow")
58
+
59
+ return list(set(tags))
60
+
61
+ if __name__ == "__main__":
62
+ if len(sys.argv) < 2:
63
+ print(json.dumps([]))
64
+ sys.exit(0)
65
+
66
+ video_path = sys.argv[1]
67
+ tags = get_video_stats(video_path)
68
+ print(json.dumps(tags))