# Map package names to their import names if they differ package_map = { "ipython": "IPython", "numpy": "numpy", "opencv-python": "cv2", "Pillow": "PIL", "scipy": "scipy", "torch": "torch", "torchvision": "torchvision", "tqdm": "tqdm", "seaborn": "seaborn", "gradio": "gradio", "psutil": "psutil", "pandas": "pandas", } with open("requirements.txt", "w") as f: for package, import_name in package_map.items(): try: mod = __import__(import_name) version = getattr(mod, "__version__", "latest") f.write(f"{package}=={version}\n") except ImportError: f.write(f"{package}\n") print(f"{package} is not installed and version is unknown.") print("requirements.txt file has been created.")