| set -e | |
| echo "Starting user embedding model pipeline..." | |
| # Check if model already exists | |
| if [ -f "embeddings_output/model.pth" ]; then | |
| echo "Model already trained." | |
| else | |
| # Check if input data exists | |
| if [ ! -f "$DATA_PATH" ] && [ ! -f "users.json" ]; then | |
| echo "Error: No data file found. Please mount a volume with users.json or set DATA_PATH." | |
| exit 1 | |
| fi | |
| # Run the model generation script | |
| python3 generate_model_gpu.py | |
| echo "Process completed. Check embeddings_output directory for results." | |
| fi | |
| # Get the hostname or public URL if available (for Hugging Face Spaces) | |
| if [ -n "$SPACE_ID" ]; then | |
| # If running in Hugging Face Spaces | |
| BASE_URL="https://${SPACE_ID}.hf.space" | |
| else | |
| # If running locally or in generic Docker | |
| BASE_URL="http://localhost:7860" | |
| fi | |
| echo "==========================================================" | |
| echo "Model is available for download at the following URLs:" | |
| echo "${BASE_URL}/file=embeddings_output/model.pth" | |
| echo "${BASE_URL}/file=embeddings_output/model_config.json" | |
| echo "==========================================================" | |
| # Start the web server to serve files | |
| echo "Starting web server on port 7860..." | |
| python3 -m http.server 7860 |