A Streamlit app that counts people in conference session photos using Snowflake Cortex AISQL. It detects raised hands too, which is handy for tracking badge giveaways or audience engagement.
- Counts attendees in uploaded photos
- Detects raised hands
- Shows conversion rates (hands up vs total people)
- Displays images with interactive analytics
- Snowflake Cortex AISQL for image analysis
- Streamlit in Snowflake for the app
- Snowflake CLI for setup automation
- Python, Altair for charts
- Snowflake account with Cortex AISQL enabled (sign up here if you don't have one)
- Snowflake CLI installed and configured
- Task (optional, for automation)
Copy the example environment file and update with your values:
cp .env.example .envEdit .env with your Snowflake connection details:
# Snowflake Connection
SNOWFLAKE_ACCOUNT=your_account
SNOWFLAKE_USER=your_username
SNOWFLAKE_ROLE=your_role
SNOWFLAKE_WAREHOUSE=your_warehouse
# Application Configuration
SNOWFLAKE_DATABASE=CROWD_COUNTER_DB
SNOWFLAKE_SCHEMA=CONFERENCES
SNOWFLAKE_STAGE=SNAPS
# AI Model
AI_MODEL=claude-4-sonnetChoose one of the following methods:
# Verify Snowflake CLI connection
task snow:check
# Preview rendered SQL (dry run)
task snow:setup:dry-run
# Create all Snowflake objects
task snow:setupThe setup script uses Jinja2 templating for variable substitution:
snow sql -f setup.sql --templating=ALL \
-D database=CROWD_COUNTER_DB \
-D schema=CONFERENCES \
-D stage=SNAPS \
-D ai_model=claude-4-sonnetIf you prefer working directly in Snowflake's UI without installing any CLI tools:
- Open Snowsight and navigate to Worksheets
- Create a new SQL Worksheet in your Workspace
- Copy the contents of
setup.sqlinto the worksheet - Replace the Jinja2 variables with your values:
{{ db }}→CROWD_COUNTER_DB(or your database name){{ sch }}→CONFERENCES(or your schema name){{ stg }}→SNAPS(or your stage name){{ model }}→claude-4-sonnet(or your preferred model)
- Run all statements (Ctrl/Cmd + Shift + Enter)
Tip: Use Find and Replace (Ctrl/Cmd + H) to quickly substitute all variables.
Upload setup.sql to a stage, then run:
EXECUTE IMMEDIATE FROM @my_stage/setup.sql
USING (database => 'CROWD_COUNTER_DB',
schema => 'CONFERENCES',
stage => 'SNAPS',
ai_model => 'claude-4-sonnet');Upload app.py to your Snowflake environment and create a Streamlit app using Snowflake's native Streamlit support.
With the app:
- Select your database and schema from the dropdowns
- Upload conference photos (JPG, PNG, JPEG)
- Wait for the analysis to complete
- Click on any row to see the image and detailed charts
From command line:
# Upload images
task snow:upload -- /path/to/photos/*.jpg
# List uploaded files
task snow:list
# Query results
task snow:queryRun task to see all available commands:
| Task | Description |
|---|---|
task snow:check |
Verify Snowflake CLI is installed and configured |
task snow:setup |
Create all Snowflake objects |
task snow:setup:dry-run |
Preview rendered SQL without executing |
task snow:upload -- FILES |
Upload images to stage |
task snow:list |
List files in stage |
task snow:query |
Query the crowd counter view |
task snow:refresh |
Refresh stage directory |
task snow:clean |
Remove files from stage |
task snow:teardown |
Drop all created objects (DESTRUCTIVE) |
All configuration is managed through environment variables in .env:
| Variable | Default | Description |
|---|---|---|
SNOWFLAKE_DATABASE |
CROWD_COUNTER_DB |
Target database |
SNOWFLAKE_SCHEMA |
CONFERENCES |
Target schema |
SNOWFLAKE_STAGE |
SNAPS |
Stage for images |
AI_MODEL |
claude-4-sonnet |
Cortex AI model |
smart-crowd-counter/
├── app.py # Streamlit application
├── setup.sql # Snowflake object creation
├── Taskfile.yml # Task automation
├── environment.yml # Conda dependencies
├── .env.example # Environment template
├── LICENSE # Apache 2.0
├── NOTICE # Attribution notices
└── CITATION.cff # Citation metadata
- Snowflake for Cortex AISQL
- Streamlit for making web apps easy
This project is open source under Apache 2.0. You're welcome to use, modify, and share it!
If you use this project, please:
- Keep the copyright notices and NOTICE file intact
- Credit the original author in your README or documentation:
Based on Smart Crowd Counter by Kamesh Sampath
- If presenting at events or demos, mention the original creator
- Consider starring the repo if it helped you
For academic or formal citations, click the "Cite this repository" button on GitHub or see CITATION.cff.
Copyright 2026 Kamesh Sampath
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.