Skip to content

Commit

Permalink
Merge pull request #1 from hill2hill/hill2hill-patch-1
Browse files Browse the repository at this point in the history
update image process func in cli.py
  • Loading branch information
hill2hill authored Oct 10, 2023
2 parents e854a2b + 4dde437 commit 16315b3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions llava/serve/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from llava.conversation import conv_templates, SeparatorStyle
from llava.model.builder import load_pretrained_model
from llava.utils import disable_torch_init
from llava.mm_utils import tokenizer_image_token, get_model_name_from_path, KeywordsStoppingCriteria
from llava.mm_utils import process_images, tokenizer_image_token, get_model_name_from_path, KeywordsStoppingCriteria

from PIL import Image

Expand Down Expand Up @@ -52,7 +52,12 @@ def main(args):
roles = conv.roles

image = load_image(args.image_file)
image_tensor = image_processor.preprocess(image, return_tensors='pt')['pixel_values'].half().cuda()
# Similar operation in model_worker.py
image_tensor = process_images([image], image_processor, args)
if type(image_tensor) is list:
image_tensor = [image.to(model.device, dtype=torch.float16) for image in image_tensor]
else:
image_tensor = image_tensor.to(model.device, dtype=torch.float16)

while True:
try:
Expand Down Expand Up @@ -115,5 +120,6 @@ def main(args):
parser.add_argument("--load-8bit", action="store_true")
parser.add_argument("--load-4bit", action="store_true")
parser.add_argument("--debug", action="store_true")
parser.add_argument("--image-aspect-ratio", type=str, default='pad')
args = parser.parse_args()
main(args)

0 comments on commit 16315b3

Please sign in to comment.