22
22
IMAGE_URLS = [
23
23
"https://upload.wikimedia.org/wikipedia/commons/d/da/2015_Kaczka_krzy%C5%BCowka_w_wodzie_%28samiec%29.jpg" ,
24
24
"https://upload.wikimedia.org/wikipedia/commons/7/77/002_The_lion_king_Snyggve_in_the_Serengeti_National_Park_Photo_by_Giles_Laurent.jpg" ,
25
+ "https://upload.wikimedia.org/wikipedia/commons/2/26/Ultramarine_Flycatcher_%28Ficedula_superciliaris%29_Naggar%2C_Himachal_Pradesh%2C_2013_%28cropped%29.JPG" ,
26
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Anim1754_-_Flickr_-_NOAA_Photo_Library_%281%29.jpg/2560px-Anim1754_-_Flickr_-_NOAA_Photo_Library_%281%29.jpg" ,
27
+ "https://upload.wikimedia.org/wikipedia/commons/d/d4/Starfish%2C_Caswell_Bay_-_geograph.org.uk_-_409413.jpg" ,
28
+ "https://upload.wikimedia.org/wikipedia/commons/6/69/Grapevinesnail_01.jpg" ,
29
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Texas_invasive_Musk_Thistle_1.jpg/1920px-Texas_invasive_Musk_Thistle_1.jpg" ,
30
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Huskiesatrest.jpg/2880px-Huskiesatrest.jpg" ,
31
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg/1920px-Orange_tabby_cat_sitting_on_fallen_leaves-Hisashi-01A.jpg" ,
32
+ "https://upload.wikimedia.org/wikipedia/commons/3/30/George_the_amazing_guinea_pig.jpg" ,
33
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Oryctolagus_cuniculus_Rcdo.jpg/1920px-Oryctolagus_cuniculus_Rcdo.jpg" ,
34
+ "https://upload.wikimedia.org/wikipedia/commons/9/98/Horse-and-pony.jpg" ,
25
35
]
26
36
27
37
@@ -285,8 +295,7 @@ def load_llama4(question: str, image_urls: list[str]) -> ModelRequestData:
285
295
286
296
engine_args = EngineArgs (
287
297
model = model_name ,
288
- max_model_len = 8192 ,
289
- max_num_seqs = 4 ,
298
+ max_model_len = 131072 ,
290
299
tensor_parallel_size = 8 ,
291
300
limit_mm_per_prompt = {"image" : len (image_urls )},
292
301
)
@@ -660,7 +669,7 @@ def run_generate(model, question: str, image_urls: list[str],
660
669
llm .llm_engine .add_lora (lora_request = lora_request )
661
670
662
671
sampling_params = SamplingParams (temperature = 0.0 ,
663
- max_tokens = 128 ,
672
+ max_tokens = 256 ,
664
673
stop_token_ids = req_data .stop_token_ids )
665
674
666
675
outputs = llm .generate (
@@ -694,7 +703,7 @@ def run_chat(model: str, question: str, image_urls: list[str],
694
703
llm .llm_engine .add_lora (lora_request = lora_request )
695
704
696
705
sampling_params = SamplingParams (temperature = 0.0 ,
697
- max_tokens = 128 ,
706
+ max_tokens = 256 ,
698
707
stop_token_ids = req_data .stop_token_ids )
699
708
outputs = llm .chat (
700
709
[{
@@ -729,10 +738,12 @@ def main(args: Namespace):
729
738
method = args .method
730
739
seed = args .seed
731
740
741
+ image_urls = IMAGE_URLS [:args .num_images ]
742
+
732
743
if method == "generate" :
733
- run_generate (model , QUESTION , IMAGE_URLS , seed )
744
+ run_generate (model , QUESTION , image_urls , seed )
734
745
elif method == "chat" :
735
- run_chat (model , QUESTION , IMAGE_URLS , seed )
746
+ run_chat (model , QUESTION , image_urls , seed )
736
747
else :
737
748
raise ValueError (f"Invalid method: { method } " )
738
749
@@ -757,6 +768,12 @@ def main(args: Namespace):
757
768
type = int ,
758
769
default = None ,
759
770
help = "Set the seed when initializing `vllm.LLM`." )
771
+ parser .add_argument (
772
+ "--num-images" ,
773
+ "-n" ,
774
+ choices = list (range (1 , 13 )), # 12 is the max number of images
775
+ default = 2 ,
776
+ help = "Number of images to use for the demo." )
760
777
761
778
args = parser .parse_args ()
762
779
main (args )
0 commit comments