Proposed replacements for methods removed from `processing_utils` in `gradio` 4.0

#802
by abidlabs HF staff - opened
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -15,6 +15,7 @@ from diffusers import (
15
  DPMSolverMultistepScheduler, # <-- Added import
16
  EulerDiscreteScheduler # <-- Added import
17
  )
 
18
  import time
19
  from share_btn import community_icon_html, loading_icon_html, share_js
20
  import user_history
@@ -99,12 +100,13 @@ def check_inputs(prompt: str, control_image: Image.Image):
99
  raise gr.Error("Prompt is required")
100
 
101
  def convert_to_pil(base64_image):
102
- pil_image = processing_utils.decode_base64_to_image(base64_image)
103
  return pil_image
104
 
105
  def convert_to_base64(pil_image):
106
- base64_image = processing_utils.encode_pil_to_base64(pil_image)
107
- return base64_image
 
108
 
109
  # Inference function
110
  @spaces.GPU
 
15
  DPMSolverMultistepScheduler, # <-- Added import
16
  EulerDiscreteScheduler # <-- Added import
17
  )
18
+ import tempfile
19
  import time
20
  from share_btn import community_icon_html, loading_icon_html, share_js
21
  import user_history
 
100
  raise gr.Error("Prompt is required")
101
 
102
  def convert_to_pil(base64_image):
103
+ pil_image = Image.open(base64_image)
104
  return pil_image
105
 
106
  def convert_to_base64(pil_image):
107
+ with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as temp_file:
108
+ image.save(temp_file.name)
109
+ return temp_file.name
110
 
111
  # Inference function
112
  @spaces.GPU