Update segment code in pyteaser and text2img