This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import pandas as pd | |
# Data from: https://publish.obsidian.md/vg-layoffs/Archive/2024 | |
# The data is stored in a directory with one CSV per year. Change the directory name accordingly | |
path = './data/gaming-layoff/' | |
all_files = glob.glob(os.path.join(path, "*.csv")) # advisable to use os.path.join as this makes concatenation OS independent | |
# Load all the CSVs into a single dataframe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Data from Our World in Data (https://ourworldindata.org/grapher/ghg-emissions-by-sector) | |
df = pd.read_csv('data/ghg-emissions-by-sector.csv') | |
df_grouped = ( | |
df | |
.drop(columns=["Entity", "Code"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def updateSpaces(db, parking_id, spaces_taken): | |
doc_ref = db.collection(u'parklots').document(parking_id) | |
doc_ref.update({ | |
u'occupied_parking_spaces': spaces_taken | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parser.add_argument('--image', help='Path to image file.') | |
parser.add_argument('--video', help='Path to video file.') | |
parser.add_argument('--streaming', help='Path to video url') | |
def load_open_cv_capture(args): | |
if args.image: | |
# Open the image file | |
file_does_not_exist(args.image) | |
cap = cv.VideoCapture(args.image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_parked_car(bounding_box, bounding_boxes_history, current_frame_idx, look_at_past_n, detection_ratio): | |
""" | |
Determine if car is detected as parked | |
:param bounding_box: Tuple of pixel positions (left, top, right, bottom) | |
:param bounding_boxes_history: List of bounding box including frame number (frame_id, left, top, right, bottom) | |
:param current_frame_idx: Index of current frame | |
:param look_at_past_n: Number of frame to consider for classification | |
:param detection_ratio: Minimum ratio to classify a car as parked | |
:return: boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_center_coords(bounding_box): | |
left, top, width, height = bounding_box | |
center_coord_y = int(left + width / 2.) | |
center_coord_x = int(top + height / 2.) | |
return center_coord_x, center_coord_y | |
def get_shortest_side_lenght(bounding_box): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_car(class_name): | |
return class_name in str(["car", "truck", "bus"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for filename in $1/*; do | |
./darknet detect cfg/yolov3.cfg weights/yolov3.weights "$filename" -out "out_$(basename "$filename")" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
git clone https://github.com/sowson/darknet.git | |
cd darknet | |
make | |
mkdir -p weights | |
wget https://pjreddie.com/media/files/yolov3.weights -O ./weights/yolov3.weights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GOPATH=$HOME/Go | |
export GOROOT=/usr/local/opt/go/libexec | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=$PATH:$GOROOT/bin | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
. $(brew --prefix)/etc/bash_completion | |
fi | |
if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ]; then |
NewerOlder