akhil2808 commited on
Commit
09b4752
·
verified ·
1 Parent(s): 738a2fe

Rename app (8).py to app.py

Browse files
Files changed (1) hide show
  1. app (8).py → app.py +5 -17
app (8).py → app.py RENAMED
@@ -9,31 +9,20 @@ import torch
9
  import argparse
10
  from transformers import AutoModel, AutoTokenizer
11
 
12
- # README, How to run demo on different devices
13
-
14
  # For Nvidia GPUs.
15
  # python web_demo_2.5.py --device cuda
16
 
17
- # For Mac with MPS (Apple silicon or AMD GPUs).
18
- # PYTORCH_ENABLE_MPS_FALLBACK=1 python web_demo_2.5.py --device mps
19
-
20
  # Argparser
21
  parser = argparse.ArgumentParser(description='demo')
22
- parser.add_argument('--device', type=str, default='cuda', help='cuda or mps')
23
  args = parser.parse_args()
24
  device = args.device
25
- assert device in ['cuda', 'mps']
26
 
27
  # Load model
28
  model_path = 'openbmb/MiniCPM-Llama3-V-2_5'
29
- if 'int4' in model_path:
30
- if device == 'mps':
31
- print('Error: running int4 model with bitsandbytes on Mac is not supported right now.')
32
- exit()
33
- model = AutoModel.from_pretrained(model_path, trust_remote_code=True)
34
- else:
35
- model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.float16)
36
- model = model.to(device=device)
37
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
38
  model.eval()
39
 
@@ -289,7 +278,6 @@ with gr.Blocks() as demo:
289
  )
290
  bt_pic.upload(lambda: None, None, chat_bot, queue=False).then(upload_img, inputs=[bt_pic,chat_bot,app_session], outputs=[chat_bot,app_session])
291
 
292
- # launch
293
- #demo.launch(share=False, debug=True, show_api=False, server_port=8080, server_name="0.0.0.0")
294
  demo.queue()
295
  demo.launch()
 
9
  import argparse
10
  from transformers import AutoModel, AutoTokenizer
11
 
 
 
12
  # For Nvidia GPUs.
13
  # python web_demo_2.5.py --device cuda
14
 
 
 
 
15
  # Argparser
16
  parser = argparse.ArgumentParser(description='demo')
17
+ parser.add_argument('--device', type=str, default='cuda')
18
  args = parser.parse_args()
19
  device = args.device
20
+ assert device in ['cuda']
21
 
22
  # Load model
23
  model_path = 'openbmb/MiniCPM-Llama3-V-2_5'
24
+ model = AutoModel.from_pretrained(model_path, trust_remote_code=True).to(dtype=torch.float16)
25
+ model = model.to(device=device)
 
 
 
 
 
 
26
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
27
  model.eval()
28
 
 
278
  )
279
  bt_pic.upload(lambda: None, None, chat_bot, queue=False).then(upload_img, inputs=[bt_pic,chat_bot,app_session], outputs=[chat_bot,app_session])
280
 
281
+
 
282
  demo.queue()
283
  demo.launch()