{"record":{"id":"bff3054846d66cbd","repo":"XingangPan/DragGAN","slug":"cannot-parse-2-vector-s","errorCode":null,"errorMessage":"cannot parse 2-vector {s}","messagePattern":"cannot parse 2-vector (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"gen_images.py","lineNumber":53,"sourceCode":"        if m:\n            ranges.extend(range(int(m.group(1)), int(m.group(2))+1))\n        else:\n            ranges.append(int(p))\n    return ranges\n\n#----------------------------------------------------------------------------\n\ndef parse_vec2(s: Union[str, Tuple[float, float]]) -> Tuple[float, float]:\n    '''Parse a floating point 2-vector of syntax 'a,b'.\n\n    Example:\n        '0,1' returns (0,1)\n    '''\n    if isinstance(s, tuple): return s\n    parts = s.split(',')\n    if len(parts) == 2:\n        return (float(parts[0]), float(parts[1]))\n    raise ValueError(f'cannot parse 2-vector {s}')\n\n#----------------------------------------------------------------------------\n\ndef make_transform(translate: Tuple[float,float], angle: float):\n    m = np.eye(3)\n    s = np.sin(angle/360.0*np.pi*2)\n    c = np.cos(angle/360.0*np.pi*2)\n    m[0][0] = c\n    m[0][1] = s\n    m[0][2] = translate[0]\n    m[1][0] = -s\n    m[1][1] = c\n    m[1][2] = translate[1]\n    return m\n\n#----------------------------------------------------------------------------\n\n@click.command()","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/XingangPan/DragGAN/blob/336f120ce126aca6f55dc58537e76c10d19eabd0/gen_images.py#L35-L71","documentation":"Raised by legacy.convert_tf_generator when converting an official TensorFlow StyleGAN/StyleGAN2 generator pickle whose internal version attribute is below 4. Only TF pickles of version >= 4 (StyleGAN2 or later configs) are supported by the PyTorch conversion path; older v1-v3 network classes have incompatible static_kwargs and params layout.","triggerScenarios":"Calling legacy.load_network_pickle on a TensorFlow .pkl from the original StyleGAN (v1/v2/v3) repo or an early experimental checkpoint instead of a StyleGAN2-era pickle; converting TF networks exported before the version field was standardized to 4.","commonSituations":"Trying to port weights from the original stylegun/stylegan repo (2019) or stylegan2 TensorFlow pickles with nonstandard versions; pickles re-saved by third-party tools that dropped/renamed the version attribute.","solutions":["Use a StyleGAN2/StyleGAN2-ADA TensorFlow pickle with version >= 4 (the official stylegan2-ada-pytorch ones)","Re-export the TF network from the original stylegan2 repo ensuring version is set","If you must convert an old StyleGAN v1 network, write a custom converter instead of convert_tf_generator","Load pre-converted PyTorch .pkl checkpoints directly (already TorchScript/native) so no TF conversion runs"],"exampleFix":"# before\nG = legacy.load_network_pickle('stylegan1-1024x1024.pkl')  # version < 4 -> ValueError\n\n# after\nG = legacy.load_network_pickle('stylegan2-ffhq-1024x1024.pkl')  # version >= 4 / native","handlingStrategy":"validation","validationCode":"import pickle\nwith open(tf_pkl, 'rb') as f: net = pickle.load(f)\nif net.version < 4:\n    raise ValueError('Needs a StyleGAN2-era (version>=4) TF pickle')","typeGuard":"def is_convertible_tf_generator(tf_G) -> bool:\n    return getattr(tf_G, 'version', 0) >= 4","tryCatchPattern":"try:\n    G = legacy.convert_tf_generator(tf_G)\nexcept ValueError as e:\n    if 'version too low' in str(e):\n        # source a v4 pickle or write a custom converter\n        ...\n    raise","preventionTips":["Use official stylegan2-ada TF exports (version >= 4)","Prefer pre-converted PyTorch pickles","Check the version attribute before attempting conversion"],"tags":["stylegan2","tensorflow","pickle","version-mismatch","model-conversion"],"backgroundTag":"unsupported-checkpoint-version","analyzedSha":"336f120ce126aca6f55dc58537e76c10d19eabd0","analyzedAt":"2026-08-27T06:29:00.251Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}