fal-ai / aura-sr

AuraSR: GAN-based Super-Resolution for real-world
Creative Commons Attribution Share Alike 4.0 International
381 stars 30 forks source link

Need to specify python version in setup.py #11

Open pelennor opened 3 weeks ago

pelennor commented 3 weeks ago

Hello.

It should be specified the minimum required python version in setup.py. If not, python would raise TypeError like below.

# error in Python 3.8
File "/home/user/miniconda3/envs/aura_sr/lib/python3.8/site-packages/aura_sr.py", line 772, in AuraSR
    def __init__(self, config: dict[str, Any], device: str = "cuda"):
TypeError: 'type' object is not subscriptable

Because the new type annotation dict[str, Any] was introduced in Python 3.9.

So, there are two options. First, you specify argument python_requires in setup func in setup.py.

# setup.py
from setuptools import setup

setup(
    name="aura-sr",
    ...., # same as it is
    python_requires='>=3.9'
)

Second, modify __init__ method of class AuraSR in aura_sr.py for backward comparability with older than Python 3.9

# aura_sr.py
from typing import Dict, Any

...  # existing code

class AuraSR:
    def __init__(self, config: Dict[str, Any], device: str = "cuda"):
        self.upsampler = UnetUpsampler(**config).to(device)
        self.input_image_size = config["input_image_size"]

...  # existing code