Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

baileywickham/PrettyCities

Repository files navigation

PrettyCities

Characterize and generate pretty cities

Open In Colab

Street view API

Given a set of street view images of a city deemed pretty (0-9 scale), train a model on this score. The biggest problem with this is data, all labels are hand generated. Even using tricks like varying heading reduces the accuracy of the labels.

Use

Requries pipenv and python3.9. Use pipenv install to install dependencies.

The jupyter notebook contains the model, the gMaps.py file contians a wrapper around the google maps street view API to fetch photos.

Use runner.py provides the google maps API as well as filter helpers:

usage: Google maps street view CLI [-h] [--csv CSV] [--lat LAT] [--long LONG] [--filter FILTER] [--varyHeading]
                                   [--live]

optional arguments:
  -h, --help       show this help message and exit
  --csv CSV        Take input of <lat,long,score> from csv, download each image and write to a file
  --lat LAT        Use with long, download one file
  --long LONG      Use with lat, download one file
  --filter FILTER  filter a file from the speadsheet into a CSV
  --varyHeading    vary the heading on the images, use default, 0, 90, 180, 270
  --live           turn off dry_run

gMaps

gMaps.py provides a basic google maps street view API.

Init the module

g = GMaps('api-key', dry_run=False)

API:

Convert DMS to dec, leaves coordinates unchanged if passed in as decimal.

lat, long = g.convert(coordinates...)

Get a streetview and write the jpg to a file. if varyHeading is set, 5 images will be downloaded: default heading, then 0, 90, 180, 270 degrees.

g.getAndWriteToFile(lat, long, Filename(basename), varyCoord=False, varyHeading=False)

Filename

The filename class generates a unique filename for each file. It takes a base name and generates unique file names.

Given a base name city and a score of 5, this will be written data/5/5-city-xxxxxx.jpg where the xs are random ints.

About

Characterize pretty cities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published