Skip to content

Instantly share code, notes, and snippets.

View srishilesh's full-sized avatar
🤖

Srishilesh P S srishilesh

🤖
View GitHub Profile
@srishilesh
srishilesh / sample.json
Created February 28, 2022 17:09
Sample COCO dataset
{
"images": [{
"file_name": "10.1.1.1.2006_3.bmp",
"height": 1123,
"width": 793,
"id": "10.1.1.1.2006_3"
}],
"type": "instances",
"annotations": [{
"area": 4560,
@srishilesh
srishilesh / COCO_validator.py
Created February 28, 2022 17:08
COCO Dataset validator
import json
coco_file = r'/content/sample.json'
with open(coco_file) as json_file:
coco_data = json.load(json_file)
def assertions(key, values, required_keys, unique_key=None):
unique_key_id_mapper = {}
for value in values:
@srishilesh
srishilesh / PASCAL_VOC_Validator.py
Created January 23, 2022 17:09
Validate dataset - PASCAL VOC
import xmltodict
import xml.etree.ElementTree as ET
dataset_file = r'/content/sample.xml' # The path to the XML file
xml_tree = ET.parse(dataset_file) # Parse the XML file
root = xml_tree.getroot() # Find the root element
assert root.tag == 'annotation' or root.attrib['verified'] == 'yes', "PASCAL VOC does not contain a root element" # Check if the root element is "annotation"
assert len(root.findtext('folder')) > 0, "XML file does not contain a 'folder' element"
@srishilesh
srishilesh / sample.xml
Created January 23, 2022 16:26
A sample XML for PASCAL VOC dataset
<annotation verified="yes">
<folder>MARMOT_ANNOTATION</folder>
<filename>10.1.1.1.2006_3.bmp</filename>
<path>MARMOT_ANNOTATION/10.1.1.1.2006_3.bmp</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>793</width>
<height>1123</height>
@srishilesh
srishilesh / voc2coco.py
Created January 11, 2022 18:00
Conversion of PASCAL VOC to COCO
import os
import argparse
import json
import xml.etree.ElementTree as ET
from typing import Dict, List
from tqdm import tqdm
import re
import xmltodict
import numpy as np
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="events_xsl.xsl"?>
<root>
<event>
<event_id>1</event_id>
<event_name>ICPC</event_name>
<event_desc>5 coding questions in 2 hrs</event_desc>
<event_type_participation>Team</event_type_participation>
<event_timing>
<event_start_datetime>2020-04-01T10:00:00</event_start_datetime>
/* USE OF GOOGLE FONTS - GOOGLE STYLESHEET IMPORTED IN HTML FILE*/
#table-title{
color: rgb(88, 40, 49);
font-family: "Times New Roman";
align-items: center;
}
/* EXAMPLE OF ELEMENT SELECTOR */
/* BORDER PROPERTY APPLIED FOR TABLE */
table {
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
<link rel="stylesheet" href="tablecss.css" />
<!-- <link rel="stylesheet" href="../css/style.css" /> -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Sofia" />
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" />
<xs:element name="root" type="rootType" />
<xs:complexType name="rootType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="event" type="eventType" />
</xs:sequence>
</xs:complexType>
@srishilesh
srishilesh / Event_XML.xml
Last active November 4, 2020 16:06
A sample XML file used for validation using XSD
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="validation_xsd.xsd">
<event>
<event_id>1</event_id>
<event_name>ICPC</event_name>
<event_desc>5 coding questions in 2 hrs</event_desc>
<event_tags>
<tag id="1" displayName="coding">coding</tag>
</event_tags>
<event_type_participation>Team</event_type_participation>