zhiweili commited on
Commit
f2cb7ad
·
1 Parent(s): 6876e59

add icc_profile

Browse files
Files changed (1) hide show
  1. app_base.py +6 -5
app_base.py CHANGED
@@ -30,6 +30,7 @@ def create_demo() -> gr.Blocks:
30
  w2 = 1.0
31
 
32
  input_image = Image.open(input_image_path)
 
33
 
34
  run_model = base_run
35
  res_image = run_model(
@@ -48,17 +49,17 @@ def create_demo() -> gr.Blocks:
48
  tmpPrefix = "/tmp/gradio/"
49
 
50
  extension = 'png'
51
- # if enhanced_image.mode == 'RGBA':
52
- # extension = 'png'
53
- # else:
54
- # extension = 'jpg'
55
 
56
  targetDir = f"{tmpPrefix}output/"
57
  if not os.path.exists(targetDir):
58
  os.makedirs(targetDir)
59
 
60
  enhanced_path = f"{targetDir}{uuid.uuid4()}.{extension}"
61
- enhanced_image.save(enhanced_path, quality=100)
62
 
63
  return enhanced_path
64
 
 
30
  w2 = 1.0
31
 
32
  input_image = Image.open(input_image_path)
33
+ icc_profile = input_image.info.get("icc_profile")
34
 
35
  run_model = base_run
36
  res_image = run_model(
 
49
  tmpPrefix = "/tmp/gradio/"
50
 
51
  extension = 'png'
52
+ if enhanced_image.mode == 'RGBA':
53
+ extension = 'png'
54
+ else:
55
+ extension = 'jpg'
56
 
57
  targetDir = f"{tmpPrefix}output/"
58
  if not os.path.exists(targetDir):
59
  os.makedirs(targetDir)
60
 
61
  enhanced_path = f"{targetDir}{uuid.uuid4()}.{extension}"
62
+ enhanced_image.save(enhanced_path, quality=100, icc_profile=icc_profile)
63
 
64
  return enhanced_path
65