Skip to content

Instantly share code, notes, and snippets.

@iamarchisha
iamarchisha / ODjson_from_csv.js
Last active March 11, 2021 07:29
JS script to prepare json files for performing object detection on AWS Sage Maker. It needs a csv input containing: image_name with extensions (str), img-height (int) , img-width (int), depth (int), left (int), top (int), width (int), height (int), label (str), label_id (int). This csv can have duplicate image_path value to represent different o…
const fs = require("fs");
const path = require("path");
const csv = require("fast-csv");
let megaJSON = {}; //will contain a json of multiple jsons
let aws_s3_URL = "<s3-data-url>"; //s3 url
// csv header image_path,img-height,img-width,depth,left,top,width,height,label,label_id
// csv can have duplicate image_path for multiple ODs (left,top,width,height) in one image
// <"image-name-1"> | 200 | 300 | 3 | 45 | 100 | 56 | 200 | <"label-1"> | 0
// <"image-name-1"> | 200 | 300 | 3 | 50 | 200 | 70 | 300 | <"label-2"> | 1
@iamarchisha
iamarchisha / move_s3_file.py
Created March 20, 2021 08:39
To copy files belonging to a category with a keyword present, from one AWS S3 bucket to another.
import os
import boto3
# Get all the keys in S3 bucket
def get_matching_s3_keys(bucket, prefix='', suffix=''):
"""
Generate the keys in an S3 bucket.
Args:
bucket (str): Name of the S3 bucket.
@iamarchisha
iamarchisha / manifest_pascal.py
Last active July 10, 2021 03:13
Ground Truth Manifest to PASCAL format. The manifest must be converted to a numpy "npy" file and the categories must also be stored as "npy" file. Use an interactive python shell to execute.
import re
import os
import json
import glob
import shutil
import logging
import boto3
import pickle
import collections