Skip to content

Importing into PostgreSQL

Ivan Krasin edited this page Oct 2, 2016 · 9 revisions

To import the annotations into PostgreSQL, connect to the Postgres server with psql and run the following commands:

Note: this is a work in progress, and it's known to be incomplete and suboptimal. Suggestions to improve it are very welcome!

postgres=# CREATE DATABASE openimages;
CREATE DATABASE
postgres=# \c openimages
You are now connected to database "openimages" as user "username".
postgres=# CREATE TABLE Images (
  ImageID VARCHAR,
  Subset VARCHAR,
  OriginalURL VARCHAR,
  OriginalLandingURL VARCHAR,
  License VARCHAR,
  AuthorProfileURL VARCHAR,
  Author VARCHAR,
  Title VARCHAR);

CREATE TABLE
postgres=# COPY Images FROM 'images_2016_08/validation/images.csv'
DELIMITER ',' CSV HEADER;
COPY 167056
postgres=# COPY Images FROM 'images_2016_08/train/images.csv'
DELIMITER ',' CSV HEADER;
COPY 9011219

You can now verify that import was successful:

postgres=# SELECT Subset, count(*) FROM Images GROUP BY Subset;
   subset   |  count  
------------+---------
 train      | 9011219
 validation |  167056
(2 rows)

TODO: import labels.

Clone this wiki locally