-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerator.py
30 lines (25 loc) · 870 Bytes
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os, sys, math, io
import numpy as np
import pandas as pd
import multiprocessing as mp
import bson
import struct
import keras
from keras.preprocessing.image import load_img, img_to_array
import tensorflow as tf
from collections import defaultdict
from tqdm import *
def make_category_tables():
cat2idx = {}
idx2cat = {}
for ir in categories_df.itertuples():
category_id = ir[0]
category_idx = ir[4]
cat2idx[category_id] = category_idx
idx2cat[category_idx] = category_id
return cat2idx, idx2cat
categories_df = pd.read_csv("categories.csv", index_col=0)
cat2idx, idx2cat = make_category_tables()
train_offsets_df = pd.read_csv("train_offsets.csv", index_col=0)
train_images_df = pd.read_csv("train_images.csv", index_col=0)
val_images_df = pd.read_csv("val_images.csv", index_col=0)