📌 Overview
Currently, DeepSentry accepts uploaded image and video files without any file size restrictions. All uploaded files are fully loaded into memory (RAM) before processing and inference.
While this works well for small and medium-sized files during local testing, extremely large uploads may lead to:
- High RAM consumption
- Slow processing times
- Server instability
- Increased API response latency
- Possible crashes on low-resource systems
This becomes especially important when deploying the application publicly or handling multiple concurrent users.
⚠️ Current Behavior
At the moment:
- Any supported file size can be uploaded
- Videos are read entirely into memory
- No validation occurs before processing
- Users do not receive a clear error for oversized uploads
Example scenario:
- A user uploads a 2 GB ".mp4" file
- The backend attempts to load/process it
- RAM usage spikes dramatically
- Inference becomes unstable or crashes
✅ Proposed Solution
Implement server-side upload size validation before inference begins.
Suggested Limits
Media Type| Recommended Limit
Images| 10 MB
Videos| 100 MB
These limits should remain configurable through environment variables or constants for easier deployment customization.
🔧 Suggested Implementation
- Validate File Size Before Processing
Check upload size immediately after receiving the file.
Example logic:
- Read file size
- Compare against allowed maximum
- Reject oversized files before OpenCV/PIL processing
- Return Proper HTTP Error Responses
If file size exceeds the allowed limit:
- Return HTTP "413 Payload Too Large"
- Include a user-friendly JSON response
Example:
{
"detail": "Uploaded file exceeds maximum allowed size."
}
- Add Configurable Limits
Move hardcoded values into constants or environment variables.
Example:
MAX_IMAGE_SIZE_MB = 10
MAX_VIDEO_SIZE_MB = 100
or:
MAX_IMAGE_SIZE_MB=10
MAX_VIDEO_SIZE_MB=100
This improves flexibility across:
- local development
- cloud deployment
- low-memory VPS servers
📂 Files Likely Affected
Potentially:
- frontend validation in "index.html"
💡 Optional Enhancements
Future improvements could include:
Frontend Validation
Display file size errors before upload begins.
Streaming Uploads
Avoid loading entire videos into memory.
Progress Indicators
Show upload and processing progress for large files.
Dynamic Limits
Different size limits based on deployment environment.
🎯 Benefits
Implementing upload size validation would improve:
- Stability
- Security
- Scalability
- Resource management
- Production readiness
- User experience
It would also prevent accidental server overload from extremely large uploads.
🏷️ Suggested Labels
- enhancement
- security
- backend
- performance
- good first issue
🚀 Expected Outcome
After implementation:
- Oversized files are rejected safely
- RAM usage remains controlled
- API becomes more production-ready
- Users receive clear validation feedback
- Deployment reliability improves significantly
📌 Overview
Currently, DeepSentry accepts uploaded image and video files without any file size restrictions. All uploaded files are fully loaded into memory (RAM) before processing and inference.
While this works well for small and medium-sized files during local testing, extremely large uploads may lead to:
This becomes especially important when deploying the application publicly or handling multiple concurrent users.
At the moment:
Example scenario:
✅ Proposed Solution
Implement server-side upload size validation before inference begins.
Suggested Limits
Media Type| Recommended Limit
Images| 10 MB
Videos| 100 MB
These limits should remain configurable through environment variables or constants for easier deployment customization.
🔧 Suggested Implementation
Check upload size immediately after receiving the file.
Example logic:
If file size exceeds the allowed limit:
Example:
{
"detail": "Uploaded file exceeds maximum allowed size."
}
Move hardcoded values into constants or environment variables.
Example:
MAX_IMAGE_SIZE_MB = 10
MAX_VIDEO_SIZE_MB = 100
or:
MAX_IMAGE_SIZE_MB=10
MAX_VIDEO_SIZE_MB=100
This improves flexibility across:
📂 Files Likely Affected
Potentially:
💡 Optional Enhancements
Future improvements could include:
Frontend Validation
Display file size errors before upload begins.
Streaming Uploads
Avoid loading entire videos into memory.
Progress Indicators
Show upload and processing progress for large files.
Dynamic Limits
Different size limits based on deployment environment.
🎯 Benefits
Implementing upload size validation would improve:
It would also prevent accidental server overload from extremely large uploads.
🏷️ Suggested Labels
🚀 Expected Outcome
After implementation: