Spaces:
No application file
No application file
Commit ·
b1ff8a3
1
Parent(s): 5e6d254
works
Browse files
app.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
-
import io
|
| 2 |
import urllib
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
-
# import fitz
|
| 6 |
from pdf2image import convert_from_path
|
| 7 |
import cv2
|
| 8 |
import pytesseract
|
| 9 |
import requests
|
| 10 |
import json
|
| 11 |
-
from PIL import Image
|
| 12 |
import re
|
| 13 |
from roboflow import Roboflow
|
| 14 |
import gradio as gr
|
|
@@ -166,20 +163,6 @@ shops = {
|
|
| 166 |
# Add more shops and their respective information here
|
| 167 |
}
|
| 168 |
|
| 169 |
-
# def pdf_to_images(pdf_path):
|
| 170 |
-
# doc = fitz.open(pdf_path)
|
| 171 |
-
# images = []
|
| 172 |
-
# for page in doc:
|
| 173 |
-
# for img in page.get_images(full=True):
|
| 174 |
-
# xref = img[0]
|
| 175 |
-
# base_image = doc.extract_image(xref)
|
| 176 |
-
# image_bytes = base_image["image"]
|
| 177 |
-
# # You can use PIL to do many things with this image data.
|
| 178 |
-
# # If you need it as an array for OpenCV, you can do that as follows:
|
| 179 |
-
# image = Image.open(io.BytesIO(image_bytes))
|
| 180 |
-
# images.append(np.array(image))
|
| 181 |
-
# return images
|
| 182 |
-
|
| 183 |
def pdf_to_images(pdf_path):
|
| 184 |
images = convert_from_path(pdf_path)
|
| 185 |
return [cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) for img in images]
|
|
|
|
|
|
|
| 1 |
import urllib
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
|
|
|
| 4 |
from pdf2image import convert_from_path
|
| 5 |
import cv2
|
| 6 |
import pytesseract
|
| 7 |
import requests
|
| 8 |
import json
|
|
|
|
| 9 |
import re
|
| 10 |
from roboflow import Roboflow
|
| 11 |
import gradio as gr
|
|
|
|
| 163 |
# Add more shops and their respective information here
|
| 164 |
}
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
def pdf_to_images(pdf_path):
|
| 167 |
images = convert_from_path(pdf_path)
|
| 168 |
return [cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR) for img in images]
|