yizhangliu commited on
Commit
baf1b75
1 Parent(s): 1ef3fca

update app.py (gradio==4.42.0)

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -4,7 +4,7 @@ warnings.filterwarnings('ignore')
4
 
5
  import subprocess, io, os, sys, time
6
 
7
- # os.system("pip install gradio==3.50.2")
8
 
9
  import gradio as gr
10
  from loguru import logger
@@ -598,13 +598,10 @@ def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_t
598
 
599
  logger.info(f"input_image==={input_image}")
600
  if 'background' in input_image.keys():
601
- input_image['image'] = input_image['background']
602
  if len(input_image['layers']) > 0:
603
- # input_image['mask'] = input_image['layers'][0] #brush_color
604
  img_arr = np.array(input_image['layers'][0].convert("L"))
605
- logger.info(f"img_arr==={img_arr.shape}, {img_arr[760][640]}, {img_arr[0][0]}")
606
  img_arr = np.where(img_arr > 0, 1, img_arr)
607
- # img_arr = 1 - img_arr
608
  input_image['mask'] = Image.fromarray(255*img_arr.astype('uint8'))
609
 
610
  if (task_type == 'Kosmos-2'):
 
4
 
5
  import subprocess, io, os, sys, time
6
 
7
+ os.system("pip install gradio==4.42.0")
8
 
9
  import gradio as gr
10
  from loguru import logger
 
598
 
599
  logger.info(f"input_image==={input_image}")
600
  if 'background' in input_image.keys():
601
+ input_image['image'] = input_image['background'].convert("RGB")
602
  if len(input_image['layers']) > 0:
 
603
  img_arr = np.array(input_image['layers'][0].convert("L"))
 
604
  img_arr = np.where(img_arr > 0, 1, img_arr)
 
605
  input_image['mask'] = Image.fromarray(255*img_arr.astype('uint8'))
606
 
607
  if (task_type == 'Kosmos-2'):