Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| from PIL import Image | |
| from io import BytesIO | |
| # Create examples directory if it doesn't exist | |
| os.makedirs("examples", exist_ok=True) | |
| # URL of the example image | |
| image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" | |
| # Download and save the image | |
| response = requests.get(image_url) | |
| if response.status_code == 200: | |
| # Open the image from the response content | |
| img = Image.open(BytesIO(response.content)) | |
| # Save the image to the examples directory | |
| img.save("examples/nature.jpg") | |
| print("Example image downloaded successfully!") | |
| else: | |
| print(f"Failed to download image. Status code: {response.status_code}") |