Counting sheaves by counting curves