Spaces:
Sleeping
Sleeping
File size: 839 Bytes
36327d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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.")
|