Spaces:
Sleeping
Sleeping
Rename zero_shot_classification.py to app.py
Browse files56 unmodified lines575859606162639 unmodified lines737475767778798026 unmodified lines10710810911011111211311411511611711811912012112212356 unmodified lines"""model_key = "CLIP-large"# Load model (cache for speed)if model_key not in MODEL_CACHE:9 unmodified linescandidate_labels = CANDIDATE_LABELS,hypothesis_template = "This image shows {}")print("\n\n=============================================================================")print(f"\nPrediction: This image shows {output[0]["label"]} | Confidence (probability): {100*output[0]["score"]: .1f}%")def run_classifer(model_key, image_path, prob_threshold = None):# model_key: name of backbone zero-shot-image-classification model to use26 unmodified linesreturn predicted_label_str, prob_dict# example runmodel_key = "CLIP-large"BASE_DIR = '/content/drive/MyDrive/ML Projects/Zero-shot Image Classification/Images'image_path = os.path.join(BASE_DIR, 'Nail2_1.png')predicted_label_str, prob_dict = run_classifer(model_key, image_path, prob_threshold = 0.4)print("\n\n=============================================================================")# print(f"\nPrediction: {predicted_label_str} | Confidence (probability): {100*output[0]['score']:.1f}%")print(f"\nPrediction: {predicted_label_str}")prob_dict"""### Gradio App56 unmodified lines575859606162639 unmodified lines737475767778798026 unmodified lines10710810911011111211311411511611711811912012156 unmodified lines"""# model_key = "CLIP-large"# Load model (cache for speed)if model_key not in MODEL_CACHE:9 unmodified linescandidate_labels = CANDIDATE_LABELS,hypothesis_template = "This image shows {}")# print("\n\n=============================================================================")# print(f"\nPrediction: This image shows {output[0]["label"]} | Confidence (probability): {100*output[0]["score"]: .1f}%")def run_classifer(model_key, image_path, prob_threshold = None):# model_key: name of backbone zero-shot-image-classification model to use26 unmodified linesreturn predicted_label_str, prob_dict# # example run# model_key = "CLIP-large"# BASE_DIR = '/content/drive/MyDrive/ML Projects/Zero-shot Image Classification/Images'# image_path = os.path.join(BASE_DIR, 'Nail2_1.png')# predicted_label_str, prob_dict = run_classifer(model_key, image_path, prob_threshold = 0.4)# print("\n\n=============================================================================")# # print(f"\nPrediction: {predicted_label_str} | Confidence (probability): {100*output[0]['score']:.1f}%")# print(f"\nPrediction: {predicted_label_str}")"""### Gradio App
zero_shot_classification.py → app.pyRenamed+11-13