Hugging Face Deployment - Step by Step
Step 1: Hugging Face Account එකක් හදාගන්න
- https://huggingface.co/join වෙබ් අඩවියට යන්න
- Email එකක් දාලා Sign Up කරන්න
- Email එකේ verification link එක click කරන්න
- Login වෙන්න
Step 2: නව Space එකක් Create කරන්න
- Profile picture එක click කරන්න (top right corner)
- "New Space" button එක click කරන්න
- විස්තර fill කරන්න:
- Space name:
dulaksha-stream(හෝ ඕන නමක්) - License: MIT
- Select SDK: Docker (මේක select කරන්න ඕනේ)
- Space hardware: CPU basic - Free
- Space name:
- "Create Space" click කරන්න
Step 3: Files Upload කරන්න
Method 1: Web Interface එකෙන් (Easy)
- "Files" tab එක click කරන්න
- "Add file" > "Upload files" click කරන්න
- මේ files upload කරන්න එකින් එක:
server.jspackage.jsonDockerfile.dockerignore
- Upload වෙලා නැති files තියෙනවනම් repeat කරන්න
Method 2: Git එකෙන් (Advanced)
git clone https://huggingface.co/spaces/YOUR-USERNAME/dulaksha-stream
cd dulaksha-stream
# Copy all files to this folder
git add .
git commit -m "Initial commit"
git push
Step 4: Build එක Wait කරන්න
- "App" tab එකට යන්න
- "Building" status එක පෙන්නන එක බලන්න
- 5-10 minutes විතර wait කරන්න
- "Running" කියලා status එක change වෙනකල් wait කරන්න
Build එක fail වෙනවනම්:
- "Logs" tab එක check කරන්න
- Error message එක copy කරන්න
Step 5: URL එක ගන්න
Build එක success වුණාම ඔයාගේ app එක මේ URL එකේ available වෙයි:
https://YOUR-USERNAME-dulaksha-stream.hf.space
උදාහරණ:
https://dulaksha-dulaksha-stream.hf.space
Step 6: Test කරන්න
Browser එකෙන් Test:
- URL එක browser එකේ open කරන්න
- Server running කියලා පෙන්වන්න ඕන
Video Upload Test (Postman):
- Postman open කරන්න
- New Request create කරන්න
- Settings:
- Method: POST
- URL:
https://YOUR-USERNAME-dulaksha-stream.hf.space/upload - Body: form-data
- Key:
file(type: File) - Value: video file එකක් select කරන්න
- Send click කරන්න
cURL එකෙන් Test:
curl -X POST -F "file=@video.mp4" https://YOUR-USERNAME-dulaksha-stream.hf.space/upload
Step 7: Response එක Check කරන්න
Upload success වුණාම මේ විදිහේ response එකක් එනවා:
{
"status": "success",
"stream_link": "https://YOUR-SPACE.hf.space/stream/123456/video.mp4",
"qualities": ["1080p", "720p", "480p"]
}
Video Quality Conversion
- 2160p (4K) video: Convert to 1080p, 720p, 480p
- 1080p video: Convert to 1080p, 720p, 480p
- 720p video: Convert to 720p, 480p
- 480p video: Keep as 480p
API Endpoints
Upload Video
POST /upload
Content-Type: multipart/form-data
Body: file (video file)
Stream File
GET /stream/:id/:filename
Download File
GET /download/:id/:filename
Important Notes
- Bot connect වෙන්න විනාඩි 2-3ක් යනවා - First upload එකට wait කරන්න
- Large files වලට processing time වැඩියි - 4K videos වලට 10-20 minutes යනවා
- Stream links permanent - කවදාවත් expire වෙන්නේ නැහැ
- All files Telegram එකේ store වෙනවා - Backup එකක් විදිහට
Common Issues
1. Build Failed
Solution: Dockerfile එක හරියටම copy වෙලා තියෙනවද check කරන්න
2. Service Unavailable
Solution: විනාඩි 2-3ක් wait කරලා retry කරන්න (bot connecting)
3. Upload Timeout
Solution:
- File size අඩු කරන්න
- Better hardware tier එකක් select කරන්න (Settings > Hardware)
4. FFmpeg Error
Solution: Video file එක corrupt වෙලා නැද්ද check කරන්න
Hardware Upgrade (Optional)
Free tier slow නම්:
- Space Settings > Hardware
- Upgrade කරන්න:
- CPU basic (Free) → CPU upgrade ($0.60/hour)
- GPU එකක් select කරන්න (faster conversion)
Files නෙරපන්න ඕනේ නම්
# Hugging Face Space එකේ
Files > Delete කරන්න files
සියලු files මේ folder එකේ තියෙනවා. Upload කරන්න විතරයි ඕන!