John Smith commited on
Commit
e5e6cc5
·
1 Parent(s): 9adec00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -99,18 +99,17 @@ def realesrgan(img, model_name, denoise_strength, face_enhance, outscale):
99
  print('If you encounter CUDA out of memory, try to set --tile with a smaller number.')
100
  else:
101
  # Save restored image and return it to the output Image component
102
- #if img_mode == 'RGBA': # RGBA images should be saved in png format
103
  extension = 'png'
104
- #else:
105
- # extension = 'jpg'
106
 
107
  #out_filename = f"output_{rnd_string(8)}.{extension}"
108
- #cv2.imwrite(out_filename, output)
109
- cv2.imwrite("output.png", output)
110
  global last_file
111
- #last_file = out_filename
112
- #return out_filename
113
- return "output.png"
114
 
115
 
116
  def rnd_string(x):
@@ -163,10 +162,10 @@ def image_properties(img):
163
  """
164
  global img_mode
165
  if img:
166
- #if has_transparency(img):
167
  img_mode = "RGBA"
168
- #else:
169
- # img_mode = "RGB"
170
  properties = f"Width: {img.size[0]}, Height: {img.size[1]} | Color Mode: {img_mode}"
171
  return properties
172
 
 
99
  print('If you encounter CUDA out of memory, try to set --tile with a smaller number.')
100
  else:
101
  # Save restored image and return it to the output Image component
102
+ if img_mode == 'RGBA': # RGBA images should be saved in png format
103
  extension = 'png'
104
+ else:
105
+ extension = 'jpg'
106
 
107
  #out_filename = f"output_{rnd_string(8)}.{extension}"
108
+ out_filename = f"output_{rnd_string(8)}.png"
109
+ cv2.imwrite(out_filename, output)
110
  global last_file
111
+ last_file = out_filename
112
+ return out_filename
 
113
 
114
 
115
  def rnd_string(x):
 
162
  """
163
  global img_mode
164
  if img:
165
+ if has_transparency(img):
166
  img_mode = "RGBA"
167
+ else:
168
+ img_mode = "RGB"
169
  properties = f"Width: {img.size[0]}, Height: {img.size[1]} | Color Mode: {img_mode}"
170
  return properties
171