Spaces:
Sleeping
Sleeping
File size: 8,960 Bytes
f2895a9 |
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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
Smile Changer API (with Firebase Authentication)
Base URL
- https://logicgoinfotechspaces-smile-changer.hf.space
Authentication
- Scheme: Bearer ID token (Firebase Authentication)
- Header: Authorization: Bearer <ID_TOKEN>
- How to obtain ID token:
1) Sign-in REST (replace YOUR_WEB_API_KEY and credentials):
curl -X POST "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=YOUR_WEB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"you@example.com","password":"yourPassword","returnSecureToken":true}'
Copy the value of "idToken" from the JSON response and use as the Bearer token.
2) Or sign-in from your Firebase web/app and call currentUser.getIdToken().
- Notes: idToken expires in ~1 hour; sign in again to refresh. Service account JSON is configured in the server via FIREBASE_CREDENTIALS_JSON.
Health (public)
- GET /api/health
- Curl:
curl https://logicgoinfotechspaces-smile-changer.hf.space/api/health
- Response: {"status":"ok"}
Auth check & user info
- GET /api/me
- Headers: Authorization: Bearer <ID_TOKEN>
- Curl:
curl -H "Authorization: Bearer <ID_TOKEN>" \
https://logicgoinfotechspaces-smile-changer.hf.space/api/me
- Response (example): {"mode":"firebase","uid":"...","claims":{"email":"..."}}
List supported attributes
- GET /api/attributes
- Headers: Authorization: Bearer <ID_TOKEN>
- Curl:
curl -H "Authorization: Bearer <ID_TOKEN>" \
https://logicgoinfotechspaces-smile-changer.hf.space/api/attributes
- Response example: {"Smile":{"internal":"fs_smiling","min":-10.0,"max":10.0}, ...}
Generic image edit
- POST /api/image-edit
- Headers: Authorization: Bearer <ID_TOKEN>
- Body (multipart/form-data):
- file: (File) input image (jpg/png)
- attribute: string (e.g., Smile, Age, Beard, Glasses, Makeup, Curly hair, Afro, Orange hair (text), Blonde hair (text))
- strength: float (see ranges from /api/attributes)
- align_face: boolean (true/false)
- use_bg_mask: boolean (true/false)
- custom_text_edit: string (optional, for text-based attributes)
- Curl (Windows path example):
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/image-edit" \
-H "Authorization: Bearer <ID_TOKEN>" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "attribute=Smile" \
-F "strength=8" \
-F "align_face=true" \
-F "use_bg_mask=false" \
--output result_smile.png
Attribute shortcut endpoints (same body as above, omit attribute field)
- POST /api/smile
- POST /api/age
- POST /api/beard
- POST /api/mustache-goatee
- POST /api/glasses
- POST /api/makeup
- POST /api/curly-hair
- POST /api/afro
- POST /api/orange-hair-text
- POST /api/blonde-hair-text
- Curl (Age example):
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/age" \
-H "Authorization: Bearer <ID_TOKEN>" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=8" \
--output result_age.png
HTTP status codes
- 200: Success (image or JSON returned)
- 400: Bad request (missing/invalid params)
- 401: Unauthorized (missing/invalid/expired ID token)
- 404: Not found (wrong endpoint)
- 415: Unsupported media type (file field missing or not an image)
- 500: Internal server error
Troubleshooting
- 401 Invalid token: get a fresh idToken (tokens expire ~1h) and ensure you send it in the Authorization header, not in the URL.
- API key invalid when signing in: ensure you use the Web API key from the same Firebase project as the created user.
- Large images: processing can take longer; keep connection open until response.
Security notes
- Never commit service account JSON to the repo. Provide credentials via Space secret FIREBASE_CREDENTIALS_JSON or a secure env var.
- Prefer HTTPS for all client requests.
Web API key (how to find)
- Firebase Console β Project settings (gear) β General
- If you donβt have a Web app, click βAdd appβ β Web (</>) and finish
- Copy Web API key from:
- Project settings β General β Your project β Web API key, or
- Project settings β General β Your apps β select Web app β SDK setup and configuration β apiKey
Authentication cURL quick reference
- Sign up a user (optional; returns idToken too):
curl -X POST "https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=YOUR_WEB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"you@example.com","password":"yourPassword","returnSecureToken":true}'
- Sign in (recommended; get idToken):
curl -X POST "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=YOUR_WEB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"you@example.com","password":"yourPassword","returnSecureToken":true}'
β Copy "idToken" and use:
curl -H "Authorization: Bearer <ID_TOKEN>" https://logicgoinfotechspaces-smile-changer.hf.space/api/me
Windows PowerShell line breaks
- Use backticks (`) instead of backslashes for multiline commands, or paste as a single line.
CURL CHEAT-SHEET (Firebase + all endpoints)
1) Sign in (get idToken)
Replace YOUR_WEB_API_KEY and credentials; copy the idToken from response.
curl -X POST "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=YOUR_WEB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"you@example.com","password":"yourPassword","returnSecureToken":true}'
2) Use YOUR_ID_TOKEN below; change file path as needed.
- Health (public)
curl https://logicgoinfotechspaces-smile-changer.hf.space/api/health
- Me (auth check)
curl -H "Authorization: Bearer YOUR_ID_TOKEN" \
https://logicgoinfotechspaces-smile-changer.hf.space/api/me
- List attributes
curl -H "Authorization: Bearer YOUR_ID_TOKEN" \
https://logicgoinfotechspaces-smile-changer.hf.space/api/attributes
- Generic image edit
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/image-edit" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "attribute=Smile" \
-F "strength=8" \
-F "align_face=true" \
-F "use_bg_mask=false" \
--output result_generic.png
Shortcut endpoints (omit attribute field)
- Smile
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/smile" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=8" \
--output result_smile.png
- Age
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/age" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=8" \
--output result_age.png
- Beard (negative adds)
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/beard" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=-15" \
--output result_beard.png
- Mustache/Goatee (negative adds)
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/mustache-goatee" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=-5" \
--output result_goatee.png
- Glasses
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/glasses" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=20" \
--output result_glasses.png
- Makeup
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/makeup" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=5" \
--output result_makeup.png
- Curly hair
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/curly-hair" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=0.10" \
--output result_curly.png
- Afro
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/afro" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=0.12" \
--output result_afro.png
- Orange hair (text)
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/orange-hair-text" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=0.18" \
-F "custom_text_edit=styleclip_global_a face_a face with orange hair_0.18" \
--output result_orange_hair.png
- Blonde hair (text)
curl -X POST "https://logicgoinfotechspaces-smile-changer.hf.space/api/blonde-hair-text" \
-H "Authorization: Bearer YOUR_ID_TOKEN" \
-F "file=@C:\\projects\\smile_api\\selfi_4.jpeg" \
-F "strength=0.18" \
-F "custom_text_edit=styleclip_global_a face_a face with blonde hair_0.18" \
--output result_blonde_hair.png |