Real-time gravitational-wave inference for binary neutron stars using machine learning