Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,18 +27,23 @@ CACHE_DIR = "gradio_cached_examples"
|
|
27 |
|
28 |
#for local cache
|
29 |
def load_cached_example_outputs(example_index: int) -> Tuple[str, str]:
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
# Function to handle the example click, it now accepts arbitrary arguments and returns the appropriate cached outputs
|
44 |
def on_example_click(*args, example_index=1, **kwargs):
|
|
|
27 |
|
28 |
#for local cache
|
29 |
def load_cached_example_outputs(example_index: int) -> Tuple[str, str]:
|
30 |
+
# Search for any folder that contains the example index in its name
|
31 |
+
for root, dirs, files in os.walk(CACHE_DIR):
|
32 |
+
for dir_name in dirs:
|
33 |
+
if dir_name.endswith(str(example_index)): # Search for folder ending with the example index
|
34 |
+
cached_dir = os.path.join(root, dir_name)
|
35 |
+
cached_image_path = os.path.join(cached_dir, "processed_image.png")
|
36 |
+
cached_audio_path = os.path.join(cached_dir, "audio.wav")
|
37 |
+
|
38 |
+
# Debugging: Print the paths being checked
|
39 |
+
print(f"Looking for cached image at: {cached_image_path}")
|
40 |
+
print(f"Looking for cached audio at: {cached_audio_path}")
|
41 |
+
|
42 |
+
# Check if the cached files exist
|
43 |
+
if os.path.exists(cached_image_path) and os.path.exists(cached_audio_path):
|
44 |
+
return cached_image_path, cached_audio_path
|
45 |
+
|
46 |
+
raise FileNotFoundError(f"Cached outputs not found for example {example_index}")
|
47 |
|
48 |
# Function to handle the example click, it now accepts arbitrary arguments and returns the appropriate cached outputs
|
49 |
def on_example_click(*args, example_index=1, **kwargs):
|