Skip to content

craigmulligan/crowdfactor

Repository files navigation

Crowd Factor

Surf crowd predictions

As a surfer you are constantly trying to assess the best time to surf. This not only involves looking at the forecast and conditions but also gauging when it's going to be most crowded. Sometimes you'll get more waves if you surf when the conditions are a little worse but the spot is less crowded - an exercise in game theory.

In order to make the best decision on when to surf you need forecast data on both the waves conditions and the crowd. The former is easy to get from surfline but there is no data on surf crowds... YET!

The idea is that Crowdfactor provides an interface similar to google maps "popular times", giving a more quantitative approach on deciding when to surf.

Google popular times

How it works

Every 10 mins, Crowdfactor will stream a minute of footage from a configured surfline camera. It then feeds that footage into a computer vision model to count the number of surfers in the water. The surfer count is then saved to a database along with the surf rating at the time of recording.

Vision model counting surfers

With this database you can then make predictions based on the day of the week, time, weather and surf rating. Everyday a model is trained against the existing recordings, which allows you to make increasingly accurate predictions about the future crowd count.

These predictions are visualised along side the real recordings and the forecasted surf ratings for the day on a dashboard.

Dashboard

Usage:

First find your spot on surfline, copy the spot_id from the URL. Then create a roboflow account and get an API key.

Then run it the project with docker-compose:

SURFLINE_SPOT_ID=<spot_id> ROBOFLOW_API_KEY=<roboflow_key> docker-compose up -d

You can view the dashboard at http://localhost.

Development

poetry install
poetry shell

Running the worker:

SURFLINE_SPOT_ID=590927576a2e4300134fbed8 ROBOFLOW_API_KEY=<secret> FLASK_DEBUG=1 FLASK_APP=lib/app python worker.py

Running the server:

SURFLINE_SPOT_ID=590927576a2e4300134fbed8 ROBOFLOW_API_KEY=<secret> FLASK_DEBUG=1 FLASK_APP=lib/app flask run

Deploying on fly.

Adjust the app name in fly.toml if needed.

You'll need to create a volume called crowdfactor_data

fly volume create crowdfactor_data --config ./fly.toml

Then deploy:

fly deploy