Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +521 -19
- prompts.txt +0 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: u-f-ai-enhancer
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: purple
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,521 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>U.F. AI Enhancer - Video Quality Improvement Tool</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.gradient-bg {
|
11 |
+
background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
|
12 |
+
}
|
13 |
+
.video-container {
|
14 |
+
aspect-ratio: 16/9;
|
15 |
+
background-color: #1a202c;
|
16 |
+
}
|
17 |
+
.slider-thumb::-webkit-slider-thumb {
|
18 |
+
-webkit-appearance: none;
|
19 |
+
appearance: none;
|
20 |
+
width: 20px;
|
21 |
+
height: 20px;
|
22 |
+
border-radius: 50%;
|
23 |
+
background: #6e8efb;
|
24 |
+
cursor: pointer;
|
25 |
+
}
|
26 |
+
.slider-thumb::-moz-range-thumb {
|
27 |
+
width: 20px;
|
28 |
+
height: 20px;
|
29 |
+
border-radius: 50%;
|
30 |
+
background: #6e8efb;
|
31 |
+
cursor: pointer;
|
32 |
+
}
|
33 |
+
.processing-loader {
|
34 |
+
border: 5px solid #f3f3f3;
|
35 |
+
border-top: 5px solid #6e8efb;
|
36 |
+
border-radius: 50%;
|
37 |
+
width: 50px;
|
38 |
+
height: 50px;
|
39 |
+
animation: spin 1s linear infinite;
|
40 |
+
}
|
41 |
+
@keyframes spin {
|
42 |
+
0% { transform: rotate(0deg); }
|
43 |
+
100% { transform: rotate(360deg); }
|
44 |
+
}
|
45 |
+
.code-block {
|
46 |
+
font-family: 'Courier New', Courier, monospace;
|
47 |
+
background-color: #2d3748;
|
48 |
+
color: #e2e8f0;
|
49 |
+
border-radius: 0.5rem;
|
50 |
+
overflow-x: auto;
|
51 |
+
}
|
52 |
+
</style>
|
53 |
+
</head>
|
54 |
+
<body class="min-h-screen bg-gray-100">
|
55 |
+
<header class="gradient-bg text-white shadow-lg">
|
56 |
+
<div class="container mx-auto px-4 py-6">
|
57 |
+
<div class="flex items-center justify-between">
|
58 |
+
<div class="flex items-center space-x-4">
|
59 |
+
<i class="fas fa-robot text-3xl"></i>
|
60 |
+
<h1 class="text-2xl font-bold">U.F. AI Enhancer</h1>
|
61 |
+
</div>
|
62 |
+
<nav>
|
63 |
+
<ul class="flex space-x-6">
|
64 |
+
<li><a href="#" class="hover:text-gray-200 transition">Home</a></li>
|
65 |
+
<li><a href="#features" class="hover:text-gray-200 transition">Features</a></li>
|
66 |
+
<li><a href="#how-it-works" class="hover:text-gray-200 transition">How It Works</a></li>
|
67 |
+
<li><a href="#code" class="hover:text-gray-200 transition">Code</a></li>
|
68 |
+
</ul>
|
69 |
+
</nav>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
</header>
|
73 |
+
|
74 |
+
<main class="container mx-auto px-4 py-8">
|
75 |
+
<section class="mb-16 text-center">
|
76 |
+
<h2 class="text-4xl font-bold mb-6 text-gray-800">Enhance Your Videos with AI</h2>
|
77 |
+
<p class="text-xl text-gray-600 max-w-3xl mx-auto">
|
78 |
+
U.F. AI Enhancer is an offline tool that improves video quality by adjusting brightness, contrast, and sharpness using computer vision techniques.
|
79 |
+
</p>
|
80 |
+
</section>
|
81 |
+
|
82 |
+
<section class="mb-16 bg-white rounded-xl shadow-lg p-6">
|
83 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
84 |
+
<div>
|
85 |
+
<h3 class="text-2xl font-semibold mb-4 text-gray-800">Upload & Process</h3>
|
86 |
+
<div class="video-container rounded-lg mb-4 flex items-center justify-center relative">
|
87 |
+
<div id="video-placeholder" class="text-center p-4 text-gray-400">
|
88 |
+
<i class="fas fa-video text-5xl mb-3"></i>
|
89 |
+
<p>Your video will appear here</p>
|
90 |
+
</div>
|
91 |
+
<video id="video-preview" controls class="w-full h-full hidden"></video>
|
92 |
+
</div>
|
93 |
+
<div class="flex justify-between mb-4">
|
94 |
+
<button id="upload-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-lg transition flex items-center">
|
95 |
+
<i class="fas fa-upload mr-2"></i> Upload Video
|
96 |
+
</button>
|
97 |
+
<button id="process-btn" class="bg-purple-500 hover:bg-purple-600 text-white px-6 py-2 rounded-lg transition flex items-center disabled:opacity-50" disabled>
|
98 |
+
<i class="fas fa-magic mr-2"></i> Enhance Video
|
99 |
+
</button>
|
100 |
+
</div>
|
101 |
+
<input type="file" id="video-input" accept="video/*" class="hidden">
|
102 |
+
</div>
|
103 |
+
<div>
|
104 |
+
<h3 class="text-2xl font-semibold mb-4 text-gray-800">Enhancement Settings</h3>
|
105 |
+
<div class="space-y-6">
|
106 |
+
<div>
|
107 |
+
<label for="brightness" class="block text-gray-700 mb-2">Brightness</label>
|
108 |
+
<input type="range" id="brightness" min="-100" max="100" value="0" class="w-full slider-thumb">
|
109 |
+
<div class="flex justify-between text-sm text-gray-500">
|
110 |
+
<span>Darker</span>
|
111 |
+
<span>Normal</span>
|
112 |
+
<span>Brighter</span>
|
113 |
+
</div>
|
114 |
+
</div>
|
115 |
+
<div>
|
116 |
+
<label for="contrast" class="block text-gray-700 mb-2">Contrast</label>
|
117 |
+
<input type="range" id="contrast" min="-100" max="100" value="0" class="w-full slider-thumb">
|
118 |
+
<div class="flex justify-between text-sm text-gray-500">
|
119 |
+
<span>Lower</span>
|
120 |
+
<span>Normal</span>
|
121 |
+
<span>Higher</span>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
<div>
|
125 |
+
<label for="sharpness" class="block text-gray-700 mb-2">Sharpness</label>
|
126 |
+
<input type="range" id="sharpness" min="0" max="100" value="50" class="w-full slider-thumb">
|
127 |
+
<div class="flex justify-between text-sm text-gray-500">
|
128 |
+
<span>Softer</span>
|
129 |
+
<span>Normal</span>
|
130 |
+
<span>Sharper</span>
|
131 |
+
</div>
|
132 |
+
</div>
|
133 |
+
<div>
|
134 |
+
<label for="filter" class="block text-gray-700 mb-2">Filter Preset</label>
|
135 |
+
<select id="filter" class="w-full p-2 border border-gray-300 rounded-lg">
|
136 |
+
<option value="none">None</option>
|
137 |
+
<option value="vivid">Vivid Colors</option>
|
138 |
+
<option value="cinematic">Cinematic</option>
|
139 |
+
<option value="blackwhite">Black & White</option>
|
140 |
+
</select>
|
141 |
+
</div>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
</section>
|
146 |
+
|
147 |
+
<section id="features" class="mb-16">
|
148 |
+
<h2 class="text-3xl font-bold mb-8 text-center text-gray-800">Key Features</h2>
|
149 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
150 |
+
<div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition">
|
151 |
+
<div class="text-blue-500 mb-4">
|
152 |
+
<i class="fas fa-sun text-4xl"></i>
|
153 |
+
</div>
|
154 |
+
<h3 class="text-xl font-semibold mb-2">Brightness Adjustment</h3>
|
155 |
+
<p class="text-gray-600">Fine-tune the brightness levels to make your videos clearer in low-light conditions or tone down overexposed footage.</p>
|
156 |
+
</div>
|
157 |
+
<div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition">
|
158 |
+
<div class="text-purple-500 mb-4">
|
159 |
+
<i class="fas fa-adjust text-4xl"></i>
|
160 |
+
</div>
|
161 |
+
<h3 class="text-xl font-semibold mb-2">Contrast Enhancement</h3>
|
162 |
+
<p class="text-gray-600">Improve the distinction between light and dark areas to make your videos pop with better visual depth.</p>
|
163 |
+
</div>
|
164 |
+
<div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition">
|
165 |
+
<div class="text-green-500 mb-4">
|
166 |
+
<i class="fas fa-cut text-4xl"></i>
|
167 |
+
</div>
|
168 |
+
<h3 class="text-xl font-semibold mb-2">Sharpness Control</h3>
|
169 |
+
<p class="text-gray-600">Reduce blurriness and enhance edge definition for crisper, more professional-looking videos.</p>
|
170 |
+
</div>
|
171 |
+
</div>
|
172 |
+
</section>
|
173 |
+
|
174 |
+
<section id="how-it-works" class="mb-16 bg-white rounded-xl shadow-lg p-8">
|
175 |
+
<h2 class="text-3xl font-bold mb-6 text-center text-gray-800">How It Works</h2>
|
176 |
+
<div class="space-y-8">
|
177 |
+
<div class="flex flex-col md:flex-row items-center">
|
178 |
+
<div class="md:w-1/4 text-center mb-4 md:mb-0">
|
179 |
+
<div class="bg-blue-100 text-blue-600 w-16 h-16 rounded-full flex items-center justify-center mx-auto text-2xl font-bold">1</div>
|
180 |
+
</div>
|
181 |
+
<div class="md:w-3/4">
|
182 |
+
<h3 class="text-xl font-semibold mb-2">Upload Your Video</h3>
|
183 |
+
<p class="text-gray-600">Select any video file from your device. The tool supports common formats like MP4, AVI, and MOV.</p>
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
<div class="flex flex-col md:flex-row items-center">
|
187 |
+
<div class="md:w-1/4 text-center mb-4 md:mb-0">
|
188 |
+
<div class="bg-purple-100 text-purple-600 w-16 h-16 rounded-full flex items-center justify-center mx-auto text-2xl font-bold">2</div>
|
189 |
+
</div>
|
190 |
+
<div class="md:w-3/4">
|
191 |
+
<h3 class="text-xl font-semibold mb-2">Adjust Enhancement Settings</h3>
|
192 |
+
<p class="text-gray-600">Use the intuitive sliders to customize brightness, contrast, and sharpness levels to your preference.</p>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
<div class="flex flex-col md:flex-row items-center">
|
196 |
+
<div class="md:w-1/4 text-center mb-4 md:mb-0">
|
197 |
+
<div class="bg-green-100 text-green-600 w-16 h-16 rounded-full flex items-center justify-center mx-auto text-2xl font-bold">3</div>
|
198 |
+
</div>
|
199 |
+
<div class="md:w-3/4">
|
200 |
+
<h3 class="text-xl font-semibold mb-2">Process & Download</h3>
|
201 |
+
<p class="text-gray-600">The AI processes each frame to apply your enhancements, then outputs a new, improved video file.</p>
|
202 |
+
</div>
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
</section>
|
206 |
+
|
207 |
+
<section id="code" class="mb-16">
|
208 |
+
<h2 class="text-3xl font-bold mb-6 text-center text-gray-800">Python Implementation</h2>
|
209 |
+
<p class="text-gray-600 mb-8 text-center max-w-3xl mx-auto">
|
210 |
+
Below is the complete Python code for the U.F. AI Enhancer. This offline tool uses OpenCV for frame-by-frame processing and MoviePy for final rendering.
|
211 |
+
</p>
|
212 |
+
|
213 |
+
<div class="code-block p-6 mb-8">
|
214 |
+
<pre><code>import cv2
|
215 |
+
import numpy as np
|
216 |
+
from moviepy.editor import VideoFileClip, VideoClip
|
217 |
+
import os
|
218 |
+
import time
|
219 |
+
|
220 |
+
class VideoEnhancer:
|
221 |
+
def __init__(self):
|
222 |
+
"""Initialize the video enhancer with default settings."""
|
223 |
+
self.brightness = 0 # Range: -100 to 100
|
224 |
+
self.contrast = 0 # Range: -100 to 100
|
225 |
+
self.sharpness = 50 # Range: 0 to 100
|
226 |
+
self.filter_preset = "none" # Options: none, vivid, cinematic, blackwhite
|
227 |
+
|
228 |
+
def apply_enhancements(self, frame):
|
229 |
+
"""Apply all selected enhancements to a single frame.
|
230 |
+
|
231 |
+
Args:
|
232 |
+
frame: Input frame (numpy array)
|
233 |
+
|
234 |
+
Returns:
|
235 |
+
Enhanced frame (numpy array)
|
236 |
+
"""
|
237 |
+
# Convert frame to float for processing
|
238 |
+
frame = frame.astype('float32') / 255.0
|
239 |
+
|
240 |
+
# Apply brightness and contrast
|
241 |
+
frame = self.adjust_brightness_contrast(frame)
|
242 |
+
|
243 |
+
# Apply sharpness
|
244 |
+
frame = self.apply_sharpness(frame)
|
245 |
+
|
246 |
+
# Apply filter preset
|
247 |
+
frame = self.apply_filter(frame)
|
248 |
+
|
249 |
+
# Convert back to 8-bit
|
250 |
+
frame = (frame * 255).astype('uint8')
|
251 |
+
|
252 |
+
return frame
|
253 |
+
|
254 |
+
def adjust_brightness_contrast(self, frame):
|
255 |
+
"""Adjust brightness and contrast of the frame.
|
256 |
+
|
257 |
+
Args:
|
258 |
+
frame: Input frame (float32, 0-1 range)
|
259 |
+
|
260 |
+
Returns:
|
261 |
+
Adjusted frame (float32, 0-1 range)
|
262 |
+
"""
|
263 |
+
# Convert brightness/contrast values to multipliers
|
264 |
+
brightness_factor = (self.brightness + 100) / 100.0
|
265 |
+
contrast_factor = (self.contrast + 100) / 100.0
|
266 |
+
|
267 |
+
# Apply brightness
|
268 |
+
frame = frame * brightness_factor
|
269 |
+
|
270 |
+
# Apply contrast
|
271 |
+
frame = ((frame - 0.5) * contrast_factor) + 0.5
|
272 |
+
|
273 |
+
# Clip values to 0-1 range
|
274 |
+
frame = np.clip(frame, 0, 1)
|
275 |
+
|
276 |
+
return frame
|
277 |
+
|
278 |
+
def apply_sharpness(self, frame):
|
279 |
+
"""Apply sharpness enhancement to the frame.
|
280 |
+
|
281 |
+
Args:
|
282 |
+
frame: Input frame (float32, 0-1 range)
|
283 |
+
|
284 |
+
Returns:
|
285 |
+
Sharpened frame (float32, 0-1 range)
|
286 |
+
"""
|
287 |
+
if self.sharpness == 50: # No sharpness adjustment
|
288 |
+
return frame
|
289 |
+
|
290 |
+
# Convert sharpness to a kernel strength (0-2 range)
|
291 |
+
strength = self.sharpness / 50.0
|
292 |
+
|
293 |
+
# Create sharpening kernel
|
294 |
+
kernel = np.array([[-1, -1, -1],
|
295 |
+
[-1, 9, -1],
|
296 |
+
[-1, -1, -1]]) * strength
|
297 |
+
|
298 |
+
# Apply convolution
|
299 |
+
sharpened = cv2.filter2D(frame, -1, kernel)
|
300 |
+
|
301 |
+
# Blend with original based on strength
|
302 |
+
alpha = min(1.0, abs(strength - 1.0))
|
303 |
+
frame = alpha * sharpened + (1 - alpha) * frame
|
304 |
+
|
305 |
+
return np.clip(frame, 0, 1)
|
306 |
+
|
307 |
+
def apply_filter(self, frame):
|
308 |
+
"""Apply selected filter preset to the frame.
|
309 |
+
|
310 |
+
Args:
|
311 |
+
frame: Input frame (float32, 0-1 range)
|
312 |
+
|
313 |
+
Returns:
|
314 |
+
Filtered frame (float32, 0-1 range)
|
315 |
+
"""
|
316 |
+
if self.filter_preset == "vivid":
|
317 |
+
# Boost saturation and contrast
|
318 |
+
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
|
319 |
+
hsv[..., 1] = hsv[..., 1] * 1.5 # Increase saturation
|
320 |
+
frame = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
|
321 |
+
frame = np.clip(frame, 0, 1)
|
322 |
+
|
323 |
+
elif self.filter_preset == "cinematic":
|
324 |
+
# Add a slight blue tint and reduce brightness
|
325 |
+
frame[..., 0] = frame[..., 0] * 0.9 # Reduce blue slightly
|
326 |
+
frame[..., 2] = frame[..., 2] * 1.1 # Increase red slightly
|
327 |
+
frame = frame * 0.9 # Darken slightly
|
328 |
+
frame = np.clip(frame, 0, 1)
|
329 |
+
|
330 |
+
elif self.filter_preset == "blackwhite":
|
331 |
+
# Convert to grayscale then back to BGR for consistent processing
|
332 |
+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
333 |
+
frame = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
|
334 |
+
|
335 |
+
return frame
|
336 |
+
|
337 |
+
def process_video(self, input_path, output_path):
|
338 |
+
"""Process the entire video file with the current settings.
|
339 |
+
|
340 |
+
Args:
|
341 |
+
input_path: Path to input video file
|
342 |
+
output_path: Path to save enhanced video file
|
343 |
+
|
344 |
+
Returns:
|
345 |
+
Processing time in seconds
|
346 |
+
"""
|
347 |
+
start_time = time.time()
|
348 |
+
|
349 |
+
# Load the video
|
350 |
+
clip = VideoFileClip(input_path)
|
351 |
+
|
352 |
+
# Define the processing function for each frame
|
353 |
+
def process_frame(frame):
|
354 |
+
return self.apply_enhancements(frame)
|
355 |
+
|
356 |
+
# Apply the processing to each frame
|
357 |
+
enhanced_clip = clip.fl_image(process_frame)
|
358 |
+
|
359 |
+
# Write the result to a file
|
360 |
+
enhanced_clip.write_videofile(
|
361 |
+
output_path,
|
362 |
+
codec='libx264',
|
363 |
+
audio_codec='aac',
|
364 |
+
threads=4,
|
365 |
+
fps=clip.fps,
|
366 |
+
bitrate=f"{int(clip.size[0] * clip.size[1] * clip.fps * 0.1)}k"
|
367 |
+
)
|
368 |
+
|
369 |
+
# Close the clips
|
370 |
+
clip.close()
|
371 |
+
enhanced_clip.close()
|
372 |
+
|
373 |
+
return time.time() - start_time
|
374 |
+
|
375 |
+
def main():
|
376 |
+
"""Main function to demonstrate the video enhancement."""
|
377 |
+
print("U.F. AI Enhancer - Video Quality Improvement Tool")
|
378 |
+
print("-----------------------------------------------")
|
379 |
+
|
380 |
+
# Initialize enhancer
|
381 |
+
enhancer = VideoEnhancer()
|
382 |
+
|
383 |
+
# Get input file
|
384 |
+
input_file = input("Enter path to input video file: ").strip('"')
|
385 |
+
if not os.path.exists(input_file):
|
386 |
+
print("Error: File not found!")
|
387 |
+
return
|
388 |
+
|
389 |
+
# Set output file
|
390 |
+
output_file = os.path.splitext(input_file)[0] + "_enhanced.mp4"
|
391 |
+
|
392 |
+
# Get enhancement settings from user
|
393 |
+
print("\nEnhancement Settings (press Enter for defaults)")
|
394 |
+
print("--------------------------------------------")
|
395 |
+
|
396 |
+
try:
|
397 |
+
brightness = input(f"Brightness (-100 to 100) [default {enhancer.brightness}]: ")
|
398 |
+
if brightness: enhancer.brightness = int(brightness)
|
399 |
+
|
400 |
+
contrast = input(f"Contrast (-100 to 100) [default {enhancer.contrast}]: ")
|
401 |
+
if contrast: enhancer.contrast = int(contrast)
|
402 |
+
|
403 |
+
sharpness = input(f"Sharpness (0 to 100) [default {enhancer.sharpness}]: ")
|
404 |
+
if sharpness: enhancer.sharpness = int(sharpness)
|
405 |
+
|
406 |
+
print("\nFilter Presets:")
|
407 |
+
print("1. None (default)")
|
408 |
+
print("2. Vivid Colors")
|
409 |
+
print("3. Cinematic")
|
410 |
+
print("4. Black & White")
|
411 |
+
filter_choice = input("Select filter (1-4) [default 1]: ")
|
412 |
+
if filter_choice == "2": enhancer.filter_preset = "vivid"
|
413 |
+
elif filter_choice == "3": enhancer.filter_preset = "cinematic"
|
414 |
+
elif filter_choice == "4": enhancer.filter_preset = "blackwhite"
|
415 |
+
|
416 |
+
# Process the video
|
417 |
+
print("\nProcessing video... This may take some time depending on video length.")
|
418 |
+
processing_time = enhancer.process_video(input_file, output_file)
|
419 |
+
|
420 |
+
print(f"\nProcessing complete! Enhanced video saved to: {output_file}")
|
421 |
+
print(f"Processing time: {processing_time:.2f} seconds")
|
422 |
+
|
423 |
+
except ValueError:
|
424 |
+
print("Error: Invalid input! Please enter numbers only for settings.")
|
425 |
+
except Exception as e:
|
426 |
+
print(f"An error occurred: {str(e)}")
|
427 |
+
|
428 |
+
if __name__ == "__main__":
|
429 |
+
main()</code></pre>
|
430 |
+
</div>
|
431 |
+
|
432 |
+
<div class="bg-white rounded-xl shadow-lg p-6">
|
433 |
+
<h3 class="text-xl font-semibold mb-4 text-gray-800">Requirements</h3>
|
434 |
+
<p class="text-gray-600 mb-4">To run this tool, you'll need to install the following Python packages:</p>
|
435 |
+
<div class="code-block p-4 mb-4">
|
436 |
+
<code>pip install opencv-python numpy moviepy</code>
|
437 |
+
</div>
|
438 |
+
<p class="text-gray-600">For better performance, you can also install FFmpeg:</p>
|
439 |
+
<div class="code-block p-4">
|
440 |
+
<code># On Windows: choco install ffmpeg<br># On macOS: brew install ffmpeg<br># On Linux (Debian/Ubuntu): sudo apt install ffmpeg</code>
|
441 |
+
</div>
|
442 |
+
</div>
|
443 |
+
</section>
|
444 |
+
</main>
|
445 |
+
|
446 |
+
<footer class="gradient-bg text-white py-8">
|
447 |
+
<div class="container mx-auto px-4">
|
448 |
+
<div class="flex flex-col md:flex-row justify-between items-center">
|
449 |
+
<div class="mb-4 md:mb-0">
|
450 |
+
<h2 class="text-xl font-bold flex items-center">
|
451 |
+
<i class="fas fa-robot mr-2"></i> U.F. AI Enhancer
|
452 |
+
</h2>
|
453 |
+
<p class="text-gray-200 mt-2">Offline AI-powered video enhancement tool</p>
|
454 |
+
</div>
|
455 |
+
<div class="flex space-x-6">
|
456 |
+
<a href="#" class="text-white hover:text-gray-200 transition">
|
457 |
+
<i class="fab fa-github text-2xl"></i>
|
458 |
+
</a>
|
459 |
+
<a href="#" class="text-white hover:text-gray-200 transition">
|
460 |
+
<i class="fab fa-twitter text-2xl"></i>
|
461 |
+
</a>
|
462 |
+
<a href="#" class="text-white hover:text-gray-200 transition">
|
463 |
+
<i class="fab fa-youtube text-2xl"></i>
|
464 |
+
</a>
|
465 |
+
</div>
|
466 |
+
</div>
|
467 |
+
<div class="border-t border-gray-400 mt-8 pt-6 text-center text-gray-200">
|
468 |
+
<p>© 2023 U.F. AI Enhancer. All rights reserved.</p>
|
469 |
+
</div>
|
470 |
+
</div>
|
471 |
+
</footer>
|
472 |
+
|
473 |
+
<script>
|
474 |
+
// UI Functionality
|
475 |
+
document.getElementById('upload-btn').addEventListener('click', function() {
|
476 |
+
document.getElementById('video-input').click();
|
477 |
+
});
|
478 |
+
|
479 |
+
document.getElementById('video-input').addEventListener('change', function(e) {
|
480 |
+
const file = e.target.files[0];
|
481 |
+
if (file) {
|
482 |
+
const videoPreview = document.getElementById('video-preview');
|
483 |
+
const videoPlaceholder = document.getElementById('video-placeholder');
|
484 |
+
|
485 |
+
videoPreview.src = URL.createObjectURL(file);
|
486 |
+
videoPreview.classList.remove('hidden');
|
487 |
+
videoPlaceholder.classList.add('hidden');
|
488 |
+
|
489 |
+
document.getElementById('process-btn').disabled = false;
|
490 |
+
}
|
491 |
+
});
|
492 |
+
|
493 |
+
document.getElementById('process-btn').addEventListener('click', function() {
|
494 |
+
// Show processing animation
|
495 |
+
const processBtn = this;
|
496 |
+
const originalText = processBtn.innerHTML;
|
497 |
+
|
498 |
+
processBtn.innerHTML = '<div class="processing-loader"></div>';
|
499 |
+
processBtn.disabled = true;
|
500 |
+
|
501 |
+
// Simulate processing (in a real app, this would call the Python backend)
|
502 |
+
setTimeout(function() {
|
503 |
+
processBtn.innerHTML = originalText;
|
504 |
+
processBtn.disabled = false;
|
505 |
+
|
506 |
+
// Show success message
|
507 |
+
alert('Video processing complete! In a real implementation, this would download the enhanced video.');
|
508 |
+
}, 3000);
|
509 |
+
});
|
510 |
+
|
511 |
+
// Update slider value displays
|
512 |
+
const sliders = ['brightness', 'contrast', 'sharpness'];
|
513 |
+
sliders.forEach(sliderId => {
|
514 |
+
const slider = document.getElementById(sliderId);
|
515 |
+
slider.addEventListener('input', function() {
|
516 |
+
// In a real app, you might update a preview here
|
517 |
+
});
|
518 |
+
});
|
519 |
+
</script>
|
520 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Notmebug/u-f-ai-enhancer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
521 |
+
</html>
|
prompts.txt
ADDED
File without changes
|