Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,11 +60,17 @@ def load_images_from_directory():
|
|
| 60 |
return Load_Data().from_folder([REFERENCE_DATASET_PATH])
|
| 61 |
|
| 62 |
def initialize_search_engine(image_list):
|
|
|
|
|
|
|
|
|
|
| 63 |
search_setup = Search_Setup(
|
| 64 |
image_list=image_list, model_name='vgg19', pretrained=True, image_count=len(image_list)
|
| 65 |
)
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
return search_setup
|
| 69 |
|
| 70 |
# App Initialization
|
|
@@ -77,7 +83,10 @@ def initialize_app():
|
|
| 77 |
image_list = load_images_from_directory()
|
| 78 |
return initialize_search_engine(image_list)
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# Routes
|
| 83 |
@app.get("/health")
|
|
|
|
| 60 |
return Load_Data().from_folder([REFERENCE_DATASET_PATH])
|
| 61 |
|
| 62 |
def initialize_search_engine(image_list):
|
| 63 |
+
if not image_list:
|
| 64 |
+
raise RuntimeError("No images found to initialize the search engine.")
|
| 65 |
+
|
| 66 |
search_setup = Search_Setup(
|
| 67 |
image_list=image_list, model_name='vgg19', pretrained=True, image_count=len(image_list)
|
| 68 |
)
|
| 69 |
+
try:
|
| 70 |
+
with patch('builtins.input', return_value='no'):
|
| 71 |
+
search_setup.run_index()
|
| 72 |
+
except Exception as e:
|
| 73 |
+
raise RuntimeError(f"Error during search engine initialization: {e}")
|
| 74 |
return search_setup
|
| 75 |
|
| 76 |
# App Initialization
|
|
|
|
| 83 |
image_list = load_images_from_directory()
|
| 84 |
return initialize_search_engine(image_list)
|
| 85 |
|
| 86 |
+
try:
|
| 87 |
+
search_setup = initialize_app()
|
| 88 |
+
except Exception as e:
|
| 89 |
+
raise RuntimeError(f"Application initialization failed: {e}")
|
| 90 |
|
| 91 |
# Routes
|
| 92 |
@app.get("/health")
|