jichao commited on
Commit
64d4f77
·
1 Parent(s): 4052154

retrieval location logic

Browse files
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ## python
2
+ __pycache__/
3
+
4
+ backend/data/embeddings/mars-mae-vit-b-2m/samples.db
5
+ backend/data/embeddings/mars-mae-vit-b-2m/embeddings.index
frontend/src/components/RetrievalDemo.jsx CHANGED
@@ -43,10 +43,13 @@ const ThumbnailImage = styled("img")({
43
  transition: "transform 0.3s ease-in-out",
44
  })
45
 
46
- const parseCoordinates = (filename) => {
47
  const match = filename.match(/E(-?\d+)_N(-?\d+)_x(\d+)_y(\d+)/)
48
  if (!match) return null
49
 
 
 
 
50
  const [_, longitude, latitude, x, y] = match
51
  const baseLong = Number.parseInt(longitude)
52
  const baseLat = Number.parseInt(latitude)
@@ -56,12 +59,14 @@ const parseCoordinates = (filename) => {
56
  const degreesPerPixel = 4 / 47420
57
  const xOffset = Number.parseInt(x) * degreesPerPixel
58
  const yOffset = Number.parseInt(y) * degreesPerPixel
 
 
59
 
60
  return {
61
  // Format the base tile name according to the specified convention
62
  baseTile: `MurrayLab_CTX_V01_E${longitude}_N${latitude}_Mosaic`,
63
- longitude: baseLong + xOffset,
64
- latitude: baseLat + 4 - yOffset,
65
  x: Number.parseInt(x),
66
  y: Number.parseInt(y),
67
  }
@@ -170,7 +175,7 @@ const RetrievalDemo = () => {
170
  <Grid item xs={12} md={6}>
171
  <Typography variant="body1" paragraph>
172
  Select a sample image above or upload your own Mars image to find similar images in our database.
173
- The database has 2 million images sampled from ±32°N on Mars.
174
  </Typography>
175
  <Box sx={{ display: "flex", gap: 2, flexWrap: "wrap", alignItems: "center" }}>
176
  <label htmlFor="contained-button-file">
@@ -271,13 +276,13 @@ const RetrievalDemo = () => {
271
  <Typography variant="subtitle2" sx={{ display: "none" }} title={result.filename}>
272
  File: {result.filename}
273
  </Typography>
274
- {parseCoordinates(result.filename) && (
275
  <Typography variant="body2" color="text.secondary">
276
- Base tile: {parseCoordinates(result.filename).baseTile}
277
  <br />
278
  Exact location:{" "}
279
- {`${Math.abs(parseCoordinates(result.filename).longitude).toFixed(2)}°${parseCoordinates(result.filename).longitude >= 0 ? "E" : "W"}, `}
280
- {`${Math.abs(parseCoordinates(result.filename).latitude).toFixed(2)}°${parseCoordinates(result.filename).latitude >= 0 ? "N" : "S"}`}
281
  </Typography>
282
  )}
283
  <Chip
 
43
  transition: "transform 0.3s ease-in-out",
44
  })
45
 
46
+ const parseCoordinates = (filename, label) => {
47
  const match = filename.match(/E(-?\d+)_N(-?\d+)_x(\d+)_y(\d+)/)
48
  if (!match) return null
49
 
50
+ const scale = label.match(/size_(\d+)/)
51
+ if (!scale) return null
52
+
53
  const [_, longitude, latitude, x, y] = match
54
  const baseLong = Number.parseInt(longitude)
55
  const baseLat = Number.parseInt(latitude)
 
59
  const degreesPerPixel = 4 / 47420
60
  const xOffset = Number.parseInt(x) * degreesPerPixel
61
  const yOffset = Number.parseInt(y) * degreesPerPixel
62
+ const centerOffset = (Number.parseInt(scale[1]) / 2 ) * degreesPerPixel
63
+
64
 
65
  return {
66
  // Format the base tile name according to the specified convention
67
  baseTile: `MurrayLab_CTX_V01_E${longitude}_N${latitude}_Mosaic`,
68
+ longitude: baseLong + xOffset + centerOffset,
69
+ latitude: baseLat + 4 - yOffset - centerOffset,
70
  x: Number.parseInt(x),
71
  y: Number.parseInt(y),
72
  }
 
175
  <Grid item xs={12} md={6}>
176
  <Typography variant="body1" paragraph>
177
  Select a sample image above or upload your own Mars image to find similar images in our database.
178
+ The database has 2 million images sampled from ±32°N on Mars, from Murray Lab Global CTX Mosaic.
179
  </Typography>
180
  <Box sx={{ display: "flex", gap: 2, flexWrap: "wrap", alignItems: "center" }}>
181
  <label htmlFor="contained-button-file">
 
276
  <Typography variant="subtitle2" sx={{ display: "none" }} title={result.filename}>
277
  File: {result.filename}
278
  </Typography>
279
+ {parseCoordinates(result.filename, result.label) && (
280
  <Typography variant="body2" color="text.secondary">
281
+ Base tile: {parseCoordinates(result.filename, result.label).baseTile}
282
  <br />
283
  Exact location:{" "}
284
+ {`${Math.abs(parseCoordinates(result.filename,result.label).longitude).toFixed(2)}°${parseCoordinates(result.filename,result.label).longitude >= 0 ? "E" : "W"}, `}
285
+ {`${Math.abs(parseCoordinates(result.filename,result.label).latitude).toFixed(2)}°${parseCoordinates(result.filename,result.label).latitude >= 0 ? "N" : "S"}`}
286
  </Typography>
287
  )}
288
  <Chip