--- title: Colorize Image API emoji: 🎨 colorFrom: blue colorTo: purple sdk: docker sdk_version: 1.0.0 app_file: Dockerfile pinned: false license: mit --- # Colorize Image API FastAPI-based image colorization service using ColorizeNet model with Firebase App Check integration. ## Features - 🖼️ Image upload and colorization - 🔒 Firebase App Check authentication - 🐳 Docker deployment - 📥 Download URLs for browser access ## API Endpoints ### Health Check ``` GET /health ``` Returns the health status of the API and model. ### Upload Image ``` POST /upload Headers: X-Firebase-AppCheck: Body: multipart/form-data with image file ``` Uploads an image and returns the image URL. ### Colorize Image ``` POST /colorize Headers: X-Firebase-AppCheck: Body: multipart/form-data with image file ``` Colorizes a grayscale image and returns the result URL. ### Download Result ``` GET /download/{file_id} Headers: X-Firebase-AppCheck: ``` Downloads the colorized image by file ID. ### Get Result (Public) ``` GET /results/{filename} ``` Public endpoint to access colorized images in browser. ## Setup ### Environment Variables Set these in your Hugging Face Space secrets: - `FIREBASE_CREDENTIALS_PATH`: Path to Firebase credentials JSON file (or set as secret) - `ENABLE_APP_CHECK`: Enable/disable Firebase App Check (default: true) - `MODEL_ID`: Hugging Face model ID (default: rsortino/ColorizeNet) - `NUM_INFERENCE_STEPS`: Number of inference steps (default: 20) ### Firebase App Check Setup 1. Initialize Firebase App Check in your frontend: ```javascript import { initializeApp } from "firebase/app"; import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check"; const firebaseConfig = { apiKey: "AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68", authDomain: "colorize-662df.firebaseapp.com", projectId: "colorize-662df", storageBucket: "colorize-662df.firebasestorage.app", messagingSenderId: "69166278311", appId: "1:69166278311:web:0e8c50b8dd8627aaeadd82", measurementId: "G-58CC2J8XKX" }; const app = initializeApp(firebaseConfig); const appCheck = initializeAppCheck(app, { provider: new ReCaptchaEnterpriseProvider('your-recaptcha-site-key'), isTokenAutoRefreshEnabled: true }); ``` 2. Include the token in API requests: ```javascript const token = await appCheck.getToken(); fetch('https://your-space.hf.space/colorize', { method: 'POST', headers: { 'X-Firebase-AppCheck': token.token }, body: formData }); ``` ## Model This API uses the `rsortino/ColorizeNet` model from Hugging Face for image colorization. ## License MIT # colorize_image-