howard-hou commited on
Commit
7fa18f3
1 Parent(s): 934f392

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -62,7 +62,7 @@ def generate(
62
  out, state = model.forward(embs=input_embs, state=None)
63
  else:
64
  input_ids = [token]
65
- out, state = model.forward(input_ids, state)
66
  for n in occurrence:
67
  out[n] -= (args.alpha_presence + occurrence[n] * args.alpha_frequency)
68
 
@@ -102,6 +102,9 @@ examples = [
102
  ]
103
  ]
104
  def chatbot(image, question):
 
 
 
105
  image = image_processor(images=image.convert('RGB'), return_tensors='pt')['pixel_values']
106
  image_features = visual_encoder.encode_images(image.unsqueeze(0)).squeeze(0) # [L, D]
107
  input_text = generate_prompt(question)
 
62
  out, state = model.forward(embs=input_embs, state=None)
63
  else:
64
  input_ids = [token]
65
+ out, state = model.forward(tokens=input_ids, state=state)
66
  for n in occurrence:
67
  out[n] -= (args.alpha_presence + occurrence[n] * args.alpha_frequency)
68
 
 
102
  ]
103
  ]
104
  def chatbot(image, question):
105
+ if image is None:
106
+ yield "Please upload an image."
107
+ return
108
  image = image_processor(images=image.convert('RGB'), return_tensors='pt')['pixel_values']
109
  image_features = visual_encoder.encode_images(image.unsqueeze(0)).squeeze(0) # [L, D]
110
  input_text = generate_prompt(question)