Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- constants.py +2 -2
- extract_images/services.py +3 -2
- extract_tables/services.py +7 -3
constants.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
GEMINI_API_KEY = "
|
2 |
-
OPENAI_API_KEY = "
|
|
|
1 |
+
GEMINI_API_KEY = ""
|
2 |
+
OPENAI_API_KEY = ""
|
extract_images/services.py
CHANGED
@@ -9,7 +9,7 @@ import openai
|
|
9 |
import requests
|
10 |
import os
|
11 |
|
12 |
-
from constants import GEMINI_API_KEY, OPENAI_API_KEY
|
13 |
from utils import (
|
14 |
draw_boxes,
|
15 |
pdf_to_images,
|
@@ -67,7 +67,8 @@ def extract_images_pdfplumber(pdf_file):
|
|
67 |
|
68 |
|
69 |
def extract_images_gemini(model, pdf_file):
|
70 |
-
|
|
|
71 |
gemini_model = genai.GenerativeModel(model)
|
72 |
prompt = f"Extract the bounding boxes of all the images present in this page. Return the bounding boxes as list of lists. Do not include anyother text or symbols in the output"
|
73 |
|
|
|
9 |
import requests
|
10 |
import os
|
11 |
|
12 |
+
# from constants import GEMINI_API_KEY, OPENAI_API_KEY
|
13 |
from utils import (
|
14 |
draw_boxes,
|
15 |
pdf_to_images,
|
|
|
67 |
|
68 |
|
69 |
def extract_images_gemini(model, pdf_file):
|
70 |
+
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
71 |
+
genai.configure(api_key=gemini_api_key)
|
72 |
gemini_model = genai.GenerativeModel(model)
|
73 |
prompt = f"Extract the bounding boxes of all the images present in this page. Return the bounding boxes as list of lists. Do not include anyother text or symbols in the output"
|
74 |
|
extract_tables/services.py
CHANGED
@@ -9,9 +9,10 @@ import ast
|
|
9 |
import google.generativeai as genai
|
10 |
import openai
|
11 |
import requests
|
|
|
12 |
|
13 |
|
14 |
-
from constants import GEMINI_API_KEY, OPENAI_API_KEY
|
15 |
from utils import (
|
16 |
draw_boxes,
|
17 |
pdf_to_images,
|
@@ -109,7 +110,9 @@ def extract_tables_img2table(pdf_file):
|
|
109 |
|
110 |
|
111 |
def extract_tables_gemini(model, pdf_file):
|
112 |
-
|
|
|
|
|
113 |
gemini_model = genai.GenerativeModel(model)
|
114 |
prompt = f"Extract the bounding boxes of all the tables present in this image. Return the bounding boxes as list of lists. Do not include anyother text or symbols in the output"
|
115 |
|
@@ -136,7 +139,8 @@ def extract_tables_gemini(model, pdf_file):
|
|
136 |
|
137 |
|
138 |
def extract_tables_gpt(model, pdf_file):
|
139 |
-
|
|
|
140 |
image_media_type = "image/png"
|
141 |
|
142 |
pdf_path = "extract_images/input_docs/uploaded_pdf.pdf"
|
|
|
9 |
import google.generativeai as genai
|
10 |
import openai
|
11 |
import requests
|
12 |
+
import os
|
13 |
|
14 |
|
15 |
+
# from constants import GEMINI_API_KEY, OPENAI_API_KEY
|
16 |
from utils import (
|
17 |
draw_boxes,
|
18 |
pdf_to_images,
|
|
|
110 |
|
111 |
|
112 |
def extract_tables_gemini(model, pdf_file):
|
113 |
+
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
114 |
+
genai.configure(api_key=gemini_api_key)
|
115 |
+
|
116 |
gemini_model = genai.GenerativeModel(model)
|
117 |
prompt = f"Extract the bounding boxes of all the tables present in this image. Return the bounding boxes as list of lists. Do not include anyother text or symbols in the output"
|
118 |
|
|
|
139 |
|
140 |
|
141 |
def extract_tables_gpt(model, pdf_file):
|
142 |
+
openai_api_key = os.getenv("OPENAI_API_KEY")
|
143 |
+
openai.api_key = openai_api_key
|
144 |
image_media_type = "image/png"
|
145 |
|
146 |
pdf_path = "extract_images/input_docs/uploaded_pdf.pdf"
|