Spaces:
Sleeping
Sleeping
File size: 774 Bytes
25a1f05 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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}") |