Let G be a triangle-free graph with n vertices and average degree t. We show that G contains at least exp( (1 - n(-1/12))1/2 n/1 In t (1/2 In t - 1)) independent sets. This improves a recent result of the first and third authors [8]. In particular, it implies that as n -> infinity every triangle-free graph on n vertices has at least e((c1-0(1))root n In n) independent sets, where c(1) = root ln 2/4 = 0.28138 ... Further, we show that for all n, there exists a triangle-free graph with n vertices which has at most e((c2 + o(1)) root n) l(n n) independent sets, where c(2) = 2 root ln2 = 1.665109 ... This disproves a conjecture from [8]. Let H be a (k + 1)-uniform linear hypergraph with n vertices and average degree t. We also show that there exists a constant c(k) such that the number of independent sets in H is at least exp(c(k) n/t(1/k) ln(1+1/k) t). This is tight apart from the constant c(k) and generalizes a result of Duke, Lefmann and Roodl [9], which guarantees the existence of an independent set of size Omega(n/t(1-k) ln(1/k) t). Both of our lower bounds follow from a more general statement, which applies to hereditary properties of hypergraphs.