praysimanjuntak commited on
Commit
d1567f0
1 Parent(s): 0b9409b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -12,6 +12,7 @@ from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN
12
  from llava.model.builder import load_pretrained_model
13
  from llava.mm_utils import tokenizer_image_token
14
  from transformers.generation.streamers import TextIteratorStreamer
 
15
 
16
  def load_image(image_file):
17
  if image_file.startswith('http') or image_file.startswith('https'):
@@ -21,6 +22,7 @@ def load_image(image_file):
21
  image = Image.open(image_file).convert('RGB')
22
  return image
23
 
 
24
  def bot_streaming(message, history):
25
  device = "cuda:0"
26
  tokenizer, model, image_processor, context_len = load_pretrained_model(model_path="./checkpoints/llava-phi3-3.8b-lora", model_name="llava-phi3-3.8b-lora", model_base="microsoft/Phi-3-mini-128k-instruct", load_8bit=False, load_4bit=False, device=device)
 
12
  from llava.model.builder import load_pretrained_model
13
  from llava.mm_utils import tokenizer_image_token
14
  from transformers.generation.streamers import TextIteratorStreamer
15
+ import spaces
16
 
17
  def load_image(image_file):
18
  if image_file.startswith('http') or image_file.startswith('https'):
 
22
  image = Image.open(image_file).convert('RGB')
23
  return image
24
 
25
+ @spaces.GPU
26
  def bot_streaming(message, history):
27
  device = "cuda:0"
28
  tokenizer, model, image_processor, context_len = load_pretrained_model(model_path="./checkpoints/llava-phi3-3.8b-lora", model_name="llava-phi3-3.8b-lora", model_base="microsoft/Phi-3-mini-128k-instruct", load_8bit=False, load_4bit=False, device=device)