Spaces:
Running
on
Zero
Running
on
Zero
update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
from transformers import pipeline
|
| 5 |
import os
|
|
@@ -86,9 +87,11 @@ def make_video(video_path, outdir='./vis_video_depth',encoder='vitl'):
|
|
| 86 |
frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2RGB) / 255.0
|
| 87 |
|
| 88 |
frame = transform({'image': frame})['image']
|
|
|
|
| 89 |
frame = torch.from_numpy(frame).unsqueeze(0).to(DEVICE)
|
| 90 |
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
depth = F.interpolate(depth[None], (frame_height, frame_width), mode='bilinear', align_corners=False)[0, 0]
|
| 94 |
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
+
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
from transformers import pipeline
|
| 6 |
import os
|
|
|
|
| 87 |
frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2RGB) / 255.0
|
| 88 |
|
| 89 |
frame = transform({'image': frame})['image']
|
| 90 |
+
frame_pil = Image.fromarray(np.uint8(frame)).convert('RGB')
|
| 91 |
frame = torch.from_numpy(frame).unsqueeze(0).to(DEVICE)
|
| 92 |
|
| 93 |
+
|
| 94 |
+
depth = predict_depth(depth_anything, frame_pil)
|
| 95 |
|
| 96 |
depth = F.interpolate(depth[None], (frame_height, frame_width), mode='bilinear', align_corners=False)[0, 0]
|
| 97 |
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
|