praysimanjuntak commited on
Commit
5f99fce
1 Parent(s): 42b4c66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -15,18 +15,6 @@ from transformers.generation.streamers import TextIteratorStreamer
15
  import spaces
16
  import torch
17
 
18
-
19
- if torch.cuda.is_available():
20
- device = "cuda"
21
- print("Using GPU")
22
- else:
23
- device = "cpu"
24
- print("Using CPU")
25
-
26
- device = "cuda:0"
27
- 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)
28
- model.to(device)
29
-
30
  def load_image(image_file):
31
  if image_file.startswith('http') or image_file.startswith('https'):
32
  response = requests.get(image_file)
@@ -37,7 +25,10 @@ def load_image(image_file):
37
 
38
  @spaces.GPU
39
  def bot_streaming(message, history):
40
- print(message)
 
 
 
41
  if message["files"]:
42
  # message["files"][-1] is a Dict or just a string
43
  if type(message["files"][-1]) == dict:
 
15
  import spaces
16
  import torch
17
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  def load_image(image_file):
19
  if image_file.startswith('http') or image_file.startswith('https'):
20
  response = requests.get(image_file)
 
25
 
26
  @spaces.GPU
27
  def bot_streaming(message, history):
28
+ device = "cuda:0"
29
+ 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)
30
+ model.to(device)
31
+
32
  if message["files"]:
33
  # message["files"][-1] is a Dict or just a string
34
  if type(message["files"][-1]) == dict: