Spaces:
Sleeping
Sleeping
NGUYEN, Xuan Phi
commited on
Commit
•
b8f920f
1
Parent(s):
7411df9
update
Browse files
multipurpose_chatbot/engines/image_processing_llava_next.py
CHANGED
@@ -434,6 +434,8 @@ class LlavaNextImageProcessor(BaseImageProcessor):
|
|
434 |
for patch in patches
|
435 |
]
|
436 |
|
|
|
|
|
437 |
resized_original_image = resize(
|
438 |
image,
|
439 |
size=size,
|
@@ -606,6 +608,7 @@ class LlavaNextImageProcessor(BaseImageProcessor):
|
|
606 |
|
607 |
if concat_images:
|
608 |
# image_num_patches = [len(x) for x in new_images]
|
|
|
609 |
pixel_values = np.concatenate(new_images, axis=0)
|
610 |
data = {
|
611 |
"pixel_values": pixel_values,
|
|
|
434 |
for patch in patches
|
435 |
]
|
436 |
|
437 |
+
print(f'patches: {len(patches)=} given {image_size}, {best_resolution}')
|
438 |
+
|
439 |
resized_original_image = resize(
|
440 |
image,
|
441 |
size=size,
|
|
|
608 |
|
609 |
if concat_images:
|
610 |
# image_num_patches = [len(x) for x in new_images]
|
611 |
+
print(f'{len(new_images)}')
|
612 |
pixel_values = np.concatenate(new_images, axis=0)
|
613 |
data = {
|
614 |
"pixel_values": pixel_values,
|
multipurpose_chatbot/engines/sealava16_transformers_engine.py
CHANGED
@@ -162,25 +162,28 @@ class SeaLlava16Engine(TransformersEngine):
|
|
162 |
sys.path.append(CODE_PATH)
|
163 |
|
164 |
|
165 |
-
# from transformers.models.llava_next.modeling_llava_next import LlavaNextForConditionalGeneration
|
166 |
-
# from transformers.models.llava_next.processing_llava_next import LlavaNextProcessor
|
167 |
from .modeling_sealava16 import LlavaNextForConditionalGeneration
|
168 |
from .image_processing_llava_next import LlavaNextImageProcessor
|
169 |
from .processing_llava_next import LlavaNextProcessor
|
170 |
model_path = MODEL_PATH
|
171 |
print(f'Loading model from {model_path}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
174 |
-
if os.path.exists(f"{model_path}/pytorch_model_fsdp.bin") and not os.path.exists(f"{model_path}/pytorch_model.bin"):
|
175 |
-
os.symlink("pytorch_model_fsdp.bin", f"{model_path}/pytorch_model.bin")
|
176 |
|
177 |
-
# self.
|
178 |
-
self.
|
179 |
-
self.
|
180 |
-
self.
|
181 |
-
self._model = LlavaNextForConditionalGeneration.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="cuda").eval()
|
182 |
print(f'Loading llava1.6 from custom code')
|
183 |
-
|
|
|
184 |
print(self._tokenizer)
|
185 |
print(self._processor)
|
186 |
|
|
|
162 |
sys.path.append(CODE_PATH)
|
163 |
|
164 |
|
|
|
|
|
165 |
from .modeling_sealava16 import LlavaNextForConditionalGeneration
|
166 |
from .image_processing_llava_next import LlavaNextImageProcessor
|
167 |
from .processing_llava_next import LlavaNextProcessor
|
168 |
model_path = MODEL_PATH
|
169 |
print(f'Loading model from {model_path}')
|
170 |
+
|
171 |
+
# default
|
172 |
+
from transformers.models.llava_next.modeling_llava_next import LlavaNextForConditionalGeneration
|
173 |
+
from transformers.models.llava_next.processing_llava_next import LlavaNextProcessor
|
174 |
+
self._processor = LlavaNextProcessor.from_pretrained(model_path)
|
175 |
+
self._model = LlavaNextForConditionalGeneration.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="cuda").eval()
|
176 |
+
print(f'Loading llava1.6 from default code')
|
177 |
|
178 |
+
# /custom
|
|
|
|
|
179 |
|
180 |
+
# self._tokenizer = AutoTokenizer.from_pretrained(model_path)
|
181 |
+
# self._image_processor = LlavaNextImageProcessor(model_path)
|
182 |
+
# self._processor = LlavaNextProcessor(image_processor=self._image_processor, tokenizer=self._tokenizer)
|
183 |
+
# self._model = LlavaNextForConditionalGeneration.from_pretrained(model_path, torch_dtype=torch.bfloat16, device_map="cuda").eval()
|
|
|
184 |
print(f'Loading llava1.6 from custom code')
|
185 |
+
|
186 |
+
print(self._processor.image_processor)
|
187 |
print(self._tokenizer)
|
188 |
print(self._processor)
|
189 |
|