- handler.py +6 -37
handler.py
CHANGED
@@ -999,48 +999,17 @@ class API_Starter:
|
|
999 |
server = pywsgi.WSGIServer(('0.0.0.0', args.port), self.app)
|
1000 |
server.serve_forever()
|
1001 |
|
1002 |
-
|
1003 |
-
if args.port == 0:
|
1004 |
-
print('Please give valid port!')
|
1005 |
-
else:
|
1006 |
-
api_starter = API_Starter()
|
1007 |
-
api_starter.run()
|
1008 |
-
|
1009 |
-
if __name__ == "__main__":
|
1010 |
-
parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
|
1011 |
-
parser.add_argument("--debug", action="store_true", help="using debug mode")
|
1012 |
-
parser.add_argument("--share", action="store_true", help="share the app")
|
1013 |
-
parser.add_argument("--port", "-p", type=int, default=7860, help="port")
|
1014 |
-
args, _ = parser.parse_known_args()
|
1015 |
-
print(f'args = {args}')
|
1016 |
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
device = set_device()
|
1021 |
-
if device == 'cpu':
|
1022 |
-
kosmos_enable = False
|
1023 |
|
1024 |
-
|
1025 |
-
kosmos_model, kosmos_processor = load_kosmos_model(device)
|
1026 |
-
|
1027 |
-
if groundingdino_enable:
|
1028 |
-
groundingdino_model = load_groundingdino_model('cpu')
|
1029 |
-
|
1030 |
-
if sam_enable:
|
1031 |
-
load_sam_model(device)
|
1032 |
|
1033 |
-
|
1034 |
-
load_sd_model(device)
|
1035 |
|
1036 |
-
|
1037 |
-
load_lama_cleaner_model(device)
|
1038 |
|
1039 |
-
if ram_enable:
|
1040 |
-
load_ram_model(device)
|
1041 |
-
|
1042 |
-
if os.environ.get('IS_MY_DEBUG') is None:
|
1043 |
-
os.system("pip list")
|
1044 |
|
1045 |
def just_fucking_get_sd_mask(input_pil, prompt):
|
1046 |
return run_anything_task(input_pil, prompt, "inpainting", "", 0.3, 0.25, 0.8, "merge", "type what to detect below", "segment", "10", 5, "Brief")
|
|
|
999 |
server = pywsgi.WSGIServer(('0.0.0.0', args.port), self.app)
|
1000 |
server.serve_forever()
|
1001 |
|
1002 |
+
device = set_device()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1003 |
|
1004 |
+
groundingdino_model = load_groundingdino_model('cuda:0')
|
1005 |
+
load_sam_model("cuda:0")
|
|
|
|
|
|
|
|
|
1006 |
|
1007 |
+
load_sd_model("cuda:0")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
|
1009 |
+
load_lama_cleaner_model("cuda:0")
|
|
|
1010 |
|
1011 |
+
load_ram_model("cuda:0")
|
|
|
1012 |
|
|
|
|
|
|
|
|
|
|
|
1013 |
|
1014 |
def just_fucking_get_sd_mask(input_pil, prompt):
|
1015 |
return run_anything_task(input_pil, prompt, "inpainting", "", 0.3, 0.25, 0.8, "merge", "type what to detect below", "segment", "10", 5, "Brief")
|