LukasHug commited on
Commit
68b8a1b
1 Parent(s): b551dbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -66,16 +66,16 @@ def run_llava(prompt, pil_image, temperature, top_p, max_new_tokens):
66
  return outputs[0].strip()
67
 
68
 
69
- # def load_selected_model(model_path):
70
- # model_name = model_path.split("/")[-1]
71
- # global tokenizer, model, image_processor, context_len
72
- # with warnings.catch_warnings(record=True) as w:
73
- # warnings.simplefilter("always")
74
- # tokenizer, model, image_processor, context_len = load_pretrained_model(model_path, None, model_name)
75
- # for warning in w:
76
- # if "vision" not in str(warning.message).lower():
77
- # print(warning.message)
78
- # model.config.tokenizer_model_max_length = 2048 * 2
79
 
80
 
81
  def get_conv_log_filename():
@@ -516,8 +516,7 @@ Set the environment variable `model` to change the model:
516
  model_path = '/common-repos/LlavaGuard/models/LlavaGuard-v1.1-7b-full/smid_and_crawled_v2_with_augmented_policies/json-v16/llava'
517
 
518
  print(f"Loading model {model_path}")
519
- tokenizer, model, image_processor, context_len = load_pretrained_model(model_path, None, model_name, token=api_key)
520
- # load_selected_model(model_path)
521
  model.config.tokenizer_model_max_length = 2048 * 2
522
 
523
  exit_status = 0
 
66
  return outputs[0].strip()
67
 
68
 
69
+ def load_selected_model(model_path):
70
+ model_name = model_path.split("/")[-1]
71
+ global tokenizer, model, image_processor, context_len
72
+ with warnings.catch_warnings(record=True) as w:
73
+ warnings.simplefilter("always")
74
+ tokenizer, model, image_processor, context_len = load_pretrained_model(model_path, None, model_name)
75
+ for warning in w:
76
+ if "vision" not in str(warning.message).lower():
77
+ print(warning.message)
78
+ model.config.tokenizer_model_max_length = 2048 * 2
79
 
80
 
81
  def get_conv_log_filename():
 
516
  model_path = '/common-repos/LlavaGuard/models/LlavaGuard-v1.1-7b-full/smid_and_crawled_v2_with_augmented_policies/json-v16/llava'
517
 
518
  print(f"Loading model {model_path}")
519
+ load_selected_model(model_path)
 
520
  model.config.tokenizer_model_max_length = 2048 * 2
521
 
522
  exit_status = 0