s3nh commited on
Commit
aa8424c
·
verified ·
1 Parent(s): d2b16af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +106 -0
app.py CHANGED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+
4
+ import os
5
+ from PIL import Image
6
+
7
+ from transformers import TextStreamer
8
+ from utils import title_markdown
9
+ from utils import block_css
10
+ from utils import tos_markdown
11
+ from utils import learn_more_markdown
12
+
13
+
14
+
15
+ textbox = gr.Textbox(
16
+ show_label = False, placeholder = "Enter text and press ENTER", container = False
17
+ )
18
+
19
+ with gr.Blocks(title = '' ) as demo:
20
+ gr.Markdown(title_markdown)
21
+
22
+ with gr.Blocks(title='MoE-LLaVA🚀')) as demo:
23
+ gr.Markdown(title_markdown)
24
+ state = gr.State()
25
+ state_ = gr.State()
26
+ first_run = gr.State()
27
+ images_tensor = gr.State()
28
+
29
+ with gr.Row():
30
+ with gr.Column(scale=3):
31
+ image1 = gr.Image(label="Input Document", type="filepath")
32
+
33
+ cur_dir = os.path.dirname(os.path.abspath(__file__))
34
+ print(cur_dir)
35
+ gr.Examples(
36
+ examples=[
37
+ [
38
+ f"{cur_dir}demo.jfif",
39
+ "What is unusual about this image?",
40
+ ],
41
+ [
42
+ f"{cur_dir}demo.jfif",
43
+ "What are the things I should be cautious about when I visit here?",
44
+ ],
45
+ [
46
+ f"{cur_dir}demo.jfif",
47
+ "If there are factual errors in the questions, point it out; if not, proceed answering the question. What’s happening in the desert?",
48
+ ],
49
+ [
50
+ f"{cur_dir}demo.jfif",
51
+ "What is the title of this book?",
52
+ ],
53
+ [
54
+ f"{cur_dir}demo.jfif",
55
+ "What type of food is the girl holding?",
56
+ ],
57
+ [
58
+ f"{cur_dir}demo.jfif",
59
+ "What color is the train?",
60
+ ],
61
+ [
62
+ f"{cur_dir}demo.jfif",
63
+ "What is the girl looking at?",
64
+ ],
65
+ [
66
+ f"{cur_dir}demo.jfif",
67
+ "What might be the reason for the dog's aggressive behavior?",
68
+ ],
69
+ ],
70
+ inputs=[image1, textbox],
71
+ )
72
+
73
+ # with gr.Column(scale=7):
74
+ # #chatbot = gr.Chatbot(label="MoE-LLaVA", bubble_full_width=True).style(height=750)
75
+ # with gr.Row():
76
+ # with gr.Column(scale=8):
77
+ # textbox.render()
78
+ # with gr.Column(scale=1, min_width=50):
79
+ # submit_btn = gr.Button(
80
+ # value="Send", variant="primary", interactive=True
81
+ # )
82
+ # with gr.Row(elem_id="buttons") as button_row:
83
+ # upvote_btn = gr.Button(value="👍 Upvote", interactive=True)
84
+ # downvote_btn = gr.Button(value="👎 Downvote", interactive=True)
85
+ # flag_btn = gr.Button(value="⚠️ Flag", interactive=True)
86
+ # # stop_btn = gr.Button(value="⏹️ Stop Generation", interactive=False)
87
+ # regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=True)
88
+ # clear_btn = gr.Button(value="🗑️ Clear history", interactive=True)
89
+
90
+ # gr.Markdown(tos_markdown)
91
+ # gr.Markdown(learn_more_markdown)
92
+
93
+ # submit_btn.click(generate, [image1, textbox, first_run, state, state_, images_tensor],
94
+ # [state, state_, chatbot, first_run, textbox, images_tensor, image1])
95
+
96
+ # regenerate_btn.click(regenerate, [state, state_], [state, state_, chatbot, first_run]).then(
97
+ # generate, [image1, textbox, first_run, state, state_, images_tensor],
98
+ # [state, state_, chatbot, first_run, textbox, images_tensor, image1])
99
+
100
+ # clear_btn.click(clear_history, [state, state_],
101
+ # [image1, textbox, first_run, state, state_, chatbot, images_tensor])
102
+
103
+ # app = gr.mount_gradio_app(app, demo, path="/")
104
+ demo.launch()
105
+
106
+