# Hybrid Deployment Setup Instructions This document provides detailed instructions for setting up the hybrid deployment of the AI-Powered Facial and Body Feature Editor, which uses your local GPU for processing while keeping the interface hosted on Hugging Face Spaces. ## Overview The hybrid deployment consists of two components: 1. **Hugging Face Space** - Hosts the user interface and handles file uploads 2. **Local GPU Server** - Runs on your computer and processes the images using your NVIDIA 3060 GPU This approach gives you the best of both worlds: the convenience of a hosted web application with the performance of your local GPU. ## Requirements ### For the Local Server - Python 3.8 or higher - PyTorch with CUDA support - NVIDIA GPU with at least 6GB VRAM (your NVIDIA 3060 with 6GB is perfect) - The following Python packages: - gradio - torch - torchvision - diffusers - transformers - opencv-python - pillow - numpy ## Step 1: Set Up the Local Server 1. Download the entire project zip file and extract it to a folder on your computer. 2. Install the required dependencies: ```bash pip install -r requirements.txt ``` 3. Make sure you have PyTorch with CUDA support: ```bash pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 ``` 4. Run the local server: ```bash python local_server.py ``` 5. The server will start and display a URL like `https://12345.gradio.app` (your number will be different). This is your local server's public URL. 6. Keep this terminal window open while using the application. ## Step 2: Update the Hugging Face Space 1. In your Hugging Face Space repository, replace the current `app.py` file with the `app_hybrid.py` file. 2. Rename `app_hybrid.py` to `app.py` or update the file directly. 3. Commit and push the changes: ```bash git add app.py git commit -m "Update to hybrid deployment mode" git push ``` 4. Hugging Face will automatically rebuild your Space with the updated code. ## Step 3: Connect the Components 1. Once your Hugging Face Space is rebuilt, open it in your browser. 2. In the "Local GPU Server Connection" section, paste the URL from your local server (the `https://12345.gradio.app` URL). 3. Click "Check Connection" to verify that the connection is working. 4. If the connection is successful, you'll see "Connected successfully" in the status field. 5. Now you can upload images and use the application as normal, but all processing will be done on your local GPU. ## Performance Tuning You can adjust the following settings to balance quality and performance: 1. **Inference Steps**: Lower values (10-15) are faster, higher values (30-50) give better quality. 2. **Guidance Scale**: Controls how closely the model follows your prompt. Values between 5-10 work well. 3. **Processing Resolution**: Lower resolutions are faster but may lose detail. 512x512 is a good balance. ## Troubleshooting ### Connection Issues - Make sure your local server is running - Check that you've entered the correct URL - Ensure your firewall isn't blocking the connection - Try restarting the local server ### GPU Memory Issues - Reduce the inference steps - Use a lower processing resolution - Close other GPU-intensive applications ### Image Processing Errors - Try using a different image - Reduce the complexity of your edits - Check the local server terminal for error messages ## Security Considerations The local server creates a temporary public URL that anyone can access while it's running. For security: 1. Only run the local server when you're actively using the application 2. Stop the server when you're done (Ctrl+C in the terminal) 3. Don't share your local server URL with others unless you want them to use your GPU ## Additional Notes - The local server will use your GPU resources, which might affect other applications running on your computer - Processing time will vary based on your GPU capabilities, but should be significantly faster than the CPU-only version - You can monitor GPU usage in the local server interface or using tools like NVIDIA Task Manager