Spaces:
Strucker
/
Runtime error

Strucker commited on
Commit
6675acc
·
verified ·
1 Parent(s): a7c6ff5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -72
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
- # <h2 align='center'>[<a href='https://emu.ssi.plus' target='_blank' rel='noopener'>FAST demo</a>]</h2>
40
- if __name__ == "__main__":
41
- title = "Emu2: Generative Multimodal Models are In-Context Learners<br> \
42
- <h2 align='center'> \
43
- [<a href='https://baaivision.github.io/emu2' target='_blank' rel='noopener'>project page</a>] \
44
- [<a href='https://github.com/baaivision/Emu' target='_blank' rel='noopener'>code</a>] \
45
- [<a href='https://arxiv.org/abs/2312.13286' target='_blank' rel='noopener'>paper</a>] \
46
- </h2> \
47
- <div align='center'> \
48
- <font size=4>Experience Emu2 with 👉</font> \
49
- <font size=6>[<b><a href='https://emu.ssi.plus' target='_blank' rel='noopener'>FAST demo</a>]</b></font> \
50
- <font size=4>👈 <b>WAY MORE FASTER!!!</b></font> \
51
- </div> \
52
- <h3 align='center'> \
53
- 🤗HF models: \
54
- <a href='https://huggingface.co/BAAI/Emu2' target='_blank' rel='noopener'>Emu2</a> | \
55
- <a href='https://huggingface.co/BAAI/Emu2-Chat' target='_blank' rel='noopener'>Emu2-Chat</a> | \
56
- <a href='https://huggingface.co/BAAI/Emu2-Gen' target='_blank' rel='noopener'>Emu2-Gen</a> \
57
- </h3> \
58
- <h4 align='center'> \
59
- [<a href='https://jwolpxeehx.feishu.cn/docx/KskPdU99FomufKx4G9hcQMeQnHv' target='_blank' rel='noopener'>使用说明</a>] \
60
- [<a href='https://jwolpxeehx.feishu.cn/docx/RYHNd1tvEo8k8Mx9HeMcvvxWnvZ' target='_blank' rel='noopener'>User Guide</a>] \
61
- </h4> \
62
- "
63
-
64
-
65
- interface_list, tab_names = [], []
66
- if not args.disable_chat:
67
- demo_chat = build_chat(args)
68
- interface_list.append(demo_chat)
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
+ )