add models
Browse files- serve/gradio_web_server.py +36 -35
- startup.sh +3 -1
serve/gradio_web_server.py
CHANGED
@@ -25,7 +25,7 @@ from serve import INTERACTION_MODES_MAP, MODEL_ID_TO_NAME
|
|
25 |
|
26 |
LOGDIR = "/logs"
|
27 |
|
28 |
-
logger = build_logger("gradio_web_server", "gradio_web_server.log")
|
29 |
|
30 |
headers = {"User-Agent": "PrismaticVLMs Client"}
|
31 |
|
@@ -48,7 +48,7 @@ def get_model_list():
|
|
48 |
models = sorted(
|
49 |
models, key=lambda x: list(MODEL_ID_TO_NAME.values()).index(x) if x in MODEL_ID_TO_NAME.values() else len(models)
|
50 |
)
|
51 |
-
logger.info(f"Models: {models}")
|
52 |
return models
|
53 |
|
54 |
|
@@ -63,7 +63,7 @@ function() {
|
|
63 |
|
64 |
|
65 |
def load_demo(url_params, request: gr.Request):
|
66 |
-
logger.info(f"load_demo. ip: {request.client.host}. params: {url_params}")
|
67 |
|
68 |
dropdown_update = gr.Dropdown.update(visible=True)
|
69 |
if "model" in url_params:
|
@@ -76,7 +76,7 @@ def load_demo(url_params, request: gr.Request):
|
|
76 |
|
77 |
|
78 |
def load_demo_refresh_model_list(request: gr.Request):
|
79 |
-
logger.info(f"load_demo. ip: {request.client.host}")
|
80 |
models = get_model_list()
|
81 |
state = default_conversation.copy()
|
82 |
dropdown_update = gr.Dropdown.update(choices=models, value=models[0] if len(models) > 0 else "")
|
@@ -84,19 +84,20 @@ def load_demo_refresh_model_list(request: gr.Request):
|
|
84 |
|
85 |
|
86 |
def vote_last_response(state, vote_type, model_selector, request: gr.Request):
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
96 |
|
97 |
|
98 |
def regenerate(state, image_process_mode, request: gr.Request):
|
99 |
-
logger.info(f"regenerate. ip: {request.client.host}")
|
100 |
state.messages[-1][-1] = None
|
101 |
prev_human_msg = state.messages[-2]
|
102 |
if type(prev_human_msg[1]) in (tuple, list):
|
@@ -106,13 +107,13 @@ def regenerate(state, image_process_mode, request: gr.Request):
|
|
106 |
|
107 |
|
108 |
def clear_history(request: gr.Request):
|
109 |
-
logger.info(f"clear_history. ip: {request.client.host}")
|
110 |
state = default_conversation.copy()
|
111 |
return (state, state.to_gradio_chatbot(), "", None) + (disable_btn,) * 5
|
112 |
|
113 |
|
114 |
def add_text(state, text, image, image_process_mode, request: gr.Request):
|
115 |
-
logger.info(f"add_text. ip: {request.client.host}. len: {len(text)}")
|
116 |
if len(text) <= 0 and image is None:
|
117 |
state.skip_next = True
|
118 |
return (state, state.to_gradio_chatbot(), "", None) + (no_change_btn,) * 5
|
@@ -138,7 +139,7 @@ def add_text(state, text, image, image_process_mode, request: gr.Request):
|
|
138 |
|
139 |
|
140 |
def http_bot(state, model_selector, interaction_mode, temperature, max_new_tokens, request: gr.Request):
|
141 |
-
logger.info(f"http_bot. ip: {request.client.host}")
|
142 |
start_tstamp = time.time()
|
143 |
model_name = model_selector
|
144 |
|
@@ -159,7 +160,7 @@ def http_bot(state, model_selector, interaction_mode, temperature, max_new_token
|
|
159 |
controller_url = args.controller_url
|
160 |
ret = requests.post(controller_url + "/get_worker_address", json={"model": model_name})
|
161 |
worker_addr = ret.json()["address"]
|
162 |
-
logger.info(f"model_name: {model_name}, worker_addr: {worker_addr}")
|
163 |
|
164 |
# No available worker
|
165 |
if worker_addr == "":
|
@@ -188,7 +189,7 @@ def http_bot(state, model_selector, interaction_mode, temperature, max_new_token
|
|
188 |
"max_new_tokens": int(max_new_tokens),
|
189 |
"images": f"List of {len(state.get_images())} images: {all_image_hash}",
|
190 |
}
|
191 |
-
logger.info(f"==== request ====\n{pload}")
|
192 |
|
193 |
pload["images"] = state.get_images()
|
194 |
|
@@ -228,20 +229,20 @@ def http_bot(state, model_selector, interaction_mode, temperature, max_new_token
|
|
228 |
yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
|
229 |
|
230 |
finish_tstamp = time.time()
|
231 |
-
logger.info(f"{output}")
|
232 |
-
|
233 |
-
with open(get_conv_log_filename(), "a") as fout:
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
|
246 |
|
247 |
title_markdown = """
|
@@ -425,11 +426,11 @@ if __name__ == "__main__":
|
|
425 |
parser.add_argument("--moderate", action="store_true")
|
426 |
parser.add_argument("--embed", action="store_true")
|
427 |
args = parser.parse_args()
|
428 |
-
logger.info(f"args: {args}")
|
429 |
|
430 |
models = get_model_list()
|
431 |
|
432 |
-
logger.info(args)
|
433 |
demo = build_demo(args.embed)
|
434 |
demo.queue(concurrency_count=args.concurrency_count, api_open=False).launch(
|
435 |
server_name=args.host, server_port=args.port, share=args.share
|
|
|
25 |
|
26 |
LOGDIR = "/logs"
|
27 |
|
28 |
+
# logger = build_logger("gradio_web_server", "gradio_web_server.log")
|
29 |
|
30 |
headers = {"User-Agent": "PrismaticVLMs Client"}
|
31 |
|
|
|
48 |
models = sorted(
|
49 |
models, key=lambda x: list(MODEL_ID_TO_NAME.values()).index(x) if x in MODEL_ID_TO_NAME.values() else len(models)
|
50 |
)
|
51 |
+
# logger.info(f"Models: {models}")
|
52 |
return models
|
53 |
|
54 |
|
|
|
63 |
|
64 |
|
65 |
def load_demo(url_params, request: gr.Request):
|
66 |
+
# logger.info(f"load_demo. ip: {request.client.host}. params: {url_params}")
|
67 |
|
68 |
dropdown_update = gr.Dropdown.update(visible=True)
|
69 |
if "model" in url_params:
|
|
|
76 |
|
77 |
|
78 |
def load_demo_refresh_model_list(request: gr.Request):
|
79 |
+
# logger.info(f"load_demo. ip: {request.client.host}")
|
80 |
models = get_model_list()
|
81 |
state = default_conversation.copy()
|
82 |
dropdown_update = gr.Dropdown.update(choices=models, value=models[0] if len(models) > 0 else "")
|
|
|
84 |
|
85 |
|
86 |
def vote_last_response(state, vote_type, model_selector, request: gr.Request):
|
87 |
+
pass
|
88 |
+
# with open(get_conv_log_filename(), "a") as fout:
|
89 |
+
# data = {
|
90 |
+
# "tstamp": round(time.time(), 4),
|
91 |
+
# "type": vote_type,
|
92 |
+
# "model": model_selector,
|
93 |
+
# "state": state.dict(),
|
94 |
+
# "ip": request.client.host,
|
95 |
+
# }
|
96 |
+
# fout.write(json.dumps(data) + "\n")
|
97 |
|
98 |
|
99 |
def regenerate(state, image_process_mode, request: gr.Request):
|
100 |
+
# logger.info(f"regenerate. ip: {request.client.host}")
|
101 |
state.messages[-1][-1] = None
|
102 |
prev_human_msg = state.messages[-2]
|
103 |
if type(prev_human_msg[1]) in (tuple, list):
|
|
|
107 |
|
108 |
|
109 |
def clear_history(request: gr.Request):
|
110 |
+
# logger.info(f"clear_history. ip: {request.client.host}")
|
111 |
state = default_conversation.copy()
|
112 |
return (state, state.to_gradio_chatbot(), "", None) + (disable_btn,) * 5
|
113 |
|
114 |
|
115 |
def add_text(state, text, image, image_process_mode, request: gr.Request):
|
116 |
+
# logger.info(f"add_text. ip: {request.client.host}. len: {len(text)}")
|
117 |
if len(text) <= 0 and image is None:
|
118 |
state.skip_next = True
|
119 |
return (state, state.to_gradio_chatbot(), "", None) + (no_change_btn,) * 5
|
|
|
139 |
|
140 |
|
141 |
def http_bot(state, model_selector, interaction_mode, temperature, max_new_tokens, request: gr.Request):
|
142 |
+
# logger.info(f"http_bot. ip: {request.client.host}")
|
143 |
start_tstamp = time.time()
|
144 |
model_name = model_selector
|
145 |
|
|
|
160 |
controller_url = args.controller_url
|
161 |
ret = requests.post(controller_url + "/get_worker_address", json={"model": model_name})
|
162 |
worker_addr = ret.json()["address"]
|
163 |
+
# logger.info(f"model_name: {model_name}, worker_addr: {worker_addr}")
|
164 |
|
165 |
# No available worker
|
166 |
if worker_addr == "":
|
|
|
189 |
"max_new_tokens": int(max_new_tokens),
|
190 |
"images": f"List of {len(state.get_images())} images: {all_image_hash}",
|
191 |
}
|
192 |
+
# logger.info(f"==== request ====\n{pload}")
|
193 |
|
194 |
pload["images"] = state.get_images()
|
195 |
|
|
|
229 |
yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
|
230 |
|
231 |
finish_tstamp = time.time()
|
232 |
+
# logger.info(f"{output}")
|
233 |
+
|
234 |
+
# with open(get_conv_log_filename(), "a") as fout:
|
235 |
+
# data = {
|
236 |
+
# "tstamp": round(finish_tstamp, 4),
|
237 |
+
# "type": "chat",
|
238 |
+
# "model": model_name,
|
239 |
+
# "start": round(start_tstamp, 4),
|
240 |
+
# "finish": round(finish_tstamp, 4),
|
241 |
+
# "state": state.dict(),
|
242 |
+
# "images": all_image_hash,
|
243 |
+
# "ip": request.client.host,
|
244 |
+
# }
|
245 |
+
# fout.write(json.dumps(data) + "\n")
|
246 |
|
247 |
|
248 |
title_markdown = """
|
|
|
426 |
parser.add_argument("--moderate", action="store_true")
|
427 |
parser.add_argument("--embed", action="store_true")
|
428 |
args = parser.parse_args()
|
429 |
+
# logger.info(f"args: {args}")
|
430 |
|
431 |
models = get_model_list()
|
432 |
|
433 |
+
# logger.info(args)
|
434 |
demo = build_demo(args.embed)
|
435 |
demo.queue(concurrency_count=args.concurrency_count, api_open=False).launch(
|
436 |
server_name=args.host, server_port=args.port, share=args.share
|
startup.sh
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
#!/bin/sh
|
2 |
python -m serve.controller --host 0.0.0.0 --port 10000 &
|
3 |
-
python -m serve.gradio_web_server --controller http://localhost:10000 --model-list-mode reload --share
|
|
|
|
|
|
1 |
#!/bin/sh
|
2 |
python -m serve.controller --host 0.0.0.0 --port 10000 &
|
3 |
+
python -m serve.gradio_web_server --controller http://localhost:10000 --model-list-mode reload --share &
|
4 |
+
python -m interactive_demo --port 40000 --model_id prism-dinosiglip+7b &
|
5 |
+
python -m interactive_demo --port 40001 --model_family llava-v15 --model_id llava-v1.5-7b --model_dir liuhaotian/llava-v1.5-7b &
|