1
0
Fork 0

Add: finction to handel yes no prompts

This commit is contained in:
Aroy-Art 2024-09-02 21:34:53 +02:00
parent f5e79bae5b
commit 977be10b92
Signed by: Aroy
GPG key ID: DB9689E9391DD156

View file

@ -6,6 +6,40 @@ from tensorflow.keras.applications.vgg19 import preprocess_input
import faiss import faiss
import cv2 import cv2
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is True for "yes" or False for "no".
"""
valid = {"yes": True, "y": True, "ye": True,
"no": False, "n": False}
if default is None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
else:
raise ValueError("invalid default answer: '%s'" % default)
while True:
sys.stdout.write(question + prompt)
choice = input().lower()
if default is not None and choice == '':
return valid[default]
elif choice in valid:
return valid[choice]
else:
sys.stdout.write("Please respond with 'yes' or 'no' "
"(or 'y' or 'n').\n")
model = vgg19.VGG19(weights="imagenet", include_top=False, pooling="avg") model = vgg19.VGG19(weights="imagenet", include_top=False, pooling="avg")