msgxai commited on
Commit
230d561
·
1 Parent(s): bfeeedb

Update README with detailed Inference Endpoint setup instructions

Browse files
Files changed (1) hide show
  1. README.md +73 -5
README.md CHANGED
@@ -92,11 +92,79 @@ Response format from the local server:
92
 
93
  ## Deployment on Hugging Face Inference Endpoints
94
 
95
- 1. Push this repository to Hugging Face Hub or your Git repository
96
- 2. Create a new Inference Endpoint on Hugging Face
97
- 3. Select this repository as the source
98
- 4. Configure compute resources (recommended: GPU with at least 16GB VRAM)
99
- 5. Deploy the endpoint
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  ### Required Files
102
 
 
92
 
93
  ## Deployment on Hugging Face Inference Endpoints
94
 
95
+ ### Step 1: Push this repository to Hugging Face Hub
96
+
97
+ 1. Create a new repository on Hugging Face Hub:
98
+ ```bash
99
+ huggingface-cli repo create your-repo-name
100
+ ```
101
+
102
+ 2. Add the Hugging Face repository as a remote:
103
+ ```bash
104
+ git remote add huggingface https://huggingface.co/username/your-repo-name
105
+ ```
106
+
107
+ 3. Push your code to the Hugging Face repository:
108
+ ```bash
109
+ git push huggingface your-branch:main
110
+ ```
111
+
112
+ ### Step 2: Create an Inference Endpoint
113
+
114
+ 1. Go to your repository on Hugging Face Hub: https://huggingface.co/username/your-repo-name
115
+ 2. Click on "Deploy" in the top menu, then select "Inference Endpoints"
116
+ 3. Click "Create a new endpoint"
117
+ 4. Configure your endpoint with the following settings:
118
+ - Name: Give your endpoint a name
119
+ - Instance Type: Choose a GPU instance (recommended: at least 16GB VRAM for SDXL)
120
+ - Replicas: Start with 1 replica
121
+ - Autoscaling: Configure as needed
122
+ 5. Click "Create endpoint"
123
+
124
+ The Hugging Face Inference Endpoints service will automatically detect and use your `EndpointHandler` class in the `handler.py` file.
125
+
126
+ ### Step 3: Test your Inference Endpoint
127
+
128
+ Once deployed, you can test your endpoint using:
129
+
130
+ ```python
131
+ import requests
132
+ import json
133
+ import base64
134
+ from PIL import Image
135
+ import io
136
+
137
+ # Your Hugging Face API token and endpoint URL
138
+ API_TOKEN = "your-hugging-face-api-token"
139
+ API_URL = "https://api-inference.huggingface.co/models/username/your-repo-name"
140
+
141
+ # Headers for the request
142
+ headers = {
143
+ "Authorization": f"Bearer {API_TOKEN}",
144
+ "Content-Type": "application/json"
145
+ }
146
+
147
+ # Request payload
148
+ payload = {
149
+ "inputs": "a beautiful landscape with mountains and a lake",
150
+ "parameters": {
151
+ "negative_prompt": "blurry, low quality",
152
+ "seed": 42,
153
+ "inference_steps": 30,
154
+ "guidance_scale": 7
155
+ }
156
+ }
157
+
158
+ # Send the request
159
+ response = requests.post(API_URL, headers=headers, json=payload)
160
+ result = response.json()
161
+
162
+ # Convert the base64-encoded image to a PIL Image
163
+ image_bytes = base64.b64decode(result[0]["generated_image"])
164
+ image = Image.open(io.BytesIO(image_bytes))
165
+ image.save("generated_image.jpg")
166
+ print(f"Image saved with seed: {result[0]['seed']}")
167
+ ```
168
 
169
  ### Required Files
170