Skip to content

Commit 7821bf1

Browse files
author
Ruilong Li
committed
expose aug_matrix
1 parent 25dea80 commit 7821bf1

File tree

3 files changed

+6
-61
lines changed

3 files changed

+6
-61
lines changed

README.md

+4-60
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,25 @@ Pytorch based data streamer. (Capture, Video & Image).
55
## Install
66

77
```
8-
pip install git+https://github.com/liruilong940607/streamer_pytorch --upgrade
8+
pip install git+https://github.com/Project-Splinter/streamer_pytorch --upgrade
99
```
1010

1111
## Usage
1212

1313
```
1414
# images
1515
python demo.py --images <IMAGE_PATH> <IMAGE_PATH> <IMAGE_PATH> --loop --vis
16+
# image folder
17+
python demo.py --image_folder <IMAGE_FOLDER_PATH> --loop --vis
1618
# videos
1719
python demo.py --videos <VIDEO_PATH> <VIDEO_PATH> <VIDEO_PATH> --vis
1820
# capture device
1921
python demo.py --camera --vis
2022
```
2123

22-
see also in `demo.py`
23-
```
24-
import tqdm
25-
import argparse
26-
import torch
27-
import numpy as np
28-
import cv2
29-
import streamer_pytorch as streamer
30-
31-
parser = argparse.ArgumentParser(description='.')
32-
parser.add_argument(
33-
'--camera', action="store_true")
34-
parser.add_argument(
35-
'--images', default="", nargs="*")
36-
parser.add_argument(
37-
'--videos', default="", nargs="*")
38-
parser.add_argument(
39-
'--loop', action="store_true")
40-
parser.add_argument(
41-
'--vis', action="store_true")
42-
args = parser.parse_args()
43-
44-
def visulization(data):
45-
window = data[0].numpy()
46-
window = window.transpose(1, 2, 0)
47-
window = (window * 0.5 + 0.5) * 255.0
48-
window = np.uint8(window)
49-
window = cv2.cvtColor(window, cv2.COLOR_BGR2RGB)
50-
window = cv2.resize(window, (0, 0), fx=2, fy=2)
51-
52-
cv2.imshow('window', window)
53-
cv2.waitKey(1)
54-
55-
if args.camera:
56-
data_stream = streamer.CaptureStreamer()
57-
elif len(args.videos) > 0:
58-
data_stream = streamer.VideoListStreamer(
59-
args.videos * (100 if args.loop else 1))
60-
elif len(args.images) > 0:
61-
data_stream = streamer.ImageListStreamer(
62-
args.images * (100 if args.loop else 1))
63-
64-
loader = torch.utils.data.DataLoader(
65-
data_stream,
66-
batch_size=1,
67-
num_workers=1,
68-
pin_memory=False,
69-
)
70-
71-
try:
72-
for data in tqdm.tqdm(loader):
73-
if args.vis:
74-
visulization(data)
75-
except Exception as e:
76-
print (e)
77-
del data_stream
78-
79-
```
80-
8124
## API
8225

8326
- CaptureStreamer(id=0, width=512, height=512, pad=True)
8427
- VideoListStreamer(files, width=512, height=512, pad=True)
8528
- ImageListStreamer(files, width=512, height=512, pad=True)
29+
- aug_matrix(w1, h1, w2, h2, pad=True)

demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
parser.add_argument(
1414
'--images', default="", nargs="*", help="paths of image.")
1515
parser.add_argument(
16-
'--image_folder', default="", help="path of image folder.")
16+
'--image_folder', default=None, help="path of image folder.")
1717
parser.add_argument(
1818
'--videos', default="", nargs="*", help="paths of video.")
1919
parser.add_argument(

streamer_pytorch/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
from .streamer import CaptureStreamer
33
from .streamer import VideoListStreamer
44
from .streamer import ImageListStreamer
5+
from .streamer import aug_matrix

0 commit comments

Comments
 (0)