{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "YqKnl2Yfem2u"
},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"kaggle_json_data = {\"username\":\"xxxx\",\"key\":\"xxxx\"}\n",
"os.mkdir(\"/root/.kaggle/\")\n",
"with open(\"/root/.kaggle/kaggle.json\", \"w\") as file:\n",
" json.dump(kaggle_json_data, file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "5TJ4RIptfeRi",
"outputId": "cd0cdd20-3827-4f11-f540-8085f97a3e42"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Warning: Your Kaggle API key is readable by other users on this system! To fix this, you can run 'chmod 600 /root/.kaggle/kaggle.json'\n"
]
}
],
"source": [
"import xml.dom.minidom\n",
"from IPython import display\n",
"from pathlib import Path\n",
"import kaggle\n",
"import cv2\n",
"from matplotlib import pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "RgR9fC3tgNr1"
},
"outputs": [],
"source": [
"ds_path = Path('./legos')\n",
"ds_kaggle_path = ds_path/\"/content/legos/dataset_20210629145407_top_600\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "PjjqYOMfese4"
},
"outputs": [],
"source": [
"kaggle.api.dataset_download_files('dreamfactor/biggest-lego-dataset-600-parts', path=ds_path, unzip=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "7MO44zWFex5e"
},
"outputs": [],
"source": [
"ANNOTATIONS = ds_kaggle_path/\"annotations\"\n",
"IMAGES = ds_kaggle_path/\"images\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "obmBqARVic1r"
},
"source": [
"## Show data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Oe9vaEyDletn"
},
"outputs": [],
"source": [
"example_i = 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "xZui1NfbfHIB",
"outputId": "00da9057-cf88-43fb-93fc-18b1f514df5f"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
" BrickRay\n",
" 2059d05c-daa2-11eb-b1a3-3497f683a169.jpg\n",
" \n",
" 600\n",
" 600\n",
" 3\n",
" \n",
" \n",
" \n",
" \n",
" \n",
"\n"
]
}
],
"source": [
"EXAMPLE_IMG = ANNOTATIONS/(os.listdir(ANNOTATIONS))[example_i]\n",
"dom = xml.dom.minidom.parse(str(EXAMPLE_IMG))\n",
"print(dom.toprettyxml(newl='', indent=''))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 453
},
"id": "aD6RTO90fLGI",
"outputId": "3ded0204-4cc3-448b-8dea-59000bc4180e"
},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
""
]
},
"metadata": {},
"execution_count": 8
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"