Skip to content

Instantly share code, notes, and snippets.

View DataTurks's full-sized avatar

DataTurks DataTurks

View GitHub Profile
{
"content": "https://s3-us-west-2.amazonaws.com/com.dataturks.trivia/cars5.mp4",
"annotation": [{
"startTime": 0.682497,
"endTime": 4.764457,
"label": "Car",
"shape": "rectangle",
"positions": [{
"points": [
[0.2390829694323144, 0.5667151868025229],
# coding: utf-8
import json
import matplotlib.pyplot as plt
from PIL import Image, ImageDraw
import numpy as np
import cv2
# Find OpenCV version
(major_ver, minor_ver, subminor_ver) = (cv2.__version__).split('.')
@DataTurks
DataTurks / keras_json_parser.py
Created September 18, 2018 13:30 — forked from sameerg07/keras_json_parser.py
parses the json file downloaded using the image classifier tool on dataturks to actual dataset
#This script has been solely created under dataturks. Copyrights are reserved
#EXAMPLE USAGE
#python3 keras_json_parser.py --json_file "flower.json" --dataset_path "Dataset5/" --train_percentage 80 --validation_percentage 20
import json
import glob
import urllib.request
import argparse
@echo off
set _DIR_PATH=%1
set _DATATURKS_OUT=dataturks_urls.txt
echo.>%_DATATURKS_OUT%
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
set ip=%ip:~1%
@DataTurks
DataTurks / Dataturks_To_Masks.py
Created August 28, 2018 10:10
A simple script to automatically convert Dataturks JSON output from polygon bounding box projects to image masks.
from skimage import draw
from skimage import io
import numpy as np
import urllib.request
import json
import logging
import os
import sys
@DataTurks
DataTurks / train_spacy_NER.py
Created May 27, 2018 10:35
Train Spacy NER example
import spacy
################### Train Spacy NER.###########
def train_spacy():
TRAIN_DATA = convert_dataturks_to_spacy("dataturks_downloaded.json");
nlp = spacy.blank('en') # create blank Language class
# create the built-in pipeline components and add them to the pipeline
# nlp.create_pipe works for built-ins that are registered with spaCy
if 'ner' not in nlp.pipe_names:
ner = nlp.create_pipe('ner')
nlp.add_pipe(ner, last=True)
@DataTurks
DataTurks / convert_dataturks_to_spacy.py
Created May 27, 2018 10:23
Creates NER training data in Spacy format from JSON downloaded from Dataturks.
############################################ NOTE ########################################################
#
# Creates NER training data in Spacy format from JSON downloaded from Dataturks.
#
# Outputs the Spacy training data which can be used for Spacy training.
#
############################################################################################################
def convert_dataturks_to_spacy(dataturks_JSON_FilePath):
try:
training_data = []
@DataTurks
DataTurks / train_spacy.py
Created May 27, 2018 10:17
Use pickled training file to train Spacy NER.
def train_spacy(training_pickle_file):
#read pickle file to load training data
with open(training_pickle_file, 'rb') as input:
TRAIN_DATA=pickle.load(input)
nlp = spacy.blank('en') # create blank Language class
# create the built-in pipeline components and add them to the pipeline
# nlp.create_pipe works for built-ins that are registered with spaCy
if 'ner' not in nlp.pipe_names:
@DataTurks
DataTurks / Dataturks_to_Spacy.py
Created May 27, 2018 10:13
Creates NER training data in Spacy format from JSON downloaded from Dataturks.
import argparse
import sys
import os
import json
import logging
import pickle
############################################ NOTE ########################################################
#
@DataTurks
DataTurks / dataturks_to_PascalVOC.py
Last active April 26, 2020 08:54
Covert Dataturks Image bounding box JSON to Pascal VOC format.
import argparse
import sys
import os
import json
import logging
import requests
from PIL import Image
################### INSTALLATION NOTE #######################
##############################################################