Singularity666 commited on
Commit
74c2727
·
1 Parent(s): 33ddfbe

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +1 -16
main.py CHANGED
@@ -28,18 +28,6 @@ def generate_image_from_text(prompt):
28
  else:
29
  r.raise_for_status()
30
 
31
- def resize_image(image_bytes, max_size=(256, 256)):
32
- # Open the image from bytes
33
- img = Image.open(BytesIO(image_bytes))
34
-
35
- # Resize the image
36
- img.thumbnail(max_size)
37
-
38
- # Save it back to bytes
39
- buffer = BytesIO()
40
- img.save(buffer, format="PNG")
41
- return buffer.getvalue()
42
-
43
  def upscale_image_esrgan(image_bytes):
44
  # Set up environment variables
45
  os.environ['ESRGAN_API_KEY'] = ESRGAN_API_KEY
@@ -93,11 +81,8 @@ def main():
93
  st.success("Generating image from text prompt...")
94
  image_bytes = generate_image_from_text(prompt)
95
 
96
- st.success("Resizing image...")
97
- resized_image_bytes = resize_image(image_bytes)
98
-
99
  st.success("Upscaling image with ESRGAN...")
100
- upscaled_image_bytes = upscale_image_esrgan(resized_image_bytes)
101
 
102
  st.success("Further upscaling image with GFPGAN...")
103
  img = further_upscale_image(upscaled_image_bytes)
 
28
  else:
29
  r.raise_for_status()
30
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  def upscale_image_esrgan(image_bytes):
32
  # Set up environment variables
33
  os.environ['ESRGAN_API_KEY'] = ESRGAN_API_KEY
 
81
  st.success("Generating image from text prompt...")
82
  image_bytes = generate_image_from_text(prompt)
83
 
 
 
 
84
  st.success("Upscaling image with ESRGAN...")
85
+ upscaled_image_bytes = upscale_image_esrgan(image_bytes)
86
 
87
  st.success("Further upscaling image with GFPGAN...")
88
  img = further_upscale_image(upscaled_image_bytes)