




"""simple docstring"""






import numpy as np
import torch
import torch.nn as nn
from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel

from ...utils import logging


lowercase__     						=						logging.get_logger(__name__)






class lowerCAmelCase__	(     lowercase						):






			'''simple docstring'''



			lowerCamelCase__      =			CLIPConfig

			lowerCamelCase__      =			["""CLIPEncoderLayer"""]
			def __init__(  self  ,      lowercase  ):
							super().__init__(lowercase  )

							_lowerCamelCase     :			List[str]    =    CLIPVisionModelWithProjection(config.vision_config  )

							_lowerCamelCase     :			List[Any]    =    nn.Linear(config.vision_config.projection_dim  ,      1  )
							_lowerCamelCase     :			Dict    =    nn.Linear(config.vision_config.projection_dim  ,      1  )






			@torch.no_grad()
			def 					A_    (  self  ,      lowercase  ,      lowercase  ,      lowercase=0.5  ,      lowercase=0.5  ):
							_lowerCamelCase     :			Dict    =    self.vision_model(lowercase  )[0]

							_lowerCamelCase     :			Any    =    self.p_head(lowercase  )
							_lowerCamelCase     :			str    =    nsfw_detected.flatten()
							_lowerCamelCase     :			int    =    nsfw_detected > p_threshold
							_lowerCamelCase     :			Union[str, Any]    =    nsfw_detected.tolist()

							if any(lowercase  ):
											logger.warning(
											    'Potential NSFW content was detected in one or more images. A black image will be returned instead.'
											    ' Try again with a different prompt and/or seed.'  )

							for idx, nsfw_detected_ in enumerate(lowercase  ):
											if nsfw_detected_:
															_lowerCamelCase     :			Dict    =    np.zeros(images[idx].shape  )

							_lowerCamelCase     :			Dict    =    self.w_head(lowercase  )
							_lowerCamelCase     :			Tuple    =    watermark_detected.flatten()
							_lowerCamelCase     :			Dict    =    watermark_detected > w_threshold
							_lowerCamelCase     :			Dict    =    watermark_detected.tolist()

							if any(lowercase  ):
											logger.warning(
											    'Potential watermarked content was detected in one or more images. A black image will be returned instead.'
											    ' Try again with a different prompt and/or seed.'  )

							for idx, watermark_detected_ in enumerate(lowercase  ):
											if watermark_detected_:
															_lowerCamelCase     :			List[str]    =    np.zeros(images[idx].shape  )

							return images, nsfw_detected, watermark_detected





from datetime import datetime

import requests


def    A						(__A   :    str       )   ->      bytes:







     """simple docstring"""


     UpperCAmelCase_          =							'''https://downloadgram.net/wp-json/wppress/video-downloader/video?url='''
     UpperCAmelCase_          =							requests.get(base_url + url       ).json()[0]['''urls'''][0]['''src''']
     return requests.get(__A       ).content


if __name__ == "__main__":
    snake_case_ : Optional[Any]    		=       input("Enter Video/IGTV url: ").strip()
    snake_case_ : Any    		=       f"{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4"
    with open(file_name, "wb") as fp:
        fp.write(download_video(url))
    print(f"Done. Video saved to disk as {file_name}.")






