[Feature]: Added option to change SAM model folder location
Enchante503 opened this issue · 1 comments
Enchante503 commented
Expected behavior
I'm new to writing code, so I'll have to scrutinize the code, but it seems to work.
#scripts_sam_model_dir = os.path.join(scripts.basedir(), "models/sam")
try:
sam_models_dir = shared.opts.sam_models_dir
except AttributeError:
sam_models_dir = ""
if len(sam_models_dir) == 0 or sam_models_dir.isspace():
scripts_sam_model_dir = os.path.join(scripts.basedir(), "models/sam")
else:
scripts_sam_model_dir = os.path.expanduser(sam_models_dir)
def on_ui_settings():
section = ('segment_anything', "Segment Anything")
shared.opts.add_option("sam_use_local_groundingdino", shared.OptionInfo(False, "Use local groundingdino to bypass C++ problem", section=section))
shared.opts.add_option("sam_models_dir",
shared.OptionInfo(
default="",
label="Segment Anything Models Directory",
component=gr.Textbox,
component_args={"interactive": True},
section=section))