Spaces:
Sleeping
Sleeping
Hugging Face Spaces Deployment Guide
This guide walks you through deploying the Puja Verification Service on a Hugging Face Docker Space.
Prerequisites
- A Hugging Face account.
- An active API Key from Groq (
GROQ_API_KEY) for the LLM translation/matching. (Note: An HF token is no longer strictly required for our service because we migrated the heavy ASR model away from local PyTorch execution and into the public Gradio API!)
Deployment Steps
1. Create a New Space
- Log into your Hugging Face account.
- Go to your profile and click New Space.
- Fill out the details:
- Space Name: e.g.,
puja-verification-api - License: Choose applicable (e.g.,
mitoropenrail) - Select the Space SDK: Choose Docker
- Docker Template: Choose Blank
- Space Hardware: Since we removed the heavy local PyTorch dependencies, the Free CPU Basic Tier (16GB RAM / 2 vCPU) is more than enough.
- Visibility: Public or Private.
- Space Name: e.g.,
- Click Create Space.
2. Configure Secrets
Your app needs the Groq API key injected securely as an environment variable before it boots.
- Inside your newly created Space, navigate to the Settings tab.
- Scroll down to the Variables and secrets section.
- Under Secrets, click New secret.
- Create the following secret:
- Name:
GROQ_API_KEY - Value: (Paste your Groq API key here)
- Name:
3. Upload Codebase
Hugging Face Spaces are essentially Git repositories. You can upload the code directly via the UI or push via CLI.
Using via Web UI (Easiest)
- Go to the Files tab of your Space.
- Click + Add file > Upload files.
- Upload the following files and folders from your local machine:
Dockerfilerequirements.txtapp/(Upload this entire directory containing all sub-foldersservices,schemas,utils, andmain.py)
- Once you click Commit, the Space will automatically read the
Dockerfileand begin building the container.
Using Git CLI (Advanced)
git clone https://huggingface.co/spaces/<your-username>/<your-space-name>
cd <your-space-name>
# Copy all project files into this directory
git add .
git commit -m "Initial commit for Puja verification API"
git push
4. Monitor Build & Boot
- Go back to the App tab on your Space.
- You should see a "Building..." status pill. You can click Logs to view the container build output. This will install
ffmpegand download the requirements. - Once the status changes to "Running", your API is successfully deployed.
5. Access the Service
The API is now live. Because it is a FastAPI app, you can seamlessly interact with it via the Swagger /docs.
- Click on the settings dropdown in your Space UI -> Embed this Space.
- Obtain the direct URL (it usually looks like
https://<org>-<space-name>.hf.space). - Navigate your browser to
https://<org>-<space-name>.hf.space/docsto see the endpoints and upload test payloads.
🛠️ Performance Optimization Note
You will notice the container runs extraordinarily fast now. By migrating the ai4bharat 600M Conformer to an external Gradio API (rverma0631/MultilingualASR), we:
- Eliminated 6+ GB of Torch/ONNX weights from RAM.
- Slashed the Docker image size significantly, dropping install times from minutes to seconds.
- Preserved the identical NLP pipeline flawlessly.