Spaces:
Running
Running
Fix screenshot case (#2)
Browse files- Fix screenshot case (3d2275a48a81590a56b66a0641e6f97cf1f8e03f)
Co-authored-by: Joya Chen <[email protected]>
infer.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
# Copyright (2025) [Seed-VL-Cookbook] Bytedance Seed
|
|
|
2 |
import json
|
3 |
import time
|
4 |
import math
|
@@ -9,8 +10,8 @@ import torch
|
|
9 |
import decord
|
10 |
import numpy as np
|
11 |
from PIL import Image, ImageSequence
|
12 |
-
from torchvision.io import read_image, encode_jpeg
|
13 |
-
from torchvision.transforms.functional import resize
|
14 |
from torchvision.transforms import InterpolationMode
|
15 |
|
16 |
|
@@ -210,7 +211,18 @@ class SeedVLInfer:
|
|
210 |
},
|
211 |
})
|
212 |
else:
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
if online and path.endswith('.webp'):
|
215 |
streaming_timestamp = i
|
216 |
if streaming_timestamp is not None:
|
|
|
1 |
# Copyright (2025) [Seed-VL-Cookbook] Bytedance Seed
|
2 |
+
import cv2
|
3 |
import json
|
4 |
import time
|
5 |
import math
|
|
|
10 |
import decord
|
11 |
import numpy as np
|
12 |
from PIL import Image, ImageSequence
|
13 |
+
from torchvision.io import read_image, encode_jpeg
|
14 |
+
from torchvision.transforms.functional import resize, pil_to_tensor
|
15 |
from torchvision.transforms import InterpolationMode
|
16 |
|
17 |
|
|
|
211 |
},
|
212 |
})
|
213 |
else:
|
214 |
+
try:
|
215 |
+
image = read_image(path, "RGB")
|
216 |
+
except:
|
217 |
+
try:
|
218 |
+
image = pil_to_tensor(Image.open(path).convert('RGB'))
|
219 |
+
except:
|
220 |
+
image = torch.from_numpy(
|
221 |
+
cv2.cvtColor(
|
222 |
+
cv2.imread(path),
|
223 |
+
cv2.COLOR_BGR2RGB
|
224 |
+
)
|
225 |
+
).permute(2, 0, 1)
|
226 |
if online and path.endswith('.webp'):
|
227 |
streaming_timestamp = i
|
228 |
if streaming_timestamp is not None:
|