fix: idempotent setup (skip env if exists), trim requirements.txt

This commit is contained in:
Kareem Horstink
2026-08-23 16:15:56 +00:00
parent 1b6c167480
commit 027788707e
3 changed files with 54 additions and 29 deletions
+5 -4
View File
@@ -1,12 +1,13 @@
# Photo Judgers — Requirements
# Install in conda env: pip install -r requirements.txt
#
# simple-aesthetics-predictor automatically installs torch + transformers.
# We avoid pinning torchvision/torchaudio here to prevent version mismatch
# with the torch that simple-aesthetics-predictor resolves. Pillow is needed
# for image loading; tqdm for progress bars.
# Core dependencies
simple-aesthetics-predictor
transformers
torch
torchvision
torchaudio
Pillow
tqdm
numpy
+27 -9
View File
@@ -1,6 +1,9 @@
@echo off
REM Photo Judgers — Conda Environment Setup (Windows)
REM Run this from the project root: photo_judgers\setup.bat
REM Idempotent: safe to re-run. Creates env if missing, installs deps.
set ENV_NAME=photo_judgers
echo ========================================
echo Photo Judgers — Setup
@@ -16,30 +19,45 @@ if %ERRORLEVEL% NEQ 0 (
exit /b 1
)
echo Creating conda environment: photo_judgers
echo Python version: 3.11
echo Checking for environment: %ENV_NAME%
echo.
REM Create the conda environment
conda create -y -n photo_judgers python=3.11
REM Check if the environment already exists
conda env list > "%TEMP%\conda_envs.txt" 2>nul
set ENV_EXISTS=
findstr /R /C "^%ENV_NAME%$" "%TEMP%\conda_envs.txt" >nul 2>nul
if %ERRORLEVEL% EQU 0 set ENV_EXISTS=1
del "%TEMP%\conda_envs.txt" 2>nul
if %ERRORLEVEL% NEQ 0 (
if defined ENV_EXISTS (
echo Environment '%ENV_NAME%' already exists. Skipping creation.
) else (
echo Creating conda environment: %ENV_NAME%
echo Python version: 3.11
echo.
conda create -y -n %ENV_NAME% python=3.11
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Failed to create conda environment.
pause
exit /b 1
)
)
echo.
echo Activating environment...
call conda activate photo_judgers
call conda activate %ENV_NAME%
echo.
echo Installing packages...
echo Installing packages from requirements.txt...
echo.
REM Install from requirements.txt
pip install -r requirements.txt
if %ERRORLEVEL% NEQ 0 (
echo.
echo WARNING: Package installation reported an error.
echo Check the messages above.
)
echo.
echo ========================================
echo Setup complete!
+16 -10
View File
@@ -1,9 +1,12 @@
#!/bin/bash
# Photo Judgers — Conda Environment Setup (Linux/Mac)
# Run this from the project root: ./setup.sh
# Idempotent: safe to re-run. Creates env if missing, installs deps.
set -e
ENV_NAME="photo_judgers"
echo "========================================"
echo " Photo Judgers — Setup"
echo "========================================"
@@ -16,23 +19,26 @@ if ! command -v conda &>/dev/null; then
exit 1
fi
echo "Creating conda environment: photo_judgers"
echo "Python version: 3.11"
echo "Checking for environment: ${ENV_NAME}"
echo ""
# Create the conda environment
conda create -y -n photo_judgers python=3.11
# Check if the environment already exists
if conda env list | grep -E "^\s*${ENV_NAME}\s*$" > /dev/null 2>&1; then
echo "Environment '${ENV_NAME}' already exists. Skipping creation."
else
echo "Creating environment '${ENV_NAME}'"
echo "Python version: 3.11"
echo ""
conda create -y -n "${ENV_NAME}" python=3.11
fi
echo ""
echo "Activating environment..."
source $(conda info --base)/etc/profile.d/conda.sh
conda activate photo_judgers
conda activate "${ENV_NAME}"
echo ""
echo "Installing packages..."
echo "Installing packages from requirements.txt..."
echo ""
# Install from requirements.txt
pip install -r requirements.txt
echo ""
@@ -41,7 +47,7 @@ echo " Setup complete!"
echo "========================================"
echo ""
echo "To activate the environment:"
echo " conda activate photo_judgers"
echo " conda activate ${ENV_NAME}"
echo ""
echo "To run the scorer:"
echo " ./run.sh"