image_output_3.png image_output_2.png image_output_1.png
import cv2

import matplotlib.pyplot as plt

import os

import os

import pandas as pd

import warnings

import warnings
warnings.simplefilter('ignore')
import numpy as np
import pandas as pd
from PIL import Image, ImageFilter, ImageOps
import seaborn as sns
import matplotlib.pyplot as plt
from tqdm import tqdm
import time
from contextlib import contextmanager
import gc
import os
import cv2
from glob import glob
import os
import requests
import io
pd.set_option('display.max_rows', 200)

INPUT_DIR = '../input/shigglecup-1st/DATA/'

train_df = pd.read_csv(f'{INPUT_DIR}train.csv')
test_df = pd.read_csv(f'{INPUT_DIR}test.csv')

train_df['train_id'] = 1
test_df['train_id'] = 0
all_df = pd.concat([train_df, test_df]).reset_index(drop=True)

all_df.isna().sum().T

def show_images_glob(images, color, figsize=(20, 10), columns=5):
    for i, image in enumerate(images):
        if image != image:
            continue
        if not os.path.exists(image):
            continue
        img = cv2.imread(image)
        im_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

def show_gbc(colors):
    img_df = all_df[[colors]].dropna()
    cnt = 0
    for i in range(len(img_df.dropna()[colors].unique())):
        if cnt > 2:
            break
        color = img_df.dropna()[colors].unique()[i]
        color_list = f'{INPUT_DIR}pokemon_images/' + train_df[train_df[colors] == color].reset_index(drop=True)['url_image']
        if len(color_list) == 0:
            continue
        cnt += 1

show_gbc('color_f')