yizhangliu commited on
Commit
27d8fa3
1 Parent(s): 43419c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -539,7 +539,14 @@ def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_t
539
 
540
  if (task_type == 'Kosmos-2'):
541
  global kosmos_model, kosmos_processor
542
- kosmos_image, kosmos_text, kosmos_entities = kosmos_generate_predictions(input_image, kosmos_input, kosmos_model, kosmos_processor)
 
 
 
 
 
 
 
543
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
544
  return None, None, time_cost_str, kosmos_image, gr.Textbox.update(visible=(time_cost_str !='')), kosmos_text, kosmos_entities
545
 
@@ -902,7 +909,7 @@ if __name__ == "__main__":
902
  DESCRIPTION += f'RAM from [RelateAnything](https://github.com/Luodian/RelateAnything). <br>'
903
  DESCRIPTION += f'Remove(cleaner) from [lama-cleaner](https://github.com/Sanster/lama-cleaner). <br>'
904
  if kosmos_enable:
905
- DESCRIPTION += f'Kosmos-2 from [Kosmos-2](https://huggingface.co/spaces/ydshieh/Kosmos-2). <br>'
906
  DESCRIPTION += f'Thanks for their excellent work.'
907
  DESCRIPTION += f'<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. \
908
  <a href="https://huggingface.co/spaces/yizhangliu/Grounded-Segment-Anything?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'
 
539
 
540
  if (task_type == 'Kosmos-2'):
541
  global kosmos_model, kosmos_processor
542
+ if isinstance(input_image, dict):
543
+ image_pil, image = load_image(input_image['image'].convert("RGB"))
544
+ input_img = input_image['image']
545
+ else:
546
+ image_pil, image = load_image(input_image.convert("RGB"))
547
+ input_img = input_image
548
+
549
+ kosmos_image, kosmos_text, kosmos_entities = kosmos_generate_predictions(input_img, kosmos_input, kosmos_model, kosmos_processor)
550
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
551
  return None, None, time_cost_str, kosmos_image, gr.Textbox.update(visible=(time_cost_str !='')), kosmos_text, kosmos_entities
552
 
 
909
  DESCRIPTION += f'RAM from [RelateAnything](https://github.com/Luodian/RelateAnything). <br>'
910
  DESCRIPTION += f'Remove(cleaner) from [lama-cleaner](https://github.com/Sanster/lama-cleaner). <br>'
911
  if kosmos_enable:
912
+ DESCRIPTION += f'Kosmos-2 from [Kosmos-2](https://github.com/microsoft/unilm/tree/master/kosmos-2). <br>'
913
  DESCRIPTION += f'Thanks for their excellent work.'
914
  DESCRIPTION += f'<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. \
915
  <a href="https://huggingface.co/spaces/yizhangliu/Grounded-Segment-Anything?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'