Tonic commited on
Commit
749f0e0
1 Parent(s): ec73dbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -147,8 +147,15 @@ def process_image(image_input):
147
  # Initialize the Gradio client with the URL of the Gradio server
148
  client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
149
 
150
- # Check if the image input is a base64 string, file path (str), or a PIL Image
151
- if isinstance(image_input, str):
 
 
 
 
 
 
 
152
  try:
153
  # Try to decode if it's a base64 string
154
  image = decode_image(image_input)
 
147
  # Initialize the Gradio client with the URL of the Gradio server
148
  client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
149
 
150
+ # Check if the image input is a NumPy array
151
+ if isinstance(image_input, np.ndarray):
152
+ # Convert the NumPy array to a PIL Image
153
+ image = Image.fromarray(image_input)
154
+ # Save the PIL Image to a temporary file
155
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp_file:
156
+ image.save(tmp_file.name)
157
+ image_path = tmp_file.name
158
+ elif isinstance(image_input, str):
159
  try:
160
  # Try to decode if it's a base64 string
161
  image = decode_image(image_input)