LogicGoInfotechSpaces commited on
Commit
dedce1e
·
verified ·
1 Parent(s): eeec1f8

Delete SETUP.md

Browse files
Files changed (1) hide show
  1. SETUP.md +0 -193
SETUP.md DELETED
@@ -1,193 +0,0 @@
1
- # Setup Guide for Colorize API
2
-
3
- ## Prerequisites
4
-
5
- 1. Python 3.10+
6
- 2. Docker (for containerized deployment)
7
- 3. Firebase Admin SDK credentials file
8
- 4. Hugging Face account with access to the Colorize Space
9
-
10
- ## Local Development Setup
11
-
12
- ### 1. Install Dependencies
13
-
14
- ```bash
15
- pip install -r requirements.txt
16
- ```
17
-
18
- ### 2. Firebase Credentials
19
-
20
- Copy your Firebase Admin SDK JSON file to the project root:
21
- - Source: `C:\Colorize\colorize-662df-firebase-adminsdk-fbsvc-e080668793.json`
22
- - Destination: `colorize-662df-firebase-adminsdk-fbsvc-e080668793.json`
23
-
24
- Or set the path in environment variable:
25
- ```bash
26
- export FIREBASE_CREDENTIALS_PATH=/path/to/your/firebase-credentials.json
27
- ```
28
-
29
- ### 3. Run the API
30
-
31
- ```bash
32
- uvicorn app.main:app --reload --port 7860
33
- ```
34
-
35
- The API will be available at `http://localhost:7860`
36
-
37
- ## Docker Setup
38
-
39
- ### 1. Build the Docker Image
40
-
41
- ```bash
42
- docker build -t colorize-api .
43
- ```
44
-
45
- ### 2. Run the Container
46
-
47
- ```bash
48
- docker run -p 7860:7860 \
49
- -v $(pwd)/colorize-662df-firebase-adminsdk-fbsvc-e080668793.json:/app/colorize-662df-firebase-adminsdk-fbsvc-e080668793.json \
50
- -e BASE_URL=http://localhost:7860 \
51
- colorize-api
52
- ```
53
-
54
- ## Hugging Face Spaces Deployment
55
-
56
- ### 1. Prepare Your Repository
57
-
58
- ```bash
59
- # Initialize git repository
60
- git init
61
- git add .
62
- git commit -m "Initial commit: Colorize API with Firebase App Check"
63
- ```
64
-
65
- ### 2. Set Up Hugging Face Space
66
-
67
- 1. Go to https://huggingface.co/spaces/LogicGoInfotechSpaces/Colorize
68
- 2. If the space doesn't exist, create a new Docker space
69
-
70
- ### 3. Add Firebase Credentials as Secret
71
-
72
- In Hugging Face Space settings:
73
- 1. Go to Settings → Secrets
74
- 2. Add a new secret:
75
- - Name: `FIREBASE_CREDENTIALS`
76
- - Value: Contents of your Firebase Admin SDK JSON file
77
-
78
- ### 4. Update Dockerfile for Secrets (if needed)
79
-
80
- The Dockerfile will automatically use the credentials file if it exists. For Hugging Face Spaces, you may need to create the file from secrets:
81
-
82
- ```dockerfile
83
- # Add this to Dockerfile if using HF secrets
84
- RUN echo "$FIREBASE_CREDENTIALS" > colorize-662df-firebase-adminsdk-fbsvc-e080668793.json || true
85
- ```
86
-
87
- ### 5. Push to Hugging Face
88
-
89
- ```bash
90
- git remote add origin https://huggingface.co/spaces/LogicGoInfotechSpaces/Colorize
91
- git push -u origin main
92
- ```
93
-
94
- ## Testing the API
95
-
96
- ### Health Check
97
-
98
- ```bash
99
- curl http://localhost:7860/health
100
- ```
101
-
102
- ### Upload Image (with App Check token)
103
-
104
- ```bash
105
- curl -X POST http://localhost:7860/upload \
106
- -H "X-Firebase-AppCheck: YOUR_APP_CHECK_TOKEN" \
107
- -F "file=@path/to/image.jpg"
108
- ```
109
-
110
- ### Colorize Image (with App Check token)
111
-
112
- ```bash
113
- curl -X POST http://localhost:7860/colorize \
114
- -H "X-Firebase-AppCheck: YOUR_APP_CHECK_TOKEN" \
115
- -F "file=@path/to/grayscale_image.jpg"
116
- ```
117
-
118
- ## Frontend Integration
119
-
120
- ### Initialize Firebase App Check
121
-
122
- ```javascript
123
- import { initializeApp } from "firebase/app";
124
- import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check";
125
-
126
- const firebaseConfig = {
127
- apiKey: "AIzaSyBIB6rcfyyqy5niERTXWvVD714Ter4Vx68",
128
- authDomain: "colorize-662df.firebaseapp.com",
129
- projectId: "colorize-662df",
130
- storageBucket: "colorize-662df.firebasestorage.app",
131
- messagingSenderId: "69166278311",
132
- appId: "1:69166278311:web:0e8c50b8dd8627aaeadd82",
133
- measurementId: "G-58CC2J8XKX"
134
- };
135
-
136
- const app = initializeApp(firebaseConfig);
137
-
138
- // Initialize App Check
139
- const appCheck = initializeAppCheck(app, {
140
- provider: new ReCaptchaEnterpriseProvider('YOUR_RECAPTCHA_SITE_KEY'),
141
- isTokenAutoRefreshEnabled: true
142
- });
143
-
144
- // Get token and make API call
145
- async function colorizeImage(imageFile) {
146
- const token = await appCheck.getToken();
147
-
148
- const formData = new FormData();
149
- formData.append('file', imageFile);
150
-
151
- const response = await fetch('https://your-space.hf.space/colorize', {
152
- method: 'POST',
153
- headers: {
154
- 'X-Firebase-AppCheck': token.token
155
- },
156
- body: formData
157
- });
158
-
159
- const result = await response.json();
160
- console.log('Colorized image URL:', result.download_url);
161
- return result;
162
- }
163
- ```
164
-
165
- ## Troubleshooting
166
-
167
- ### Model Loading Issues
168
-
169
- If the ColorizeNet model fails to load:
170
- 1. Check your internet connection (model downloads from Hugging Face)
171
- 2. Verify you have sufficient disk space
172
- 3. Check logs for specific error messages
173
-
174
- ### Firebase App Check Issues
175
-
176
- If App Check verification fails:
177
- 1. Verify your Firebase credentials file is correct
178
- 2. Check that App Check is enabled in Firebase Console
179
- 3. Ensure the token is being sent in the `X-Firebase-AppCheck` header
180
-
181
- ### Port Issues
182
-
183
- Hugging Face Spaces uses port 7860 by default. Make sure your Dockerfile exposes this port.
184
-
185
- ## Environment Variables
186
-
187
- - `FIREBASE_CREDENTIALS_PATH`: Path to Firebase Admin SDK JSON file
188
- - `ENABLE_APP_CHECK`: Enable/disable Firebase App Check (true/false)
189
- - `BASE_URL`: Base URL for generating download URLs
190
- - `PORT`: Port to run the API on (default: 7860)
191
- - `MODEL_ID`: Hugging Face model ID (default: rsortino/ColorizeNet)
192
- - `NUM_INFERENCE_STEPS`: Number of inference steps (default: 20)
193
-