Update infer.py
Browse files9 unmodified lines1011121314159 unmodified linesdevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')def infer_video(video_filepath: str, size_modifier: int) -> str:model = RealESRGAN(device, scale=size_modifier)9 unmodified lines1011121314151617181920212223242526272829309 unmodified linesdevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')def infer_image(img: Image.Image, size_modifier: int ) -> Image.Image:if img is None:raise Exception("Image not uploaded")width, height = img.sizeif width >= 5000 or height >= 5000:raise Exception("The image is too large.")model = RealESRGAN(device, scale=size_modifier)model.load_weights(f'weights/RealESRGAN_x{size_modifier}.pth', download=False)result = model.predict(img.convert('RGB'))print(f"Image size ({device}): {size_modifier} ... OK")return resultdef infer_video(video_filepath: str, size_modifier: int) -> str:model = RealESRGAN(device, scale=size_modifier)
infer.py+15