Spaces:
Paused
Paused
File size: 4,363 Bytes
803c132 | 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | # InstantSplat API - Quick Start
Submit images via API and get back the Supabase GLB URL in 3 easy steps!
## 🚀 30-Second Quick Start
### Step 1: Install Client
```bash
pip install gradio_client
```
### Step 2: Run This Code
```python
from gradio_client import Client
# Connect to your Space
client = Client("your-username/InstantSplat")
# Submit images and get GLB URL
result = client.predict(
["image1.jpg", "image2.jpg", "image3.jpg"],
api_name="/predict"
)
glb_url = result[5] # The 6th element is the GLB URL
print(f"Your 3D model: {glb_url}")
```
### Step 3: Done! 🎉
The `glb_url` is your Supabase Storage URL that you can:
- Share directly
- Download programmatically
- Embed in viewers
- Store in databases
## 📦 What You Get Back
The API returns 6 elements:
```python
[
video_path, # [0] Path to video
ply_url, # [1] PLY file URL (Supabase)
ply_download, # [2] PLY download
ply_model, # [3] PLY model
glb_model, # [4] GLB model path
glb_url, # [5] GLB URL (Supabase) ← YOU WANT THIS!
]
```
Access it with: `result[5]`
## 📝 Example: Complete Script
```python
#!/usr/bin/env python3
from gradio_client import Client
def get_glb_url(images):
"""Submit images, get GLB URL."""
client = Client("your-username/InstantSplat")
result = client.predict(images, api_name="/predict")
return result[5] # GLB URL
# Use it
images = ["img1.jpg", "img2.jpg", "img3.jpg"]
glb_url = get_glb_url(images)
print(f"GLB URL: {glb_url}")
```
## 🛠️ Using the CLI Tool
We provide a ready-to-use CLI tool:
```bash
# Local usage
python api_client.py img1.jpg img2.jpg img3.jpg
# With remote Space
export INSTANTSPLAT_SPACE="your-username/InstantSplat"
python api_client.py img1.jpg img2.jpg img3.jpg
```
Output:
```
================================================================================
InstantSplat API Client
================================================================================
Connecting to Space: your-username/InstantSplat
Submitting 3 images for processing...
1. img1.jpg
2. img2.jpg
3. img3.jpg
================================================================================
✅ SUCCESS!
--------------------------------------------------------------------------------
GLB URL: https://xxx.storage.supabase.co/storage/v1/object/public/outputs/xxx.glb
PLY URL: https://xxx.storage.supabase.co/storage/v1/object/public/outputs/xxx.ply
Video: Available
--------------------------------------------------------------------------------
💡 Tip: You can now download the GLB file:
curl -o model.glb 'https://xxx.storage.supabase.co/...'
================================================================================
```
## 🌐 JavaScript/TypeScript
```bash
npm install --save @gradio/client
```
```typescript
import { Client } from "@gradio/client";
const client = await Client.connect("your-username/InstantSplat");
const result = await client.predict("/predict", {
inputfiles: ["img1.jpg", "img2.jpg", "img3.jpg"]
});
const glbUrl = result.data[5];
console.log("GLB URL:", glbUrl);
```
## 📚 Full Documentation
For advanced usage, see:
- **`API_GUIDE.md`** - Complete API documentation
- **`api_client.py`** - Ready-to-use Python client
- **In-app API tab** - Interactive documentation
## ⚠️ Important Notes
### Input Requirements
- ✅ Minimum 2 images (3+ recommended)
- ✅ Same resolution for all images
- ✅ JPG or PNG format
### Processing Time
- Typically 30-120 seconds depending on:
- Number of images
- Image resolution
- GPU availability
### What Gets Uploaded to Supabase
- GLB file (~5-20 MB)
- PLY file (~50-200 MB)
- Both accessible via the returned URLs
## 🔧 Troubleshooting
### "Supabase credentials not set"
Set environment variables in your Space settings:
```
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_KEY=your-service-role-key
SUPABASE_BUCKET=outputs
```
### "The resolution of the input image should be the same"
Resize all images to same dimensions before uploading.
### Connection timeout
The Space might be sleeping (free tier). It will wake up on first request (takes ~30s).
## 🎯 Next Steps
1. Try the quick start above
2. Test with your own images
3. Integrate into your app
4. Check out `API_GUIDE.md` for advanced features
Happy coding! 🚀
|