jiminHuang commited on
Commit
422c2e8
·
verified ·
1 Parent(s): 13a471f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -50,10 +50,16 @@ tokenizer, llava_model, image_processor, context_len = load_pretrained_model(
50
  args.load_4bit,
51
  device=args.device)
52
 
 
 
 
 
 
 
 
 
53
  @spaces.GPU
54
  def bot_streaming(message, history):
55
- print ("triggered")
56
- print(message)
57
  image_file = None
58
  if message["files"]:
59
  if type(message["files"][-1]) == dict:
@@ -93,18 +99,17 @@ def bot_streaming(message, history):
93
  for new_text in streamer:
94
  buffer += new_text
95
  generated_text_without_prompt = buffer
96
- time.sleep(0.06)
97
  print (generated_text_without_prompt)
98
  yield generated_text_without_prompt
99
 
100
- chatbot = gr.Chatbot(scale=1)
101
  chat_input = gr.MultimodalTextbox(interactive=True, file_types=["image"], placeholder="Enter message or upload file...", show_label=False)
102
  with gr.Blocks(fill_height=True) as demo:
103
  gr.ChatInterface(
104
  fn=bot_streaming,
105
  title="FinLLaVA-8B Demo",
106
  examples=[
107
- {"text": "What is in this picture?", "files": ["http://images.cocodataset.org/val2017/000000039769.jpg"]},
108
  {"text": "What is the spending on Healthcare in July? A. 450 B. 600 C. 520 D. 510", "files": ["image_107.png"]},
109
  {"text": "If 2012 net periodic opeb cost increased at the same pace as the pension cost, what would the estimated 2013 cost be in millions? A. 14.83333 B. 12.5 C. 15.5 D. 13.5", "files": ["image_659.png"]},
110
  ],
 
50
  args.load_4bit,
51
  device=args.device)
52
 
53
+
54
+ PLACEHOLDER = """
55
+ <div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
56
+ <h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">FinLLaVA</h1>
57
+ <p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">FinLLaVA is a LLaVA model fine-tuned from FinLLaMA and CLIP by the Fin AI</p>
58
+ </div>
59
+ """
60
+
61
  @spaces.GPU
62
  def bot_streaming(message, history):
 
 
63
  image_file = None
64
  if message["files"]:
65
  if type(message["files"][-1]) == dict:
 
99
  for new_text in streamer:
100
  buffer += new_text
101
  generated_text_without_prompt = buffer
102
+ time.sleep(1.0)
103
  print (generated_text_without_prompt)
104
  yield generated_text_without_prompt
105
 
106
+ chatbot = gr.Chatbot(placeholder=PLACEHOLDER,scale=1)
107
  chat_input = gr.MultimodalTextbox(interactive=True, file_types=["image"], placeholder="Enter message or upload file...", show_label=False)
108
  with gr.Blocks(fill_height=True) as demo:
109
  gr.ChatInterface(
110
  fn=bot_streaming,
111
  title="FinLLaVA-8B Demo",
112
  examples=[
 
113
  {"text": "What is the spending on Healthcare in July? A. 450 B. 600 C. 520 D. 510", "files": ["image_107.png"]},
114
  {"text": "If 2012 net periodic opeb cost increased at the same pace as the pension cost, what would the estimated 2013 cost be in millions? A. 14.83333 B. 12.5 C. 15.5 D. 13.5", "files": ["image_659.png"]},
115
  ],