Spaces:
Sleeping
Sleeping
Directory Overview | |
This directory contains two essential files for the overall project as well as the demo application: | |
1. gen_utilities.py | |
This module provides a collection of utility functions and classes commonly used across various parts of the application. These utilities include functions for displaying images, checking the runtime environment, generating paths, and managing GPU resources. | |
Functions: | |
- show_image(image): Display an image in various environments. | |
- show_image_with_matplotlib(image): Display an image using Matplotlib. | |
- is_jupyter_notebook() -> bool: Check if the code is running in a Jupyter notebook. | |
- is_pycharm() -> bool: Check if the code is running in PyCharm. | |
- is_google_colab() -> bool: Check if the code is running in Google Colab. | |
- get_image_path(name, path_type) -> str: Generate a path for models, images, or data based on the specified type. | |
- get_model_path(model_name) -> str: Get the path to the specified model folder. | |
- add_detected_objects_to_dataframe(df, detector_type, image_directory, detector) -> pd.DataFrame: Add a column to the DataFrame with detected objects for each image. | |
- free_gpu_resources() -> None: Clear GPU memory. | |
Notes: | |
- Ensure the required packages are installed (`numpy`, `torch`, `PIL`, `matplotlib`, `pandas`, `IPython`, `sys`). | |
- Supports various image formats (file paths, PIL Images, numpy arrays, PyTorch tensors). | |
- add_detected_objects_to_dataframe assumes an appropriate object detector is provided and configured. | |
2. ui_manager.py | |
The UIManager class manages the user interface for the Streamlit application, handling the creation and navigation of various tabs. | |
Class Overview: | |
- UIManager: Manages the Streamlit app UI. | |
- __init__(): Initializes the UIManager with predefined tabs. | |
- add_tab(tab_name: str, display_function: callable) -> None: Adds a new tab to the UI. | |
- display_sidebar() -> str: Displays the sidebar for navigation. | |
- display_selected_page(selection: str) -> None: Displays the selected page based on the user's choice. | |
- display_home() -> None: Displays the Home page. | |
- display_dataset_analysis() -> None: Displays the Dataset Analysis page. | |
- display_results() -> None: Displays the Results page. | |
- display_model_arch() -> None: Displays the Model Architecture page. | |
- display_run_inference() -> None: Displays the Run Inference page. | |
- display_dissertation_report() -> None: Displays the Dissertation Report page. | |
- display_code() -> None: Displays the Code page. | |
- display_placeholder() -> None: Displays a placeholder for future content. | |
Notes: | |
- The UIManager class facilitates the navigation and rendering of different tabs in the Streamlit app. | |
- Customize and extend the UI by adding new tabs with `add_tab`. | |