text-guided-image-colorization / CURL_EXAMPLES.md
LogicGoInfotechSpaces's picture
Integrate FastAI colorization with Firebase auth and Gradio UI - Replace main.py with FastAI implementation - Add Gradio interface for Space UI - Add Firebase authentication to /colorize endpoint - Add curl examples documentation - Update test.py with User-Agent headers
e4599d1
|
raw
history blame
2.42 kB

cURL Examples for Colorization API

Base URL

https://logicgoinfotechspaces-text-guided-image-colorization.hf.space

1. Health Check (No Auth Required)

curl -X GET "https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/health" \
  -H "User-Agent: Mozilla/5.0"

2. Colorize Image (With Firebase Auth)

Using Firebase ID Token

curl -X POST "https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/colorize" \
  -H "Authorization: Bearer YOUR_FIREBASE_ID_TOKEN" \
  -H "User-Agent: Mozilla/5.0" \
  -F "file=@/path/to/your/image.jpg"

Using App Check Token

curl -X POST "https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/colorize" \
  -H "X-Firebase-AppCheck: YOUR_APP_CHECK_TOKEN" \
  -H "User-Agent: Mozilla/5.0" \
  -F "file=@/path/to/your/image.jpg"

Without Auth (if DISABLE_AUTH=true)

curl -X POST "https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/colorize" \
  -H "User-Agent: Mozilla/5.0" \
  -F "file=@/path/to/your/image.jpg" \
  -o colorized_result.png

3. Windows PowerShell Example

$imagePath = "C:\projects\colorize_text\pexels-andrey-grushnikov-223358-707676.jpg"
$headers = @{
    "User-Agent" = "Mozilla/5.0"
}
$form = @{
    file = Get-Item $imagePath
}
Invoke-RestMethod -Uri "https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/colorize" `
    -Method Post `
    -Headers $headers `
    -Form $form `
    -OutFile "colorized_result.png"

4. Python requests Example

import requests

url = "https://logicgoinfotechspaces-text-guided-image-colorization.hf.space/colorize"
headers = {
    "User-Agent": "Mozilla/5.0",
    # "Authorization": "Bearer YOUR_FIREBASE_ID_TOKEN",  # Uncomment if auth enabled
}
files = {
    "file": ("image.jpg", open("path/to/image.jpg", "rb"), "image/jpeg")
}

response = requests.post(url, headers=headers, files=files)
if response.status_code == 200:
    with open("colorized_result.png", "wb") as f:
        f.write(response.content)
    print("Colorized image saved!")
else:
    print(f"Error: {response.status_code} - {response.text}")

Response

  • Success (200): Returns PNG image file
  • Error (400): Bad request (invalid file type)
  • Error (401): Unauthorized (missing/invalid auth token)
  • Error (503): Service unavailable (model not loaded)