import os import gradio as gr # Function to print the current working directory def print_current_directory(): current_directory = os.getcwd() print(f"Current working directory: {current_directory}") # Debug function to check image path def check_image_path(image_path): if os.path.exists(image_path): print(f"Image found at {image_path}") return True else: print(f"Image not found at {image_path}") return False # Correct path to the image (adjust if necessary) image_path = "memory_usage.png" # Use an absolute path for the image absolute_image_path = os.path.abspath(image_path) # Gradio interface app = gr.Blocks(css=".scrollable {height: 400px; overflow-y: auto; padding: 10px; border: 1px solid #ccc;}") with app: with gr.Tab("Image Gallery"): if check_image_path(absolute_image_path): gr.Image(value=absolute_image_path, label="Memory Usage", type="filepath") else: gr.HTML(f"
Image not found at {absolute_image_path}
") if __name__ == "__main__": print("Checking the current working directory...") print_current_directory() # Print the current working directory on startup print("Checking if the image path is correct...") check_image_path(absolute_image_path) # Check image path on startup print("Starting Gradio interface...") app.launch()