Local Testing Guide
Before deploying to Hugging Face Spaces, you may want to test the application locally. This guide provides instructions for local testing.
Prerequisites
- CUDA-capable GPU with at least 8GB VRAM
- Python 3.8+
- pip or conda package manager
Steps for Local Testing
- Install Dependencies
pip install -r image_descriptor_requirements.txt
- Run in UI Mode
python app.py
This will start the Gradio UI on http://localhost:7860. You can upload images and test the model.
- Run in API-only Mode
FLASK_APP=image_descriptor.py flask run --host=0.0.0.0 --port=5000
This will start just the Flask API on http://localhost:5000.
- Test the Docker Container
# Build the container
docker build -t image-descriptor .
# Run the container
docker run -p 7860:7860 --gpus all image-descriptor
The application will be available at http://localhost:7860.
Testing the API
You can test the API using curl:
# Health check
curl http://localhost:5000/health
# Process an image
curl -X POST -F "image=@data_temp/page_2.png" http://localhost:5000/describe
Troubleshooting
- GPU Memory Issues: If you encounter GPU memory errors, try reducing batch sizes or using a smaller model.
- Model Download Issues: If the model download fails, try downloading it manually from Hugging Face and place it in the
.cache/huggingface/transformers
directory. - Dependencies: Make sure you have the correct CUDA version installed for your GPU.
Next Steps
Once you've confirmed the application works locally, you can deploy it to Hugging Face Spaces following the instructions in the main README.md.