{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from tqdm import tqdm\n", "import cv2 as cv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Classes" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "classes = [\"cloth\", \"KN95\",\"N95\", \"surgical\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Format helper functions" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def visualize(img_info, path):\n", " img_name = path + img_info[\"ImageID\"] + \".jpg\"\n", " bbox = eval(img_info[\"bbox\"])\n", " img = cv.imread(img_name)\n", " img = cv.cvtColor(img, cv.COLOR_RGB2BGR)\n", " [x1, y1, x2, y2] = [int(coord) for coord in bbox]\n", " cv.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)\n", " plt.imshow(img)\n", " plt.axis(\"off\")\n", " plt.title(img_info[\"masktype\"])\n", " plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prepare data" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "train_df = pd.read_csv(\"data/train.csv\")\n", "val_df = pd.read_csv(\"data/val.csv\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | ImageID | \n", "bbox | \n", "masktype | \n", "
---|---|---|---|
0 | \n", "k8o0f | \n", "[73, 197, 293, 400] | \n", "N95 | \n", "
1 | \n", "7a0l9 | \n", "[47, 364, 300, 512] | \n", "surgical | \n", "
2 | \n", "wfp7p | \n", "[203, 221, 380, 403] | \n", "N95 | \n", "
3 | \n", "7qaw6 | \n", "[87, 210, 322, 385] | \n", "surgical | \n", "
4 | \n", "i4kqj | \n", "[227, 283, 479, 475] | \n", "surgical | \n", "