arad1367 commited on
Commit
f42f33d
β€’
1 Parent(s): 7e738ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import spaces
2
- import subprocess
3
  import os
4
  import gradio as gr
5
  from pdf2image import convert_from_path
@@ -7,6 +6,8 @@ from byaldi import RAGMultiModalModel
7
  from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
8
  from qwen_vl_utils import process_vision_info
9
  import torch
 
 
10
 
11
  # Run the commands from setup.sh to install poppler-utils
12
  def install_poppler():
@@ -30,7 +31,7 @@ model = Qwen2VLForConditionalGeneration.from_pretrained("Qwen/Qwen2-VL-2B-Instru
30
  trust_remote_code=True, torch_dtype=torch.bfloat16).cuda().eval()
31
  processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct", trust_remote_code=True)
32
 
33
- @gr.spaces.GPU()
34
  def process_pdf_and_query(pdf_file, user_query):
35
  # Convert the PDF to images
36
  images = convert_from_path(pdf_file.name) # pdf_file.name gives the file path
 
1
  import spaces
 
2
  import os
3
  import gradio as gr
4
  from pdf2image import convert_from_path
 
6
  from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
7
  from qwen_vl_utils import process_vision_info
8
  import torch
9
+ import torchvision
10
+ import subprocess
11
 
12
  # Run the commands from setup.sh to install poppler-utils
13
  def install_poppler():
 
31
  trust_remote_code=True, torch_dtype=torch.bfloat16).cuda().eval()
32
  processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct", trust_remote_code=True)
33
 
34
+ @spaces.GPU()
35
  def process_pdf_and_query(pdf_file, user_query):
36
  # Convert the PDF to images
37
  images = convert_from_path(pdf_file.name) # pdf_file.name gives the file path