Spaces:
Runtime error
Runtime error
| 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 "data=@image.jpg" \ | |
| "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* |