Skip to content

Commit c350792

Browse files
authored
Merge pull request #56 from duggalsu/cpu_profiling
Add cpu profiling and optimize operator
2 parents 9d7fb86 + 95a2959 commit c350792

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

src/api/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
credentials.json
2+
3+
# memray
24
*.bin
35
*.html
6+
7+
# pyinstrument
8+
*.json

src/api/core/operators/vid_vec_rep_resnet.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
def initialize(param):
44
print("Installing packages for vid_vec_rep_resnet")
55

6-
global TextBlob, os, np, cv2, qr, torch, data, models, transforms, Image, FFmpeg, wget
7-
global imagenet_transform, ImageListDataset, VideoAnalyzer, gendata, compress_video
6+
global TextBlob, os, np, cv2, qr, torch, data, models, transforms, Image, wget #, FFmpeg
7+
global imagenet_transform, ImageListDataset, VideoAnalyzer, gendata #, compress_video
88

99
import os
1010
import numpy as np
@@ -15,7 +15,7 @@ def initialize(param):
1515
import torchvision.models as models
1616
import torchvision.transforms as transforms
1717
from PIL import Image
18-
from ffmpy import FFmpeg
18+
# from ffmpy import FFmpeg
1919
import wget
2020

2121
imagenet_transform = transforms.Compose(
@@ -26,6 +26,7 @@ def initialize(param):
2626
]
2727
)
2828

29+
'''
2930
def compress_video(fname):
3031
newname = "/tmp/compressed.mp4"
3132
FNULL = open(os.devnull, "w")
@@ -38,6 +39,8 @@ def compress_video(fname):
3839
ff.run(stdout=FNULL, stderr=FNULL)
3940
# os.remove(fname)
4041
return newname
42+
'''
43+
4144

4245
def gendata(vid_analyzer):
4346
# average vector
@@ -205,11 +208,11 @@ def run(file):
205208
fname = file["path"]
206209
fsize = os.path.getsize(fname) / 1e6
207210
print("original size: ", fsize)
208-
if fsize < 10:
209-
print("compressing video")
210-
fname = compress_video(fname)
211-
fsize = os.path.getsize(fname) / 1e6
212-
print("compressed video size: ", fsize)
211+
# if fsize < 10:
212+
# print("compressing video")
213+
# fname = compress_video(fname)
214+
# fsize = os.path.getsize(fname) / 1e6
215+
# print("compressed video size: ", fsize)
213216
if fsize > 10:
214217
raise Exception("Video too large")
215218

@@ -219,7 +222,7 @@ def run(file):
219222

220223
doable, error_msg = vid_analyzer.check_constraints()
221224

222-
os.remove(fname)
225+
# os.remove(fname)
223226

224227
if not doable:
225228
raise "Unsupported Video. Cannot index video."

src/api/core/operators/vid_vec_rep_resnet_requirements.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ torch==2.1.2+cpu
22
torchvision==0.16.2+cpu
33
numpy==1.26.3
44
wget==3.2
5-
ffmpy==0.3.1
65
Pillow==10.2.0
76
scipy==1.11.4
87
opencv-python-headless==4.9.0.80

src/api/core/operators/vid_vec_rep_resnet_requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ certifi==2023.11.17
1010
# via requests
1111
charset-normalizer==3.3.2
1212
# via requests
13-
ffmpy==0.3.1
14-
# via -r vid_vec_rep_resnet_requirements.in
1513
filelock==3.13.1
1614
# via torch
1715
fsspec==2023.12.2

src/api/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ pytest==7.4.4
2222
PyYAML==6.0.1
2323
dacite==1.8.1
2424
memray==1.11.0 # dev
25+
pyinstrument==4.6.2

src/api/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ pyasn1-modules==0.2.8
171171
# via google-auth
172172
pygments==2.17.2
173173
# via rich
174+
pyinstrument==4.6.2
175+
# via -r requirements.in
174176
pytest==7.4.4
175177
# via -r requirements.in
176178
python-dateutil==2.8.1

0 commit comments

Comments
 (0)