Skip to content

Instantly share code, notes, and snippets.

View Mahmood-Hussain's full-sized avatar
🎯
Focusing

Mahmood Hussain Bhat Mahmood-Hussain

🎯
Focusing
View GitHub Profile

Instaling opencart 3.0.3.8 on Ubuntu 20.04, PHP 7.4, Apache2

Install PHP and its dependencies

sudo apt update
sudo apt -y install software-properties-common
@Mahmood-Hussain
Mahmood-Hussain / remove_difficult_objects.py
Created November 21, 2022 03:24
This code snippet is to remove labels (bounding boxes) marked as difficult in RTTS dataset. Please replace label_dir with original labels directory and out_dir is where to save newly modified labels.
import os
import xml.etree.ElementTree as ET
label_dir = '/home/mahmood/Downloads/RTTS/labels_original'
out_dir = '/home/mahmood/Downloads/RTTS/labels'
label_file_paths = os.listdir(label_dir)
print(f'Processing ...')
total_difficult = 0
@Mahmood-Hussain
Mahmood-Hussain / reorganize_yolo_class_labels.py
Last active October 6, 2022 02:19
Reorganize/Change indexes of yolo format class labels into new indices. This script could be useful when you have two datasets in yolo(5,...) format with same labels but those labels for two datasets are at different indexes which makes it difficult to test or train on same datasets so this script could be handy in those situations.
# yolo label format: class x_center y_center width height
import glob
def change_labels_index(labels_path, new_class_mappings):
"""Change the index of labels to match the new class mappings for yolo"""
for label_file in glob.glob(labels_path + "/*.txt"):
with open(label_file, "r") as f:
lines = f.readlines()
with open(label_file, "w") as f:
for line in lines:
@Mahmood-Hussain
Mahmood-Hussain / copyormoverec.py
Last active September 1, 2022 05:11
Move or Copy files form source directory to destination directory with progress using python
import glob
import os
import argparse
parser = argparse.ArgumentParser(description='Copy or move files')
parser.add_argument('--source', help='Source directory', type=str)
parser.add_argument('--dest', help='Destination directory', type=str)
parser.add_argument('-r', '--recursive', action='store_true', help='Recursive if you want to scan sub directories recursively', default=True)
parser.add_argument('-e', '--extensions', nargs='+', help='Extensions allowed', default=['jpg', 'png', 'gif'])
parser.add_argument('-c', '--copy', action='store_true', help='Copy files or move files default is copy files', default=True)