
'''simple docstring'''







from datetime import datetime

import requests
from bsa import BeautifulSoup

if __name__ == "__main__":
					lowercase    :							Tuple      =					input("Enter image url: ").strip()
					print(F'''Downloading image from {url} ...''')
					lowercase    :							Optional[int]      =					BeautifulSoup(requests.get(url).content, "html.parser")
					# The image URL is in the content field of the first meta tag with property og:image
					lowercase    :							Tuple      =					soup.find("meta", {"property": "og:image"})["content"]
					lowercase    :							Dict      =					requests.get(image_url).content
					lowercase    :							int      =					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}.''')




'''simple docstring'''
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


lowerCamelCase :      Optional[int]					 =     False







class 							A__    (       unittest.TestCase  ):
  pass







@slow
@require_torch_gpu
class 							A__    (       unittest.TestCase  ):





  def 						A  (		self      :	Tuple )	->    Dict:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =VersatileDiffusionImageVariationPipeline.from_pretrained('shi-labs/versatile-diffusion' )
       pipe.to(_a )
       pipe.set_progress_bar_config(disable=_a )

       _SCREAMING_SNAKE_CASE							    =load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg' )
       _SCREAMING_SNAKE_CASE							    =torch.manual_seed(0 )
       _SCREAMING_SNAKE_CASE							    =pipe(
           image=_a							,					generator=_a							,					guidance_scale=7.5							,					num_inference_steps=50							,					output_type='numpy'							,					).images

       _SCREAMING_SNAKE_CASE							    =image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       _SCREAMING_SNAKE_CASE							    =np.array([0.04_41, 0.04_69, 0.05_07, 0.05_75, 0.06_32, 0.06_50, 0.08_65, 0.09_09, 0.09_45] )

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