update app.py
Browse files
app.py
CHANGED
@@ -50,20 +50,20 @@ def write2file(path, content):
|
|
50 |
def sort_models(models):
|
51 |
def custom_sort_key(model_name):
|
52 |
# InternVL-Chat-V1-5 should be the first item
|
53 |
-
if model_name == "
|
54 |
-
return (
|
55 |
-
elif model_name.startswith("
|
56 |
-
return (1, model_name) #
|
57 |
else:
|
58 |
return (0, model_name) # 0 indicates normal order
|
59 |
|
60 |
models.sort(key=custom_sort_key, reverse=True)
|
61 |
-
try: # We have five InternVL-Chat-V1-5 models, randomly choose one to be the first
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
except:
|
66 |
-
|
67 |
return models
|
68 |
|
69 |
|
@@ -274,7 +274,7 @@ def change_system_prompt(state, system_prompt, request: gr.Request):
|
|
274 |
def add_text(state, message, system_prompt, model_selector, request: gr.Request):
|
275 |
print(f"state: {state}")
|
276 |
if not state:
|
277 |
-
state
|
278 |
images = message.get("files", [])
|
279 |
text = message.get("text", "").strip()
|
280 |
logger.info(f"add_text. ip: {request.client.host}. len: {len(text)}")
|
@@ -577,6 +577,7 @@ def build_demo(embed_mode):
|
|
577 |
theme=gr.themes.Default(),
|
578 |
css=block_css,
|
579 |
) as demo:
|
|
|
580 |
state = gr.State()
|
581 |
|
582 |
if not embed_mode:
|
@@ -672,11 +673,9 @@ def build_demo(embed_mode):
|
|
672 |
[
|
673 |
{
|
674 |
"files": [
|
675 |
-
"gallery/
|
676 |
-
"gallery/child_2.jpg",
|
677 |
-
f"gallery/child_3.jpg",
|
678 |
],
|
679 |
-
"text": "
|
680 |
}
|
681 |
],
|
682 |
],
|
@@ -847,8 +846,6 @@ if __name__ == "__main__":
|
|
847 |
if not args.worker_ip:
|
848 |
args.worker_ip = os.environ.get("WORKER_IP", None)
|
849 |
|
850 |
-
models = get_model_list()
|
851 |
-
|
852 |
sd_worker_url = args.sd_worker_url
|
853 |
logger.info(args)
|
854 |
demo = build_demo(args.embed)
|
|
|
50 |
def sort_models(models):
|
51 |
def custom_sort_key(model_name):
|
52 |
# InternVL-Chat-V1-5 should be the first item
|
53 |
+
if model_name == "InternVL2-Pro":
|
54 |
+
return (2, model_name) # 2 indicates highest precedence
|
55 |
+
elif model_name.startswith("InternVL2-8B"):
|
56 |
+
return (1, model_name) # 0 indicates highest precedence
|
57 |
else:
|
58 |
return (0, model_name) # 0 indicates normal order
|
59 |
|
60 |
models.sort(key=custom_sort_key, reverse=True)
|
61 |
+
# try: # We have five InternVL-Chat-V1-5 models, randomly choose one to be the first
|
62 |
+
# first_three = models[:4]
|
63 |
+
# random.shuffle(first_three)
|
64 |
+
# models[:4] = first_three
|
65 |
+
# except:
|
66 |
+
# pass
|
67 |
return models
|
68 |
|
69 |
|
|
|
274 |
def add_text(state, message, system_prompt, model_selector, request: gr.Request):
|
275 |
print(f"state: {state}")
|
276 |
if not state:
|
277 |
+
state = init_state()
|
278 |
images = message.get("files", [])
|
279 |
text = message.get("text", "").strip()
|
280 |
logger.info(f"add_text. ip: {request.client.host}. len: {len(text)}")
|
|
|
577 |
theme=gr.themes.Default(),
|
578 |
css=block_css,
|
579 |
) as demo:
|
580 |
+
models = get_model_list()
|
581 |
state = gr.State()
|
582 |
|
583 |
if not embed_mode:
|
|
|
673 |
[
|
674 |
{
|
675 |
"files": [
|
676 |
+
"gallery/water.jpg",
|
|
|
|
|
677 |
],
|
678 |
+
"text": "Please describe this image.",
|
679 |
}
|
680 |
],
|
681 |
],
|
|
|
846 |
if not args.worker_ip:
|
847 |
args.worker_ip = os.environ.get("WORKER_IP", None)
|
848 |
|
|
|
|
|
849 |
sd_worker_url = args.sd_worker_url
|
850 |
logger.info(args)
|
851 |
demo = build_demo(args.embed)
|