Wolfram Computation Meets Knowledge

ResNet-101 Trained on YFCC100m Geotagged Data

Determine the geolocation of a photograph

Released in 2017, this geolocation model classifies the location in which a photo was taken among more than 15,000 predefined locations around the world. The classes correspond to cells extracted from Google's S2 Geometry library. This model correctly localized 82.2% of the Im2GPS test set within 2,500 kilometers.

Number of layers: 344 | Parameter count: 74,405,235 | Trained size: 299 MB

Training Set Information

Examples

Resource retrieval

Retrieve the resource object:

In[1]:=
ResourceObject["ResNet-101 Trained on YFCC100m Geotagged Data"]
Out[1]=

Get the pre-trained network:

In[2]:=
NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"]
Out[2]=

Basic usage

Obtain an estimate of the latitude and longitude of where a photo was taken:

In[3]:=
Out[3]=

Show a map of the area corresponding to the position:

In[4]:=
GeoGraphics[position]
Out[4]=

Mark the position on a world map:

In[5]:=
GeoGraphics[GeoMarker[position], GeoRange -> 4000000]
Out[5]=

Multiple predictions

The net returns a probability distribution over all available locations. Obtain the 50 most probable locations for a given image and plot these locations on the world map, with the size of the location marker proportional to the probability:

In[6]:=
Out[6]=

Fine-scale predictions

In places with high population density, very fine-grained predictions are possible. Consider the following four landmarks in Paris:

In[7]:=
landmarks = 
 EntityValue[{Entity["Building", "EiffelTower::5h9w8"], 
   Entity["Building", "TheLouvre::vqy3g"], 
   Entity["Building", "NotreDameCathedral::95fcw"], 
   Entity["Building", "ArcDeTriomphe::92x88"]}, "Image", 
  "EntityAssociation"]
Out[7]=

Predict the locations of the four landmarks and mark the locations on the map:

In[8]:=
GeoListPlot[
 MapThread[
  GeoMarker[#1, #2, 
    "Scale" -> 0.01] &, {NetModel[
     "ResNet-101 Trained on YFCC100m Geotagged Data"][
    Values[landmarks]], Values[landmarks]}], 
 GeoRange -> Quantity[1.5, "Miles"]]
Out[8]=

Compare with the actual locations:

In[9]:=
GeoListPlot[
 Map[GeoMarker[EntityValue[#, "Position"], EntityValue[#, "Image"], 
    "Scale" -> 0.01] &, Keys[landmarks]], 
 GeoRange -> Quantity[1.5, "Miles"]]
Out[9]=

Region density

Inspect the distribution of the available positions. Display a heat map of the location density on the map:

In[10]:=
GeoHistogram[
 NetExtract[NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"],
    "Output"][["Labels"]], 50, PlotStyle -> Opacity[0.4], 
 ImageSize -> Large]
Out[10]=

Export to MXNet

Export the net into a format that can be opened in MXNet:

In[11]:=
jsonPath = 
 Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], 
  NetModel["ResNet-101 Trained on YFCC100m Geotagged Data"], "MXNet"]
Out[11]=

Export also creates a net.params file containing parameters:

In[12]:=
paramPath = FileNameJoin[{DirectoryName[jsonPath], "net.params"}]
Out[12]=

Get the size of the parameter file:

In[13]:=
FileByteCount[paramPath]
Out[13]=

The size is similar to the byte count of the resource object:

In[14]:=
ResourceObject[
  "ResNet-101 Trained on YFCC100m Geotagged Data"]["ByteCount"]
Out[14]=

Requirements

Wolfram Language 11.2 (September 2017) or above

Reference