khang119966 commited on
Commit
94865fa
·
verified ·
1 Parent(s): 27bc946

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -117,6 +117,8 @@ def correct_image_orientation(image_path):
117
 
118
  def load_image(image_file, input_size=448, max_num=12):
119
  image = correct_image_orientation(image_file).convert('RGB')
 
 
120
  print("Image size: ", image.size)
121
  transform = build_transform(input_size=input_size)
122
  images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
@@ -125,12 +127,13 @@ def load_image(image_file, input_size=448, max_num=12):
125
  return pixel_values
126
 
127
  model = AutoModel.from_pretrained(
128
- "5CD-AI/Vintern-1B-v3_5",
129
  torch_dtype=torch.bfloat16,
130
  low_cpu_mem_usage=True,
131
  trust_remote_code=True,
 
132
  ).eval().cuda()
133
- tokenizer = AutoTokenizer.from_pretrained("5CD-AI/Vintern-1B-v3_5", trust_remote_code=True, use_fast=False)
134
 
135
  @spaces.GPU
136
  def chat(message, history):
@@ -285,15 +288,16 @@ demo = gr.Blocks(css=CSS,js=js, theme='NoCrypt/miku')
285
  with demo:
286
  chat_demo_interface = gr.ChatInterface(
287
  fn=chat,
288
- description="""**Vintern-1B-v3.5** is the latest in the Vintern series, bringing major improvements over v2 across all benchmarks. This **continuous fine-tuning Version** enhances Vietnamese capabilities while retaining strong English performance. It excels in OCR, text recognition, and Vietnam-specific document understanding.""",
289
  examples=[{"text": "Hãy viết một email giới thiệu sản phẩm trong ảnh.", "files":["./demo_3.jpg"]},
290
  {"text": "Trích xuất các thông tin từ ảnh trả về markdown.", "files":["./demo_1.jpg"]},
291
  {"text": "Bạn là nhân viên marketing chuyên nghiệp. Hãy viết một bài quảng cáo dài trên mạng xã hội giới thiệu về cửa hàng.", "files":["./demo_2.jpg"]},
292
  {"text": "Trích xuất thông tin kiện hàng trong ảnh và trả về dạng JSON.", "files":["./demo_4.jpg"]}],
293
- title="❄️ Vintern-1B-v3.5 Demo ❄️",
294
  multimodal=True,
295
  css=CSS,
296
  js=js,
 
297
  theme='NoCrypt/miku'
298
  )
299
 
 
117
 
118
  def load_image(image_file, input_size=448, max_num=12):
119
  image = correct_image_orientation(image_file).convert('RGB')
120
+ width, height = image.size
121
+ image = image.resize((width * 2, height * 2), Image.LANCZOS)
122
  print("Image size: ", image.size)
123
  transform = build_transform(input_size=input_size)
124
  images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
 
127
  return pixel_values
128
 
129
  model = AutoModel.from_pretrained(
130
+ "5CD-AI/Vintern-3B-R-beta",
131
  torch_dtype=torch.bfloat16,
132
  low_cpu_mem_usage=True,
133
  trust_remote_code=True,
134
+ use_flash_attn=True,
135
  ).eval().cuda()
136
+ tokenizer = AutoTokenizer.from_pretrained("5CD-AI/Vintern-3B-R-beta", trust_remote_code=True, use_fast=False)
137
 
138
  @spaces.GPU
139
  def chat(message, history):
 
288
  with demo:
289
  chat_demo_interface = gr.ChatInterface(
290
  fn=chat,
291
+ description="""**Vintern-3B-R-beta** is the latest in the Vintern series.""",
292
  examples=[{"text": "Hãy viết một email giới thiệu sản phẩm trong ảnh.", "files":["./demo_3.jpg"]},
293
  {"text": "Trích xuất các thông tin từ ảnh trả về markdown.", "files":["./demo_1.jpg"]},
294
  {"text": "Bạn là nhân viên marketing chuyên nghiệp. Hãy viết một bài quảng cáo dài trên mạng xã hội giới thiệu về cửa hàng.", "files":["./demo_2.jpg"]},
295
  {"text": "Trích xuất thông tin kiện hàng trong ảnh và trả về dạng JSON.", "files":["./demo_4.jpg"]}],
296
+ title="❄️ Vintern-3B-R-beta Demo ❄️",
297
  multimodal=True,
298
  css=CSS,
299
  js=js,
300
+ additional_inputs=[gr.Checkbox(label="Think", value=False)], # Thêm checkbox
301
  theme='NoCrypt/miku'
302
  )
303