manu commited on
Commit
e7f8afe
·
verified ·
1 Parent(s): 6efb913

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -20,12 +20,12 @@ def install_fa2():
20
 
21
 
22
  model = ColQwen2.from_pretrained(
23
- "manu/colqwen2-v1.0-alpha",
24
  torch_dtype=torch.bfloat16,
25
  device_map="cuda:0", # or "mps" if on Apple Silicon
26
  # attn_implementation="flash_attention_2", # should work on A100
27
  ).eval()
28
- processor = ColQwen2Processor.from_pretrained("manu/colqwen2-v1.0")
29
 
30
 
31
  def encode_image_to_base64(image):
@@ -39,7 +39,7 @@ def query_gpt4o_mini(query, images):
39
  """Calls OpenAI's GPT-4o-mini with the query and image data."""
40
  from openai import OpenAI
41
 
42
- images = [encode_image_to_base64(image) for image in images]
43
  client = OpenAI(api_key=os.env.get("OPENAI_KEY"))
44
  PROMPT = """
45
  You are a smart assistant designed to answer questions about a PDF document.
@@ -122,7 +122,7 @@ def search(query: str, ds, images, k):
122
  results.append((images[idx], f"Page {idx}"))
123
 
124
  # Generate response from GPT-4o-mini
125
- ai_response = "Activate AI response by forking and adding your GPT-4o key" # query_gpt4o_mini(query, results)
126
 
127
  return results, ai_response
128
 
 
20
 
21
 
22
  model = ColQwen2.from_pretrained(
23
+ "vidore/colqwen2-v1.0",
24
  torch_dtype=torch.bfloat16,
25
  device_map="cuda:0", # or "mps" if on Apple Silicon
26
  # attn_implementation="flash_attention_2", # should work on A100
27
  ).eval()
28
+ processor = ColQwen2Processor.from_pretrained("vidore/colqwen2-v1.0")
29
 
30
 
31
  def encode_image_to_base64(image):
 
39
  """Calls OpenAI's GPT-4o-mini with the query and image data."""
40
  from openai import OpenAI
41
 
42
+ base64_images = [encode_image_to_base64(image) for image in images]
43
  client = OpenAI(api_key=os.env.get("OPENAI_KEY"))
44
  PROMPT = """
45
  You are a smart assistant designed to answer questions about a PDF document.
 
122
  results.append((images[idx], f"Page {idx}"))
123
 
124
  # Generate response from GPT-4o-mini
125
+ ai_response = query_gpt4o_mini(query, results)
126
 
127
  return results, ai_response
128