CoolFace
Modelpublic

fernandoperlar/preprocessing_image

sourceHugging Faceupdated 5y agoView on Hugging Face
0likes
Misc.py26 linesDownload Raw Back to scripts
1import tensorflow as tf2import os3import shutil4 5class computer:6	# This function checks if the model is running on the CPU or GPU7	def check_available_devices():8		print("Available devices:")9		for device in tf.config.experimental.list_physical_devices():10			print(f"- {device.device_type}: {device.name}")11 12		if len(tf.config.list_physical_devices("GPU")) == 0:13			print("\nCannot run model on GPU. Do you want to run it with the CPU? [Y/N]: ")14			if input().upper() != "Y":15				raise SystemExit("Execution of the model has been canceled!")16 17	def create_output_folder(subfolder, new=True):18		if new and os.path.exists("output/" + subfolder):19			shutil.rmtree("output/" + subfolder)20 21		if not os.path.exists("output"):22			os.makedirs("output")23 24		if not os.path.exists("output/" + subfolder):25			os.makedirs("output/" + subfolder)26