Spaces:
Sleeping
Sleeping
update
Browse files- app.py +2 -2
- models/vsa_model.py +22 -15
app.py
CHANGED
@@ -100,8 +100,8 @@ with gr.Blocks() as app:
|
|
100 |
|
101 |
|
102 |
vsa = VisionSearchAssistant(
|
103 |
-
ground_device = "cuda
|
104 |
-
vlm_device="cuda
|
105 |
vlm_load_4bit=True,
|
106 |
)
|
107 |
# Launch the app
|
|
|
100 |
|
101 |
|
102 |
vsa = VisionSearchAssistant(
|
103 |
+
ground_device = "cuda",
|
104 |
+
vlm_device="cuda",
|
105 |
vlm_load_4bit=True,
|
106 |
)
|
107 |
# Launch the app
|
models/vsa_model.py
CHANGED
@@ -278,7 +278,6 @@ class VisionSearchAssistant:
|
|
278 |
the $\mathcal{F}_{vlm}(cdot)$ in the paper.
|
279 |
|
280 |
"""
|
281 |
-
@spaces.GPU
|
282 |
def __init__(
|
283 |
self,
|
284 |
search_model: str = "internlm/internlm2_5-7b-chat",
|
@@ -289,19 +288,13 @@ class VisionSearchAssistant:
|
|
289 |
vlm_load_4bit: bool = True,
|
290 |
vlm_load_8bit: bool = False,
|
291 |
):
|
292 |
-
self.
|
293 |
-
|
294 |
-
|
295 |
-
self.
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
self.vlm = VLM(
|
300 |
-
model_path = vlm_model,
|
301 |
-
device = vlm_device,
|
302 |
-
load_4bit = vlm_load_4bit,
|
303 |
-
load_8bit = vlm_load_8bit
|
304 |
-
)
|
305 |
self.use_correlate = True
|
306 |
|
307 |
@spaces.GPU
|
@@ -310,7 +303,21 @@ class VisionSearchAssistant:
|
|
310 |
image: Union[str, Image.Image, np.ndarray],
|
311 |
text: str,
|
312 |
ground_classes: Union[List[str], None] = None
|
313 |
-
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
# Create and clear the temporary directory.
|
315 |
if not os.access('temp', os.F_OK):
|
316 |
os.makedirs('temp')
|
|
|
278 |
the $\mathcal{F}_{vlm}(cdot)$ in the paper.
|
279 |
|
280 |
"""
|
|
|
281 |
def __init__(
|
282 |
self,
|
283 |
search_model: str = "internlm/internlm2_5-7b-chat",
|
|
|
288 |
vlm_load_4bit: bool = True,
|
289 |
vlm_load_8bit: bool = False,
|
290 |
):
|
291 |
+
self.search_model = search_model
|
292 |
+
self.ground_model = ground_model
|
293 |
+
self.ground_device = ground_device
|
294 |
+
self.vlm_model = vlm_model
|
295 |
+
self.vlm_device = vlm_device
|
296 |
+
self.vlm_load_4bit = vlm_load_4bit
|
297 |
+
self.vlm_load_8bit = vlm_load_8bit
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
self.use_correlate = True
|
299 |
|
300 |
@spaces.GPU
|
|
|
303 |
image: Union[str, Image.Image, np.ndarray],
|
304 |
text: str,
|
305 |
ground_classes: Union[List[str], None] = None
|
306 |
+
):
|
307 |
+
self.searcher = WebSearcher(
|
308 |
+
model_path = self.search_model
|
309 |
+
)
|
310 |
+
self.grounder = VisualGrounder(
|
311 |
+
model_path = self.ground_model,
|
312 |
+
device = self.ground_device,
|
313 |
+
)
|
314 |
+
self.vlm = VLM(
|
315 |
+
model_path = self.vlm_model,
|
316 |
+
device = self.vlm_device,
|
317 |
+
load_4bit = self.vlm_load_4bit,
|
318 |
+
load_8bit = self.vlm_load_8bit
|
319 |
+
)
|
320 |
+
|
321 |
# Create and clear the temporary directory.
|
322 |
if not os.access('temp', os.F_OK):
|
323 |
os.makedirs('temp')
|