|
import os |
|
import gradio as gr |
|
|
|
|
|
def print_current_directory(): |
|
current_directory = os.getcwd() |
|
print(f"Current working directory: {current_directory}") |
|
|
|
|
|
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 |
|
|
|
|
|
image_path = "memory_usage.png" |
|
|
|
|
|
absolute_image_path = os.path.abspath(image_path) |
|
|
|
|
|
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("Checking if the image path is correct...") |
|
check_image_path(absolute_image_path) |
|
print("Starting Gradio interface...") |
|
app.launch() |
|
|