Flame acceleration and transition from deflagration to detonation in hydrogen explosions