amazonaws-sp commited on
Commit
9bf53d3
·
verified ·
1 Parent(s): 80431ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -61,8 +61,12 @@ def generate(
61
  if not use_vae:
62
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
63
  response = requests.get(url)
 
 
64
  init_image = Image.open(BytesIO(response.content)).convert("RGB")
65
  init_image = init_image.resize((768, 512))
 
 
66
 
67
  if use_vae:
68
  vae = AutoencoderKL.from_pretrained(vaecall, torch_dtype=torch.float16)
 
61
  if not use_vae:
62
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
63
  response = requests.get(url)
64
+ if response.status_code != 200:
65
+ raise Exception(f"Failed to fetch image from URL: {url}")
66
  init_image = Image.open(BytesIO(response.content)).convert("RGB")
67
  init_image = init_image.resize((768, 512))
68
+ except Exception as e:
69
+ return f"Error fetching image from URL: {str(e)}"
70
 
71
  if use_vae:
72
  vae = AutoencoderKL.from_pretrained(vaecall, torch_dtype=torch.float16)