|
|
import kagglehub |
|
|
import os |
|
|
import random |
|
|
from PIL import Image |
|
|
|
|
|
|
|
|
path = kagglehub.dataset_download("imreallyjohn/cartoonset10k") |
|
|
|
|
|
print("Path to dataset files:", path) |
|
|
|
|
|
|
|
|
images_folder = os.path.join(path, "/content/CartoonAvatar/CartoonAvatar") |
|
|
image_files = [f for f in os.listdir(images_folder) if f.endswith('.png')] |
|
|
|
|
|
if image_files: |
|
|
|
|
|
random_image_filename = random.choice(image_files) |
|
|
image_path = os.path.join(images_folder, random_image_filename) |
|
|
|
|
|
|
|
|
selected_image = Image.open(image_path) |
|
|
selected_image.show() |
|
|
print(f"Displayed image: {random_image_filename}") |
|
|
display(selected_image) |
|
|
else: |
|
|
print("No available images to display.") |
|
|
|