Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -53,16 +53,28 @@ def search(query: str, ds, images, k):
|
|
53 |
return results
|
54 |
|
55 |
|
56 |
-
@spaces.GPU
|
57 |
def index(files, ds):
|
58 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
images = []
|
60 |
for f in files:
|
61 |
-
images.extend(convert_from_path(f))
|
62 |
|
63 |
if len(images) >= 150:
|
64 |
raise gr.Error("The number of images in the dataset should be less than 150.")
|
|
|
65 |
|
|
|
|
|
|
|
|
|
|
|
66 |
# run inference - docs
|
67 |
dataloader = DataLoader(
|
68 |
images,
|
|
|
53 |
return results
|
54 |
|
55 |
|
|
|
56 |
def index(files, ds):
|
57 |
+
print("Converting files")
|
58 |
+
images = convert_files(files)
|
59 |
+
print(f"Files converted with {len(images)} images.")
|
60 |
+
return index_gpu(images, ds)
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
def convert_files(files):
|
65 |
images = []
|
66 |
for f in files:
|
67 |
+
images.extend(convert_from_path(f, thread_count=4))
|
68 |
|
69 |
if len(images) >= 150:
|
70 |
raise gr.Error("The number of images in the dataset should be less than 150.")
|
71 |
+
return images
|
72 |
|
73 |
+
|
74 |
+
@spaces.GPU
|
75 |
+
def index_gpu(images, ds):
|
76 |
+
"""Example script to run inference with ColPali"""
|
77 |
+
|
78 |
# run inference - docs
|
79 |
dataloader = DataLoader(
|
80 |
images,
|