Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,16 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
|
3 |
-
# ===================================================
|
4 |
-
#
|
5 |
-
# Author : Fan Zhang
|
6 |
-
# Email : [email protected]
|
7 |
-
# Institute : Beijing Academy of Artificial Intelligence (BAAI)
|
8 |
-
# Create On : 2023-12-11 15:34
|
9 |
-
# Last Modified : 2024-01-04 10:15
|
10 |
-
# File Name : app.py
|
11 |
-
# Description :
|
12 |
-
#
|
13 |
-
# ===================================================
|
14 |
-
|
15 |
import os
|
16 |
-
os.system("pip uninstall -y gradio")
|
17 |
-
os.system("pip install gradio==3.40.1")
|
18 |
-
|
19 |
import argparse
|
20 |
-
|
21 |
import gradio as gr
|
22 |
from demo.generation_frontend import build_generation
|
23 |
from demo.chat_frontend import build_chat
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
parser = argparse.ArgumentParser()
|
26 |
parser.add_argument("--title", type=str, default='Emu')
|
27 |
-
|
28 |
parser.add_argument("--host", type=str, default="0.0.0.0")
|
29 |
parser.add_argument("--port", type=int, default=9002)
|
30 |
parser.add_argument("--share", action="store_true")
|
@@ -35,56 +21,34 @@ parser.add_argument("--disable-generate", action="store_true")
|
|
35 |
|
36 |
args = parser.parse_args()
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
tab_names.append("Multimodal Chat")
|
70 |
-
|
71 |
-
if not args.disable_generate:
|
72 |
-
demo_generation = build_generation(args)
|
73 |
-
interface_list.append(demo_generation)
|
74 |
-
tab_names.append("Multimodal Generation")
|
75 |
-
|
76 |
-
demo_all = gr.TabbedInterface(
|
77 |
-
interface_list=interface_list,
|
78 |
-
tab_names=tab_names,
|
79 |
-
title=title,
|
80 |
-
theme=gr.themes.Default(primary_hue="blue", secondary_hue="blue"),
|
81 |
-
)
|
82 |
-
|
83 |
-
demo_all.queue(
|
84 |
-
concurrency_count=args.concurrency_count,
|
85 |
-
status_update_rate=3,
|
86 |
-
api_open=False,
|
87 |
-
).launch(
|
88 |
-
enable_queue=True,
|
89 |
-
share=args.share,
|
90 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
|
|
|
|
|
|
2 |
import argparse
|
|
|
3 |
import gradio as gr
|
4 |
from demo.generation_frontend import build_generation
|
5 |
from demo.chat_frontend import build_chat
|
6 |
|
7 |
+
# Uninstall and reinstall a specific version of gradio
|
8 |
+
os.system("pip uninstall -y gradio")
|
9 |
+
os.system("pip install gradio==3.40.1")
|
10 |
+
|
11 |
+
# Set up the argument parser
|
12 |
parser = argparse.ArgumentParser()
|
13 |
parser.add_argument("--title", type=str, default='Emu')
|
|
|
14 |
parser.add_argument("--host", type=str, default="0.0.0.0")
|
15 |
parser.add_argument("--port", type=int, default=9002)
|
16 |
parser.add_argument("--share", action="store_true")
|
|
|
21 |
|
22 |
args = parser.parse_args()
|
23 |
|
24 |
+
# Initialize lists for interfaces and tab names
|
25 |
+
interface_list, tab_names = [], []
|
26 |
+
|
27 |
+
# Conditional blocks to add chat and generation interfaces
|
28 |
+
if not args.disable_chat:
|
29 |
+
demo_chat = build_chat(args)
|
30 |
+
interface_list.append(demo_chat)
|
31 |
+
tab_names.append("Multimodal Chat")
|
32 |
+
|
33 |
+
if not args.disable_generate:
|
34 |
+
demo_generation = build_generation(args)
|
35 |
+
interface_list.append(demo_generation)
|
36 |
+
tab_names.append("Multimodal Generation")
|
37 |
+
|
38 |
+
# Create a tabbed interface with the specified interfaces and tabs
|
39 |
+
demo_all = gr.TabbedInterface(
|
40 |
+
interface_list=interface_list,
|
41 |
+
tab_names=tab_names,
|
42 |
+
title=args.title,
|
43 |
+
theme=gr.themes.Default(primary_hue="blue", secondary_hue="blue"),
|
44 |
+
)
|
45 |
+
|
46 |
+
# Launch the application with the specified settings
|
47 |
+
demo_all.queue(
|
48 |
+
concurrency_count=args.concurrency_count,
|
49 |
+
status_update_rate=3,
|
50 |
+
api_open=False,
|
51 |
+
).launch(
|
52 |
+
enable_queue=True,
|
53 |
+
share=args.share,
|
54 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|