RaushanTurganbay HF staff commited on
Commit
fb9f560
·
verified ·
1 Parent(s): daa724b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -58,10 +58,12 @@ def bot_streaming(message, history):
58
  if len(image) == 1:
59
  if image[0].endswith(video_extensions):
60
 
61
- image = sample_frames(image[0], 32)
 
62
  prompt = f"<|im_start|>user <video>\n{message.text}<|im_end|><|im_start|>assistant"
63
  elif image[0].endswith(image_extensions):
64
  image = Image.open(image[0]).convert("RGB")
 
65
  prompt = f"<|im_start|>user <image>\n{message.text}<|im_end|><|im_start|>assistant"
66
 
67
  elif len(image) > 1:
@@ -82,9 +84,10 @@ def bot_streaming(message, history):
82
  prompt = "<|im_start|>user"+ toks + f"\n{user_prompt}<|im_end|><|im_start|>assistant"
83
 
84
  image = image_list
 
85
 
86
 
87
- inputs = processor(prompt, image, return_tensors="pt").to("cuda", torch.float16)
88
  streamer = TextIteratorStreamer(processor, **{"max_new_tokens": 200, "skip_special_tokens": True})
89
  generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=100)
90
  generated_text = ""
 
58
  if len(image) == 1:
59
  if image[0].endswith(video_extensions):
60
 
61
+ video = sample_frames(image[0], 32)
62
+ image = None
63
  prompt = f"<|im_start|>user <video>\n{message.text}<|im_end|><|im_start|>assistant"
64
  elif image[0].endswith(image_extensions):
65
  image = Image.open(image[0]).convert("RGB")
66
+ video = None
67
  prompt = f"<|im_start|>user <image>\n{message.text}<|im_end|><|im_start|>assistant"
68
 
69
  elif len(image) > 1:
 
84
  prompt = "<|im_start|>user"+ toks + f"\n{user_prompt}<|im_end|><|im_start|>assistant"
85
 
86
  image = image_list
87
+ video = None
88
 
89
 
90
+ inputs = processor(text=prompt, images=image, videos=video, return_tensors="pt").to("cuda", torch.float16)
91
  streamer = TextIteratorStreamer(processor, **{"max_new_tokens": 200, "skip_special_tokens": True})
92
  generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=100)
93
  generated_text = ""