






"""simple docstring"""
import unittest

import numpy as np
import torch

from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device


enable_full_determinism()


class _lowerCAmelCase						(    unittest.TestCase       ):







						@property
						def 			A      (    self							)		->							Any:
										torch.manual_seed(0							)
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    UNetaDModel(
										    block_out_channels=(3_2, 6_4)   ,				layers_per_block=2   ,				sample_size=3_2   ,				in_channels=3   ,				out_channels=3   ,				down_block_types=('DownBlock2D', 'AttnDownBlock2D')   ,				up_block_types=('AttnUpBlock2D', 'UpBlock2D')   ,				)
										return model







						def 			A      (    self							)		->							Dict:
										_SCREAMING_SNAKE_CASE   :		int       		=    self.dummy_uncond_unet
										_SCREAMING_SNAKE_CASE   :		int       		=    ScoreSdeVeScheduler()

										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    ScoreSdeVePipeline(unet=lowerCAmelCase_   ,				scheduler=lowerCAmelCase_							)
										sde_ve.to(lowerCAmelCase_							)
										sde_ve.set_progress_bar_config(disable=lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    torch.manual_seed(0							)
										_SCREAMING_SNAKE_CASE   :		Any       		=    sde_ve(num_inference_steps=2   ,				output_type='numpy'   ,				generator=lowerCAmelCase_							).images

										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    torch.manual_seed(0							)
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    sde_ve(num_inference_steps=2   ,				output_type='numpy'   ,				generator=lowerCAmelCase_   ,				return_dict=lowerCAmelCase_							)[
										    0
										]

										_SCREAMING_SNAKE_CASE   :		int       		=    image[0, -3:, -3:, -1]
										_SCREAMING_SNAKE_CASE   :		str       		=    image_from_tuple[0, -3:, -3:, -1]

										assert image.shape == (1, 3_2, 3_2, 3)
										_SCREAMING_SNAKE_CASE   :		Any       		=    np.array([0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]							)

										assert np.abs(image_slice.flatten() - expected_slice							).max() < 1e-2
										assert np.abs(image_from_tuple_slice.flatten() - expected_slice							).max() < 1e-2







@slow
@require_torch
class _lowerCAmelCase						(    unittest.TestCase       ):







						def 			A      (    self							)		->							Optional[Any]:
										_SCREAMING_SNAKE_CASE   :		Any       		=    'google/ncsnpp-church-256'
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    UNetaDModel.from_pretrained(lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE   :		Tuple       		=    ScoreSdeVeScheduler.from_pretrained(lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    ScoreSdeVePipeline(unet=lowerCAmelCase_   ,				scheduler=lowerCAmelCase_							)
										sde_ve.to(lowerCAmelCase_							)
										sde_ve.set_progress_bar_config(disable=lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE   :		List[str]       		=    torch.manual_seed(0							)
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    sde_ve(num_inference_steps=1_0   ,				output_type='numpy'   ,				generator=lowerCAmelCase_							).images

										_SCREAMING_SNAKE_CASE   :		Dict       		=    image[0, -3:, -3:, -1]

										assert image.shape == (1, 2_5_6, 2_5_6, 3)

										_SCREAMING_SNAKE_CASE   :		Tuple       		=    np.array([0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0]							)

										assert np.abs(image_slice.flatten() - expected_slice							).max() < 1e-2









"""simple docstring"""
from datetime import datetime

import requests
from bsa import BeautifulSoup

if __name__ == "__main__":
			lowerCAmelCase__    						=			input('Enter image url: ').strip()
			print(F'Downloading image from {url} ...')
			lowerCAmelCase__    						=			BeautifulSoup(requests.get(url).content, 'html.parser')
			# The image URL is in the content field of the first meta tag with property og:image
			lowerCAmelCase__    						=			soup.find('meta', {'property': 'og:image'})['content']
			lowerCAmelCase__    						=			requests.get(image_url).content
			lowerCAmelCase__    						=			F'{datetime.now():%Y-%m-%d_%H:%M:%S}.jpg'
			with open(file_name, 'wb') as fp:
						fp.write(image_data)
			print(F'Done. Image saved to disk as {file_name}.')

