changed floating point 16
Browse files- owl_core.py +7 -4
owl_core.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import torch
|
|
|
2 |
from tqdm import tqdm
|
3 |
import cv2
|
4 |
import os
|
@@ -47,8 +48,6 @@ def owl_full_video(
|
|
47 |
threshold: float,
|
48 |
fps_processed: int = 1,
|
49 |
scaling_factor: float = 0.5,
|
50 |
-
processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble"),
|
51 |
-
model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").to('cuda'),
|
52 |
device: str = 'cuda',
|
53 |
batch_size: int = 6,
|
54 |
):
|
@@ -56,10 +55,14 @@ def owl_full_video(
|
|
56 |
Saves results per frame to a df.
|
57 |
"""
|
58 |
|
|
|
|
|
|
|
|
|
59 |
# create new dirs and paths for results
|
60 |
filename = os.path.splitext(os.path.basename(vid_path))[0]
|
61 |
-
results_dir = f'../temp/{filename}_{datetime.now().strftime("%H%M%S")}'
|
62 |
-
|
63 |
frames_dir = os.path.join(results_dir, "frames")
|
64 |
|
65 |
# if the frames directory does not exist, create it and get the frames from the video
|
|
|
1 |
import torch
|
2 |
+
import torch.quantization
|
3 |
from tqdm import tqdm
|
4 |
import cv2
|
5 |
import os
|
|
|
48 |
threshold: float,
|
49 |
fps_processed: int = 1,
|
50 |
scaling_factor: float = 0.5,
|
|
|
|
|
51 |
device: str = 'cuda',
|
52 |
batch_size: int = 6,
|
53 |
):
|
|
|
55 |
Saves results per frame to a df.
|
56 |
"""
|
57 |
|
58 |
+
processor = Owlv2Processor.from_pretrained("google/owlv2-base-patch16-ensemble")
|
59 |
+
model = Owlv2ForObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble").half().to('cuda')
|
60 |
+
|
61 |
+
|
62 |
# create new dirs and paths for results
|
63 |
filename = os.path.splitext(os.path.basename(vid_path))[0]
|
64 |
+
# results_dir = f'../temp/{filename}_{datetime.now().strftime("%H%M%S")}' # run this on server
|
65 |
+
results_dir = f'temp/{filename}_{datetime.now().strftime("%H%M%S")}' # run this on local
|
66 |
frames_dir = os.path.join(results_dir, "frames")
|
67 |
|
68 |
# if the frames directory does not exist, create it and get the frames from the video
|