File tree Expand file tree Collapse file tree 7 files changed +30
-6
lines changed Expand file tree Collapse file tree 7 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ jobs:
104104
105105 - name : Push Docker image
106106 if : steps.check_changes.outputs.skip != 'true'
107- uses : docker/build-push-action@v5.1 .0
107+ uses : docker/build-push-action@v5.2 .0
108108 id : docker_build_and_push
109109 with :
110110 context : " ${{ env.examples_dir }}/${{ env.backend_dir_name }}"
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ def safe_str_cmp(a, b):
165165@_server .before_request
166166def check_auth ():
167167 if BASIC_AUTH is not None :
168+
168169 auth = request .authorization
169170 if not auth or not (safe_str_cmp (auth .username , BASIC_AUTH [0 ]) and safe_str_cmp (auth .password , BASIC_AUTH [1 ])):
170171 return Response ('Unauthorized' , 401 , {'WWW-Authenticate' : 'Basic realm="Login required"' })
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ if __name__ == "__main__":
112112 print('Check "' + {model_class}.__name__ + '" instance creation..')
113113 model = {model_class}(**kwargs)
114114
115- app = init_app(model_class={model_class})
115+ app = init_app(model_class={model_class}, basic_auth_user=args.basic_auth_user, basic_auth_pass=args.basic_auth_pass )
116116
117117 app.run(host=args.host, port=args.port, debug=args.debug)
118118
Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ def get_kwargs_from_config(config_path=_DEFAULT_CONFIG_PATH):
6767 parser .add_argument (
6868 '--check' , dest = 'check' , action = 'store_true' ,
6969 help = 'Validate model instance before launching server' )
70+ parser .add_argument ('--basic-auth-user' ,
71+ default = os .environ .get ('ML_SERVER_BASIC_AUTH_USER' , None ),
72+ help = 'Basic auth user' )
73+
74+ parser .add_argument ('--basic-auth-pass' ,
75+ default = os .environ .get ('ML_SERVER_BASIC_AUTH_PASS' , None ),
76+ help = 'Basic auth pass' )
77+
7078
7179 args = parser .parse_args ()
7280
@@ -105,7 +113,7 @@ def parse_kwargs():
105113 print ('Check "' + OpenAIInteractive .__name__ + '" instance creation..' )
106114 model = OpenAIInteractive (** kwargs )
107115
108- app = init_app (model_class = OpenAIInteractive )
116+ app = init_app (model_class = OpenAIInteractive , basic_auth_user = args . basic_auth_user , basic_auth_pass = args . basic_auth_pass )
109117
110118 app .run (host = args .host , port = args .port , debug = args .debug )
111119
Original file line number Diff line number Diff line change 193193``` bash
194194docker-compose up
195195```
196- to start the backend in a docker container.
196+ to start the backend in a docker container;
197+
198+ or
199+
200+ ``` bash
201+ MOBILESAM_CHECKPOINT=path/to/mobile_sam.pt label-studio-ml start segment_anything_model/
202+ ```
203+
204+ > Note: if you see the error on MacOS, try set the environment variable ` KMP_DUPLICATE_LIB_OK=True `
197205
198206## Set up a Project in Label Studio for Segment Anything
199207
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ def get_kwargs_from_config(config_path=_DEFAULT_CONFIG_PATH):
6666 parser .add_argument (
6767 '--check' , dest = 'check' , action = 'store_true' ,
6868 help = 'Validate model instance before launching server' )
69+ parser .add_argument ('--basic-auth-user' ,
70+ default = os .environ .get ('ML_SERVER_BASIC_AUTH_USER' , None ),
71+ help = 'Basic auth user' )
72+
73+ parser .add_argument ('--basic-auth-pass' ,
74+ default = os .environ .get ('ML_SERVER_BASIC_AUTH_PASS' , None ),
75+ help = 'Basic auth pass' )
6976
7077 args = parser .parse_args ()
7178
@@ -104,7 +111,7 @@ def parse_kwargs():
104111 print ('Check "' + SamMLBackend .__name__ + '" instance creation..' )
105112 model = SamMLBackend (** kwargs )
106113
107- app = init_app (model_class = SamMLBackend )
114+ app = init_app (model_class = SamMLBackend , basic_auth_user = args . basic_auth_user , basic_auth_pass = args . basic_auth_pass )
108115
109116 app .run (host = args .host , port = args .port , debug = args .debug )
110117
Original file line number Diff line number Diff line change 11#! /bin/bash
22
33# Execute the gunicorn command
4- exec gunicorn --preload --bind :$PORT --workers 1 --threads 8 --timeout 0 _wsgi:app
4+ exec gunicorn --preload --bind :${ PORT:- 9090} --workers 1 --threads 8 --timeout 0 _wsgi:app
You can’t perform that action at this time.
0 commit comments