File size: 1,380 Bytes
9382e3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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"<p>Image not found at {absolute_image_path}</p>")

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()