Spaces:
Sleeping
Sleeping
test: fixed typo
Browse files
app.py
CHANGED
@@ -28,7 +28,9 @@ _CACHE = {
|
|
28 |
'sae_data_dict': {},
|
29 |
'model_data': {},
|
30 |
'segmasks': {},
|
31 |
-
'top_images': {}
|
|
|
|
|
32 |
}
|
33 |
|
34 |
def load_all_data(image_root: str, pkl_root: str) -> Tuple[Dict, Dict]:
|
@@ -638,6 +640,8 @@ def precompute_segmasks():
|
|
638 |
except Exception as e:
|
639 |
print(f"Error precomputing mask {cache_key}: {e}")
|
640 |
|
|
|
|
|
641 |
|
642 |
with gr.Blocks(
|
643 |
theme=gr.themes.Citrus(),
|
@@ -837,6 +841,13 @@ if __name__ == "__main__":
|
|
837 |
|
838 |
# Configure cache sizes based on available RAM
|
839 |
cache_size = int(total_ram_gb * 100) # Rough estimate: 100 entries per GB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
840 |
|
841 |
# Memory monitoring function
|
842 |
def monitor_memory_usage():
|
@@ -859,18 +870,6 @@ if __name__ == "__main__":
|
|
859 |
import threading
|
860 |
start_memory_monitor()
|
861 |
|
862 |
-
|
863 |
-
# Add to initialization
|
864 |
-
preload_all_model_data()
|
865 |
-
|
866 |
-
_CACHE['precomputed_activations'] = {}
|
867 |
-
precompute_activations()
|
868 |
-
precompute_segmasks()
|
869 |
-
|
870 |
-
data_dict, sae_data_dict = load_all_data(image_root="./data/image", pkl_root=pkl_root)
|
871 |
-
default_image_name = "christmas-imagenet"
|
872 |
-
|
873 |
-
|
874 |
# Launch the app with memory-optimized settings
|
875 |
demo.queue(max_size=min(20, int(total_ram_gb))) # Scale queue with RAM
|
876 |
demo.launch(
|
|
|
28 |
'sae_data_dict': {},
|
29 |
'model_data': {},
|
30 |
'segmasks': {},
|
31 |
+
'top_images': {},
|
32 |
+
'precomputed_activations' = {}
|
33 |
+
|
34 |
}
|
35 |
|
36 |
def load_all_data(image_root: str, pkl_root: str) -> Tuple[Dict, Dict]:
|
|
|
640 |
except Exception as e:
|
641 |
print(f"Error precomputing mask {cache_key}: {e}")
|
642 |
|
643 |
+
data_dict, sae_data_dict = load_all_data(image_root="./data/image", pkl_root=pkl_root)
|
644 |
+
default_image_name = "christmas-imagenet"
|
645 |
|
646 |
with gr.Blocks(
|
647 |
theme=gr.themes.Citrus(),
|
|
|
841 |
|
842 |
# Configure cache sizes based on available RAM
|
843 |
cache_size = int(total_ram_gb * 100) # Rough estimate: 100 entries per GB
|
844 |
+
|
845 |
+
# Precompute all data
|
846 |
+
print("Starting precomputation...")
|
847 |
+
preload_all_model_data()
|
848 |
+
precompute_activations()
|
849 |
+
precompute_segmasks()
|
850 |
+
print("Precomputation complete!")
|
851 |
|
852 |
# Memory monitoring function
|
853 |
def monitor_memory_usage():
|
|
|
870 |
import threading
|
871 |
start_memory_monitor()
|
872 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
873 |
# Launch the app with memory-optimized settings
|
874 |
demo.queue(max_size=min(20, int(total_ram_gb))) # Scale queue with RAM
|
875 |
demo.launch(
|