Spaces:
Runtime error
Runtime error
Commit
·
b0fa0f9
1
Parent(s):
1a767c1
update
Browse files- app_high_res.py +6 -4
app_high_res.py
CHANGED
|
@@ -11,9 +11,12 @@ import functools
|
|
| 11 |
from transformers import AutoProcessor, Idefics2ForConditionalGeneration
|
| 12 |
from models.conversation import conv_templates
|
| 13 |
from typing import List
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
processor = AutoProcessor.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-high-res-35k-mantis-2epoch_4096")
|
| 15 |
-
model = Idefics2ForConditionalGeneration.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-high-res-35k-mantis-2epoch_4096", torch_dtype=torch.bfloat16)
|
| 16 |
-
# model = model.to("cuda")
|
| 17 |
MAX_NUM_FRAMES = 24
|
| 18 |
conv_template = conv_templates["idefics_2"]
|
| 19 |
|
|
@@ -61,8 +64,7 @@ all the frames of video are as follows:
|
|
| 61 |
"""
|
| 62 |
@spaces.GPU(duration=60)
|
| 63 |
def generate(text:str, images:List[Image.Image], history: List[dict], **kwargs):
|
| 64 |
-
|
| 65 |
-
model = model.to("cuda")
|
| 66 |
if not images:
|
| 67 |
images = None
|
| 68 |
|
|
|
|
| 11 |
from transformers import AutoProcessor, Idefics2ForConditionalGeneration
|
| 12 |
from models.conversation import conv_templates
|
| 13 |
from typing import List
|
| 14 |
+
import subprocess
|
| 15 |
+
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
processor = AutoProcessor.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-high-res-35k-mantis-2epoch_4096")
|
| 19 |
+
model = Idefics2ForConditionalGeneration.from_pretrained("Mantis-VL/mantis-8b-idefics2-video-eval-high-res-35k-mantis-2epoch_4096", torch_dtype=torch.bfloat16, attn_implementation="flash_attention_2")
|
|
|
|
| 20 |
MAX_NUM_FRAMES = 24
|
| 21 |
conv_template = conv_templates["idefics_2"]
|
| 22 |
|
|
|
|
| 64 |
"""
|
| 65 |
@spaces.GPU(duration=60)
|
| 66 |
def generate(text:str, images:List[Image.Image], history: List[dict], **kwargs):
|
| 67 |
+
model.to("cuda")
|
|
|
|
| 68 |
if not images:
|
| 69 |
images = None
|
| 70 |
|