Delete DEPLOYMENT.md
Browse files- DEPLOYMENT.md +0 -143
DEPLOYMENT.md
DELETED
|
@@ -1,143 +0,0 @@
|
|
| 1 |
-
# Deployment Guide
|
| 2 |
-
|
| 3 |
-
## Quick Start
|
| 4 |
-
|
| 5 |
-
### 1. Copy Firebase Credentials
|
| 6 |
-
|
| 7 |
-
Copy your Firebase Admin SDK JSON file to the project root:
|
| 8 |
-
```bash
|
| 9 |
-
# Windows
|
| 10 |
-
copy C:\Colorize\colorize-662df-firebase-adminsdk-fbsvc-e080668793.json .
|
| 11 |
-
|
| 12 |
-
# Linux/Mac
|
| 13 |
-
cp /path/to/colorize-662df-firebase-adminsdk-fbsvc-e080668793.json .
|
| 14 |
-
```
|
| 15 |
-
|
| 16 |
-
**Important**: For Hugging Face Spaces, you should add this as a secret instead of committing it to the repository.
|
| 17 |
-
|
| 18 |
-
### 2. Deploy to Hugging Face Spaces
|
| 19 |
-
|
| 20 |
-
```bash
|
| 21 |
-
# Initialize git repository
|
| 22 |
-
git init
|
| 23 |
-
git add .
|
| 24 |
-
git commit -m "Deploy Colorize API"
|
| 25 |
-
|
| 26 |
-
# Add Hugging Face remote
|
| 27 |
-
git remote add origin https://huggingface.co/spaces/LogicGoInfotechSpaces/Colorize
|
| 28 |
-
|
| 29 |
-
# Push to Hugging Face
|
| 30 |
-
git push -u origin main
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
### 3. Configure Hugging Face Space Secrets
|
| 34 |
-
|
| 35 |
-
1. Go to your Space: https://huggingface.co/spaces/LogicGoInfotechSpaces/Colorize
|
| 36 |
-
2. Navigate to Settings → Secrets
|
| 37 |
-
3. Add a new secret:
|
| 38 |
-
- **Name**: `FIREBASE_CREDENTIALS`
|
| 39 |
-
- **Value**: Paste the entire contents of your Firebase Admin SDK JSON file
|
| 40 |
-
|
| 41 |
-
### 4. Update Dockerfile for Secrets (Optional)
|
| 42 |
-
|
| 43 |
-
If you want to use the secret, you can modify the Dockerfile to create the file from the secret:
|
| 44 |
-
|
| 45 |
-
```dockerfile
|
| 46 |
-
# Add this before the CMD line
|
| 47 |
-
RUN if [ -n "$FIREBASE_CREDENTIALS" ]; then \
|
| 48 |
-
echo "$FIREBASE_CREDENTIALS" > colorize-662df-firebase-adminsdk-fbsvc-e080668793.json; \
|
| 49 |
-
fi
|
| 50 |
-
```
|
| 51 |
-
|
| 52 |
-
## Testing Locally
|
| 53 |
-
|
| 54 |
-
### Run with Docker
|
| 55 |
-
|
| 56 |
-
```bash
|
| 57 |
-
# Build image
|
| 58 |
-
docker build -t colorize-api .
|
| 59 |
-
|
| 60 |
-
# Run container
|
| 61 |
-
docker run -p 7860:7860 \
|
| 62 |
-
-v $(pwd)/colorize-662df-firebase-adminsdk-fbsvc-e080668793.json:/app/colorize-662df-firebase-adminsdk-fbsvc-e080668793.json \
|
| 63 |
-
colorize-api
|
| 64 |
-
```
|
| 65 |
-
|
| 66 |
-
### Run without Docker
|
| 67 |
-
|
| 68 |
-
```bash
|
| 69 |
-
# Install dependencies
|
| 70 |
-
pip install -r requirements.txt
|
| 71 |
-
|
| 72 |
-
# Run API
|
| 73 |
-
uvicorn app.main:app --host 0.0.0.0 --port 7860
|
| 74 |
-
```
|
| 75 |
-
|
| 76 |
-
## API Endpoints
|
| 77 |
-
|
| 78 |
-
Once deployed, your API will be available at:
|
| 79 |
-
- `https://logicgoinfotechspaces-colorize.hf.space/health` - Health check
|
| 80 |
-
- `https://logicgoinfotechspaces-colorize.hf.space/colorize` - Colorize image
|
| 81 |
-
- `https://logicgoinfotechspaces-colorize.hf.space/upload` - Upload image
|
| 82 |
-
|
| 83 |
-
## Frontend Integration Example
|
| 84 |
-
|
| 85 |
-
```javascript
|
| 86 |
-
// Initialize Firebase
|
| 87 |
-
import { initializeApp } from "firebase/app";
|
| 88 |
-
import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check";
|
| 89 |
-
|
| 90 |
-
const firebaseConfig = {
|
| 91 |
-
apiKey: "AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68",
|
| 92 |
-
authDomain: "colorize-662df.firebaseapp.com",
|
| 93 |
-
projectId: "colorize-662df",
|
| 94 |
-
storageBucket: "colorize-662df.firebasestorage.app",
|
| 95 |
-
messagingSenderId: "69166278311",
|
| 96 |
-
appId: "1:69166278311:web:0e8c50b8dd8627aaeadd82",
|
| 97 |
-
measurementId: "G-58CC2J8XKX"
|
| 98 |
-
};
|
| 99 |
-
|
| 100 |
-
const app = initializeApp(firebaseConfig);
|
| 101 |
-
const appCheck = initializeAppCheck(app, {
|
| 102 |
-
provider: new ReCaptchaEnterpriseProvider('YOUR_RECAPTCHA_SITE_KEY'),
|
| 103 |
-
isTokenAutoRefreshEnabled: true
|
| 104 |
-
});
|
| 105 |
-
|
| 106 |
-
// Colorize image function
|
| 107 |
-
async function colorizeImage(file) {
|
| 108 |
-
const { getToken } = await import('firebase/app-check');
|
| 109 |
-
const token = await getToken(appCheck);
|
| 110 |
-
|
| 111 |
-
const formData = new FormData();
|
| 112 |
-
formData.append('file', file);
|
| 113 |
-
|
| 114 |
-
const response = await fetch('https://logicgoinfotechspaces-colorize.hf.space/colorize', {
|
| 115 |
-
method: 'POST',
|
| 116 |
-
headers: {
|
| 117 |
-
'X-Firebase-AppCheck': token.token
|
| 118 |
-
},
|
| 119 |
-
body: formData
|
| 120 |
-
});
|
| 121 |
-
|
| 122 |
-
return await response.json();
|
| 123 |
-
}
|
| 124 |
-
```
|
| 125 |
-
|
| 126 |
-
## Troubleshooting
|
| 127 |
-
|
| 128 |
-
### Model Not Loading
|
| 129 |
-
|
| 130 |
-
- Check Hugging Face Space logs
|
| 131 |
-
- Verify model ID: `rsortino/ColorizeNet`
|
| 132 |
-
- Ensure sufficient disk space (models can be large)
|
| 133 |
-
|
| 134 |
-
### Firebase App Check Failing
|
| 135 |
-
|
| 136 |
-
- Verify credentials are correctly set as a secret
|
| 137 |
-
- Check that App Check is enabled in Firebase Console
|
| 138 |
-
- Ensure reCAPTCHA Enterprise is set up
|
| 139 |
-
|
| 140 |
-
### Port Issues
|
| 141 |
-
|
| 142 |
-
Hugging Face Spaces automatically handles port 7860. The Dockerfile is configured for this.
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|