jw2yang commited on
Commit
1c6b43e
·
1 Parent(s): a5e40e0
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -34,7 +34,7 @@ magma_qa_prompt = "<image>\n{} Answer the question briefly."
34
  magma_model_id = "microsoft/Magma-8B"
35
  magam_model = AutoModelForCausalLM.from_pretrained(magma_model_id, trust_remote_code=True, torch_dtype=dtype)
36
  magma_processor = AutoProcessor.from_pretrained(magma_model_id, trust_remote_code=True)
37
- magam_model.to("cuda")
38
 
39
  # Download the entire repository
40
  # snapshot_download(repo_id=repo_id, local_dir=local_dir)
@@ -92,7 +92,7 @@ def get_som_response(instruction, image_som):
92
  inputs = magma_processor(images=[image_som], texts=prompt, return_tensors="pt")
93
  inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0)
94
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
95
- inputs = inputs.to("cuda").to(dtype)
96
 
97
  magam_model.generation_config.pad_token_id = magma_processor.tokenizer.pad_token_id
98
  with torch.inference_mode():
@@ -129,7 +129,7 @@ def get_qa_response(instruction, image):
129
  inputs = magma_processor(images=[image], texts=prompt, return_tensors="pt")
130
  inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0)
131
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
132
- inputs = inputs.to("cuda")
133
 
134
  magam_model.generation_config.pad_token_id = magma_processor.tokenizer.pad_token_id
135
  with torch.inference_mode():
 
34
  magma_model_id = "microsoft/Magma-8B"
35
  magam_model = AutoModelForCausalLM.from_pretrained(magma_model_id, trust_remote_code=True, torch_dtype=dtype)
36
  magma_processor = AutoProcessor.from_pretrained(magma_model_id, trust_remote_code=True)
37
+ # magam_model.to("cuda")
38
 
39
  # Download the entire repository
40
  # snapshot_download(repo_id=repo_id, local_dir=local_dir)
 
92
  inputs = magma_processor(images=[image_som], texts=prompt, return_tensors="pt")
93
  inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0)
94
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
95
+ inputs = inputs.to(dtype)
96
 
97
  magam_model.generation_config.pad_token_id = magma_processor.tokenizer.pad_token_id
98
  with torch.inference_mode():
 
129
  inputs = magma_processor(images=[image], texts=prompt, return_tensors="pt")
130
  inputs['pixel_values'] = inputs['pixel_values'].unsqueeze(0)
131
  inputs['image_sizes'] = inputs['image_sizes'].unsqueeze(0)
132
+ inputs = inputs.to(dtype)
133
 
134
  magam_model.generation_config.pad_token_id = magma_processor.tokenizer.pad_token_id
135
  with torch.inference_mode():