Upload modeling_tara.py with huggingface_hub
Browse files- modeling_tara.py +20 -0
modeling_tara.py
CHANGED
|
@@ -350,6 +350,26 @@ def read_frames_decord(
|
|
| 350 |
del video_reader
|
| 351 |
|
| 352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
if __name__ == "__main__":
|
| 354 |
|
| 355 |
# Load model
|
|
|
|
| 350 |
del video_reader
|
| 351 |
|
| 352 |
|
| 353 |
+
import PIL.Image
|
| 354 |
+
def read_image_decord(image_path):
|
| 355 |
+
image = PIL.Image.open(image_path)
|
| 356 |
+
image = image.convert('RGB')
|
| 357 |
+
image = np.array(image)
|
| 358 |
+
image = image.transpose(2, 0, 1)
|
| 359 |
+
image = torch.from_numpy(image)
|
| 360 |
+
image = image.unsqueeze(0)
|
| 361 |
+
return image
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
def read_images_decord(image_paths):
|
| 365 |
+
images = []
|
| 366 |
+
for image_path in image_paths:
|
| 367 |
+
image = read_image_decord(image_path)
|
| 368 |
+
images.append(image)
|
| 369 |
+
images = torch.cat(images)
|
| 370 |
+
return images
|
| 371 |
+
|
| 372 |
+
|
| 373 |
if __name__ == "__main__":
|
| 374 |
|
| 375 |
# Load model
|