import { useEffect, useMemo, useState } from 'react' import { marked } from 'marked' import { MapView } from './components/MapView' import { spots, type Spot } from './data/spots' type Stage = 'idle' | 'loading' | 'streaming' const pipeline = [ { label: 'Capture', detail: 'Snap/upload a campus photo from phone or laptop' }, { label: 'Swin geo-locator', detail: 'Swin Transformer predicts lat/lng + confidence from the image' }, { label: 'LLM enrichment', detail: 'Predicted coords + building cues go to GPT to craft a tailored prompt and narrative', }, { label: 'Render', detail: 'Map pin drops, coordinates lock in, and we stream the Penn landmark background', }, ] const randomLoadingMs = () => 2600 + Math.random() * 1800 const buildStreamContent = (spot: Spot) => { const header = `# Prediction` const coords = `Lat/Lng: ${spot.lat.toFixed(4)}, ${spot.lng.toFixed(4)}` const facts = ['**Quick facts:**', `- ${coords}`, '- Model: Swin Transformer + retrieval postprocess'].join('\n') return [header, spot.narrative, `**Location note:** ${spot.background}`, facts].join('\n\n') } export default function App() { const [selectedId, setSelectedId] = useState(spots[0]?.id ?? '') const [stage, setStage] = useState('loading') const [typedText, setTypedText] = useState('') const [progress, setProgress] = useState(0) const selected: Spot = useMemo( () => spots.find((spot) => spot.id === selectedId) ?? spots[0], [selectedId], )! const renderedMarkdown = useMemo(() => { if (stage === 'loading') return '' return marked.parse(typedText || '') }, [typedText, stage]) useEffect(() => { if (!selected) return let streamTimer: ReturnType | undefined let progressTimer: ReturnType | undefined setStage('loading') setTypedText('') setProgress(0) progressTimer = setInterval(() => { setProgress((prev) => Math.min(95, prev + 5 + Math.random() * 8)) }, 260) const loadTimer = setTimeout(() => { setStage('streaming') if (progressTimer) clearInterval(progressTimer) setProgress(100) const text = buildStreamContent(selected) let index = 0 streamTimer = setInterval(() => { index += 2 setTypedText(text.slice(0, index)) if (index >= text.length) { if (streamTimer) clearInterval(streamTimer) setStage('idle') } }, 18) }, randomLoadingMs()) return () => { clearTimeout(loadTimer) if (progressTimer) clearInterval(progressTimer) if (streamTimer) clearInterval(streamTimer) } }, [selected]) return (

Image -> GPS | Swin Transformer

Guess where you are @ Penn Engineering

Snap a pic and we'll guess your coordinates. Pick a sample on the left; after a few seconds of thinking, you'll see lat/lng, a description, and a map pin.

Swin Transformer Geo retrieval Penn Engineering

Inference status

{stage === 'loading' ? 'Processing image...' : stage === 'streaming' ? 'Streaming description...' : 'Complete'}

Expect ~3-5 seconds while the model runs, coordinates lock in, and the markdown description streams out.

{['Queue / preprocess', 'Model forward', 'Postprocess', 'Format + render'].map((label, index) => { const active = (stage === 'loading' && index === 1) || (stage === 'streaming' && index >= 1) || stage === 'idle' return (
{label}
) })}
{stage === 'loading' ? (

Predicting coordinates

Waiting for location...

Map will render once lat/lng are ready.

) : ( )}

Predicted coordinates

{stage === 'loading' ? '--.-- , --.--' : `${selected.lat.toFixed(4)}, ${selected.lng.toFixed(4)}`}

{stage === 'loading' ? 'Locating...' : 'Coordinate locked in'}

Lat
{stage === 'loading' ? '--.--' : selected.lat.toFixed(4)}
Lng
{stage === 'loading' ? '--.--' : selected.lng.toFixed(4)}

Streaming description

{stage === 'loading' ? 'Pending' : 'Done'}
{stage === 'loading' ? (
) : (
)}

How it works

Image2GPS pipeline

One photo flows through four handoff stages: capture, geo inference, language enrichment, and a final render that drops a map pin with Penn-specific storytelling.

{pipeline.map((step, index) => (
{index + 1} {index < pipeline.length - 1 &&

{step.label}

{step.detail}

))}
Outputs

Locked coordinates, GPT-authored narration, and a synced map preview—ready to explore the Penn campus in context.

) }