Skip to content

Commit 29aa0c9

Browse files
committed
Updated requirements.txt, added data collection script
1 parent b7b3719 commit 29aa0c9

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

data_collection.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
###############################################################################
2+
#
3+
# File: store_images.py
4+
#
5+
# Author: Isaac Ingram
6+
#
7+
# Purpose: Store an image stream from a website to the local disk.
8+
#
9+
# Usage: This program requires the requests library to be installed.
10+
# To use, provide two commandline arguments: <URL> and <path>. 'URL' is the URL
11+
# to requests content from. 'path' is the relative or absolute path to where
12+
# the images should be placed on your system.
13+
#
14+
###############################################################################
15+
import sys
16+
from datetime import datetime
17+
18+
import requests
19+
20+
21+
def print_usage_and_exit() -> None:
22+
"""
23+
Print the usage statement and exit.
24+
:return: None
25+
"""
26+
print("Usage: store_images.py <URL> <path>")
27+
exit(0)
28+
29+
30+
def main():
31+
try:
32+
while(True):
33+
# Check command line args
34+
if len(sys.argv) != 3:
35+
print_usage_and_exit()
36+
url = sys.argv[1]
37+
storage_path = sys.argv[2]
38+
# Get rid of last character in path if it's a slash
39+
if storage_path[-1] == "/":
40+
storage_path = storage_path[:-1]
41+
try:
42+
image_data = requests.get(url).content
43+
img_name = f'{storage_path}/{datetime.now().strftime("%S-%M-%H-%d-%m-%Y.jpg")}'
44+
with open(img_name, 'wb') as image_file:
45+
image_file.write(image_data)
46+
except Exception as e:
47+
print(f"Failed to download from {url}: {e}")
48+
except KeyboardInterrupt:
49+
print("Program interrupted by user. Exiting...")
50+
51+
52+
if __name__ == '__main__':
53+
main()

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ matplotlib==3.10.0
2424
matplotlib-inline==0.1.7
2525
mpmath==1.3.0
2626
networkx==3.4.2
27-
numpy==1.23.5
27+
numpy
2828
opencv-python==4.11.0.86
2929
packaging==24.2
3030
paho-mqtt==2.1.0
@@ -54,8 +54,8 @@ sympy==1.13.1
5454
tensorboard==2.19.0
5555
tensorboard-data-server==0.7.2
5656
threadpoolctl==3.6.0
57-
torch==2.5.1
58-
torchvision==0.20.1
57+
torch
58+
torchvision
5959
tqdm==4.67.1
6060
traitlets==5.14.3
6161
typing_extensions==4.12.2
@@ -64,4 +64,4 @@ ultralytics==8.3.111
6464
ultralytics-thop==2.0.14
6565
urllib3==2.3.0
6666
wcwidth==0.2.13
67-
Werkzeug==3.1.3
67+
Werkzeug==3.1.3

0 commit comments

Comments
 (0)