akhaliq HF staff commited on
Commit
d06af8a
1 Parent(s): c3a4b53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1,6 +1,9 @@
1
  import gradio as gr
2
  import fal_client
3
  import time
 
 
 
4
 
5
  def generate_image(api_key, prompt, image_size, num_images, enable_safety_checker, safety_tolerance):
6
  try:
@@ -13,7 +16,7 @@ def generate_image(api_key, prompt, image_size, num_images, enable_safety_checke
13
  "Square": "square",
14
  "Portrait 4:3": "portrait_4_3",
15
  "Portrait 16:9": "portrait_16_9",
16
- "Landscape 4:3": "landscape_4_3",
17
  "Landscape 16:9": "landscape_16_9"
18
  }
19
 
@@ -50,7 +53,10 @@ def generate_image(api_key, prompt, image_size, num_images, enable_safety_checke
50
  images = []
51
  for image_info in result["images"]:
52
  image_url = image_info["url"]
53
- images.append(image_url)
 
 
 
54
 
55
  return images if len(images) > 1 else images[0]
56
  except Exception as e:
 
1
  import gradio as gr
2
  import fal_client
3
  import time
4
+ import requests
5
+ from io import BytesIO
6
+ from PIL import Image
7
 
8
  def generate_image(api_key, prompt, image_size, num_images, enable_safety_checker, safety_tolerance):
9
  try:
 
16
  "Square": "square",
17
  "Portrait 4:3": "portrait_4_3",
18
  "Portrait 16:9": "portrait_16_9",
19
+ "Landscape 4:3", "landscape_4_3",
20
  "Landscape 16:9": "landscape_16_9"
21
  }
22
 
 
53
  images = []
54
  for image_info in result["images"]:
55
  image_url = image_info["url"]
56
+ # Download the image
57
+ response = requests.get(image_url)
58
+ image = Image.open(BytesIO(response.content))
59
+ images.append(image)
60
 
61
  return images if len(images) > 1 else images[0]
62
  except Exception as e: