ghostsInTheMachine
commited on
Commit
•
855f2e9
1
Parent(s):
8324267
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ from PIL import Image
|
|
10 |
import moviepy.editor as mp
|
11 |
from infer import lotus # Import the depth model inference function
|
12 |
import logging
|
|
|
13 |
|
14 |
# Set up logging
|
15 |
logging.basicConfig(level=logging.INFO)
|
@@ -25,7 +26,7 @@ def preprocess_video(video_path, target_fps=24, max_resolution=(1920, 1080)):
|
|
25 |
|
26 |
# Resize video if it's larger than the target resolution
|
27 |
if video.size[0] > max_resolution[0] or video.size[1] > max_resolution[1]:
|
28 |
-
video = video.resize(
|
29 |
|
30 |
# Adjust FPS if target_fps is specified
|
31 |
if target_fps > 0:
|
@@ -41,8 +42,13 @@ def process_frame(image, seed=0):
|
|
41 |
torch.manual_seed(seed)
|
42 |
np.random.seed(seed)
|
43 |
|
44 |
-
#
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
# Convert depth output to numpy array
|
48 |
depth_array = np.array(output_d)
|
@@ -161,33 +167,7 @@ def process_wrapper(video, fps=0, seed=0, batch_size=16):
|
|
161 |
|
162 |
# Custom CSS for styling
|
163 |
custom_css = """
|
164 |
-
|
165 |
-
text-align: center;
|
166 |
-
padding: 10px 0;
|
167 |
-
}
|
168 |
-
|
169 |
-
#title {
|
170 |
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
171 |
-
font-size: 36px;
|
172 |
-
font-weight: bold;
|
173 |
-
color: #000000;
|
174 |
-
padding: 10px;
|
175 |
-
border-radius: 10px;
|
176 |
-
display: inline-block;
|
177 |
-
background: linear-gradient(
|
178 |
-
135deg,
|
179 |
-
#e0f7fa, #e8f5e9, #fff9c4, #ffebee,
|
180 |
-
#f3e5f5, #e1f5fe, #fff3e0, #e8eaf6
|
181 |
-
);
|
182 |
-
background-size: 400% 400%;
|
183 |
-
animation: gradient-animation 15s ease infinite;
|
184 |
-
}
|
185 |
-
|
186 |
-
@keyframes gradient-animation {
|
187 |
-
0% { background-position: 0% 50%; }
|
188 |
-
50% { background-position: 100% 50%; }
|
189 |
-
100% { background-position: 0% 50%; }
|
190 |
-
}
|
191 |
"""
|
192 |
|
193 |
# Gradio Interface
|
|
|
10 |
import moviepy.editor as mp
|
11 |
from infer import lotus # Import the depth model inference function
|
12 |
import logging
|
13 |
+
import io # Import io module
|
14 |
|
15 |
# Set up logging
|
16 |
logging.basicConfig(level=logging.INFO)
|
|
|
26 |
|
27 |
# Resize video if it's larger than the target resolution
|
28 |
if video.size[0] > max_resolution[0] or video.size[1] > max_resolution[1]:
|
29 |
+
video = video.resize(height=max_resolution[1])
|
30 |
|
31 |
# Adjust FPS if target_fps is specified
|
32 |
if target_fps > 0:
|
|
|
42 |
torch.manual_seed(seed)
|
43 |
np.random.seed(seed)
|
44 |
|
45 |
+
# Save image to an in-memory file
|
46 |
+
img_bytes = io.BytesIO()
|
47 |
+
image.save(img_bytes, format='PNG')
|
48 |
+
img_bytes.seek(0) # Reset file pointer to the beginning
|
49 |
+
|
50 |
+
# Process through the depth model
|
51 |
+
_, output_d = lotus(img_bytes, 'depth', seed, device)
|
52 |
|
53 |
# Convert depth output to numpy array
|
54 |
depth_array = np.array(output_d)
|
|
|
167 |
|
168 |
# Custom CSS for styling
|
169 |
custom_css = """
|
170 |
+
/* Your existing custom CSS */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
"""
|
172 |
|
173 |
# Gradio Interface
|