Spaces:
Runtime error
Runtime error
liuyizhang
commited on
Commit
•
5c28041
1
Parent(s):
9912950
update app.py
Browse files- app.py +11 -7
- app_cli.py +3 -0
app.py
CHANGED
@@ -698,8 +698,6 @@ def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_t
|
|
698 |
logger.info(f'run_anything_task_[{file_temp}]_9_9_')
|
699 |
return output_images, gr.Gallery.update(label='result images'), None, None, None
|
700 |
|
701 |
-
kosmos_enable = False
|
702 |
-
|
703 |
def change_radio_display(task_type, mask_source_radio):
|
704 |
text_prompt_visible = True
|
705 |
inpaint_prompt_visible = False
|
@@ -717,8 +715,7 @@ def change_radio_display(task_type, mask_source_radio):
|
|
717 |
image_gallery_visible = False
|
718 |
kosmos_input_visible = True
|
719 |
kosmos_output_visible = True
|
720 |
-
kosmos_text_output_visible = True
|
721 |
-
|
722 |
|
723 |
if task_type == "inpainting":
|
724 |
inpaint_prompt_visible = True
|
@@ -754,7 +751,12 @@ def get_model_device(module):
|
|
754 |
except Exception as e:
|
755 |
return 'Error'
|
756 |
|
757 |
-
|
|
|
|
|
|
|
|
|
|
|
758 |
if kosmos_enable:
|
759 |
task_types.append("Kosmos-2")
|
760 |
|
@@ -774,7 +776,8 @@ if __name__ == "__main__":
|
|
774 |
|
775 |
load_sd_model()
|
776 |
load_lama_cleaner_model()
|
777 |
-
|
|
|
778 |
|
779 |
if os.environ.get('IS_MY_DEBUG') is None and kosmos_enable:
|
780 |
kosmos_model, kosmos_processor = load_kosmos_model(device)
|
@@ -867,7 +870,8 @@ if __name__ == "__main__":
|
|
867 |
])
|
868 |
|
869 |
DESCRIPTION = f'### This demo from [Grounded-Segment-Anything](https://github.com/IDEA-Research/Grounded-Segment-Anything). <br>'
|
870 |
-
|
|
|
871 |
DESCRIPTION += f'Remove(cleaner) from [lama-cleaner](https://github.com/Sanster/lama-cleaner). <br>'
|
872 |
if kosmos_enable:
|
873 |
DESCRIPTION += f'Kosmos-2 from [Kosmos-2](https://huggingface.co/spaces/ydshieh/Kosmos-2). <br>'
|
|
|
698 |
logger.info(f'run_anything_task_[{file_temp}]_9_9_')
|
699 |
return output_images, gr.Gallery.update(label='result images'), None, None, None
|
700 |
|
|
|
|
|
701 |
def change_radio_display(task_type, mask_source_radio):
|
702 |
text_prompt_visible = True
|
703 |
inpaint_prompt_visible = False
|
|
|
715 |
image_gallery_visible = False
|
716 |
kosmos_input_visible = True
|
717 |
kosmos_output_visible = True
|
718 |
+
kosmos_text_output_visible = True
|
|
|
719 |
|
720 |
if task_type == "inpainting":
|
721 |
inpaint_prompt_visible = True
|
|
|
751 |
except Exception as e:
|
752 |
return 'Error'
|
753 |
|
754 |
+
ram_enable = True
|
755 |
+
kosmos_enable = False
|
756 |
+
|
757 |
+
task_types = ["detection", "segment", "inpainting", "remove"]
|
758 |
+
if ram_enable:
|
759 |
+
task_types.append("relate anything")
|
760 |
if kosmos_enable:
|
761 |
task_types.append("Kosmos-2")
|
762 |
|
|
|
776 |
|
777 |
load_sd_model()
|
778 |
load_lama_cleaner_model()
|
779 |
+
if ram_enable:
|
780 |
+
load_ram_model()
|
781 |
|
782 |
if os.environ.get('IS_MY_DEBUG') is None and kosmos_enable:
|
783 |
kosmos_model, kosmos_processor = load_kosmos_model(device)
|
|
|
870 |
])
|
871 |
|
872 |
DESCRIPTION = f'### This demo from [Grounded-Segment-Anything](https://github.com/IDEA-Research/Grounded-Segment-Anything). <br>'
|
873 |
+
if ram_enable:
|
874 |
+
DESCRIPTION += f'RAM from [RelateAnything](https://github.com/Luodian/RelateAnything). <br>'
|
875 |
DESCRIPTION += f'Remove(cleaner) from [lama-cleaner](https://github.com/Sanster/lama-cleaner). <br>'
|
876 |
if kosmos_enable:
|
877 |
DESCRIPTION += f'Kosmos-2 from [Kosmos-2](https://huggingface.co/spaces/ydshieh/Kosmos-2). <br>'
|
app_cli.py
CHANGED
@@ -77,6 +77,8 @@ sam_mask_generator = None
|
|
77 |
sd_pipe = None
|
78 |
lama_cleaner_model= None
|
79 |
ram_model = None
|
|
|
|
|
80 |
|
81 |
def get_args():
|
82 |
argparser = argparse.ArgumentParser()
|
@@ -116,6 +118,7 @@ if __name__ == '__main__':
|
|
116 |
remove_mode = "rectangle", # ["segment", "rectangle"]
|
117 |
remove_mask_extend = "10",
|
118 |
num_relation = 5,
|
|
|
119 |
cleaner_size_limit = -1,
|
120 |
)
|
121 |
if len(output_images) > 0:
|
|
|
77 |
sd_pipe = None
|
78 |
lama_cleaner_model= None
|
79 |
ram_model = None
|
80 |
+
kosmos_model = None
|
81 |
+
kosmos_processor = None
|
82 |
|
83 |
def get_args():
|
84 |
argparser = argparse.ArgumentParser()
|
|
|
118 |
remove_mode = "rectangle", # ["segment", "rectangle"]
|
119 |
remove_mask_extend = "10",
|
120 |
num_relation = 5,
|
121 |
+
kosmos_input = None,
|
122 |
cleaner_size_limit = -1,
|
123 |
)
|
124 |
if len(output_images) > 0:
|