Spaces:
Runtime error
Runtime error
File size: 3,398 Bytes
fac3244 2f1f8ac fac3244 2f1f8ac fac3244 07a9436 fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac fac3244 2f1f8ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
---
title: PLONK Geolocation
emoji: 🗺️
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
short_description: Generative Visual Geolocation with PLONK
---
# 🗺️ PLONK: Around the World in 80 Timesteps
A generative approach to global visual geolocation using diffusion models. Upload an image and PLONK will predict where it was taken!
## 🚀 Features
- **High-Quality Predictions**: Uses 32 samples with CFG=2.0 for robust geolocation
- **Uncertainty Estimation**: Provides confidence radius (±km) for each prediction
- **REST API**: Full programmatic access with JSON responses
- **Multiple Input Methods**: File upload, webcam, clipboard, or base64 encoding
- **CORS Enabled**: Ready for web integration
## 📡 API Usage
### REST API Endpoints
**Main Prediction:**
```
POST https://kylanoconnor-plonk-geolocation.hf.space/api/predict
```
**JSON Response:**
```
POST https://kylanoconnor-plonk-geolocation.hf.space/api/predict_json
```
### Python Example
```python
import requests
# Upload image file
response = requests.post(
"https://kylanoconnor-plonk-geolocation.hf.space/api/predict",
files={"file": open("image.jpg", "rb")}
)
result = response.json()
print(f"Location: {result['data']['latitude']}, {result['data']['longitude']}")
print(f"Uncertainty: ±{result['data']['uncertainty_km']} km")
```
### cURL Example
```bash
curl -X POST \
-F "[email protected]" \
"https://kylanoconnor-plonk-geolocation.hf.space/api/predict"
```
### JavaScript/Node.js
```javascript
const formData = new FormData();
formData.append('data', imageFile);
const response = await fetch(
'https://kylanoconnor-plonk-geolocation.hf.space/api/predict',
{
method: 'POST',
body: formData
}
);
const result = await response.json();
console.log('Location:', result.data);
```
### Gradio Client (Python)
```python
from gradio_client import Client
client = Client("kylanoconnor/plonk-geolocation")
result = client.predict("path/to/image.jpg", api_name="/predict")
print(result)
```
## 🎯 Model Configuration
- **Model**: nicolas-dufour/PLONK_YFCC
- **Dataset**: YFCC-100M
- **Samples**: 32 (for uncertainty estimation)
- **Guidance Scale**: 2.0
- **Timesteps**: 32
- **Uncertainty**: Statistical analysis across predictions
## 📊 Response Format
```json
{
"status": "success",
"mode": "production",
"predicted_location": {
"latitude": 40.756123,
"longitude": -73.984567
},
"confidence": "high",
"samples": 32,
"uncertainty_km": 12.3,
"note": "Real PLONK prediction using 32 samples"
}
```
## 📚 About
**Paper**: [Around the World in 80 Timesteps: A Generative Approach to Global Visual Geolocation](https://arxiv.org/abs/2412.06781)
**Authors**: Nicolas Dufour, David Picard, Vicky Kalogeiton, Loic Landrieu
**Original Code**: https://github.com/nicolas-dufour/plonk
This Space provides both a user-friendly web interface and robust API access for global visual geolocation using the PLONK model. The model uses 32 samples per prediction to provide uncertainty estimation and more reliable results.
## 🔧 Development
To run locally:
```bash
pip install -r requirements_hf_spaces.txt
python app.py
```
The app will be available at `http://localhost:7860` with API documentation at `/docs`.
---
*Built with ❤️ using Gradio and Hugging Face Spaces* |