<s>[INST] import os
import tkinter as tk
from tkinter import filedialog
from PIL import Image, ImageTk
from tkinter import messagebox

def open():
    # Open the file dialog
    root.filename = filedialog.askopenfilename(initialdir=os.getcwd(), filetypes=[("Image Files", ".jpg .jpeg .png .gif")])

    # Open the image
    img = Image.open(root.filename)
    img.thumbnail((400,400))
    img = ImageTk.PhotoImage(img)

    # Create a label for the image
    label = tk.Label(image=img)
    label.image = img  # Keep a reference to avoid garbage collection
    label.pack()

# Create the main window
root = tk.Tk()
root.title("Image Viewer")

# Create the button
button = tk.Button(root, text="Open image", command=open)
button.pack()

# Run the main loop
root.mainloop()

The above code doesn't work properly. The image does not appear in the window. How do I fix it?[/INST]