While both UPS and the Inverter provide backup power during mains outage, with the UPS the switch is instantaneous, whereas with the Inverter there is a gap of a second or two. In both the cases AC is converted into DC.
This gap is OK for household gadgets such as lights, fans, fridge, etc. but not OK for computers.
UPS: The main AC which is converted into DC is constantly charging the battery. The output of the battery is fed to the Sine wave inverter and it converts DC to AC and this feeds the equipment. Since power out is always drawn from the battery, there is no time lag when mains swicthes off; it just stops the battery from being charged and the UPS continues to supply power till the battery runs out.
Inverter: The main AC which is converted into DC is constantly charging the battery. A sensor and relay mechanism checks whether the mains is ON or OFF. When the main switches OFF, the relay actuator triggers to switch from mains to inverter. Rest is same like the UPS. Because of this sensor and relay, there is a gap between triggering.