jbprincipe1 commited on
Commit
b265954
·
verified ·
1 Parent(s): 185553a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -20,9 +20,6 @@ user_prompt = '<|user|>\n'
20
  assistant_prompt = '<|assistant|>\n'
21
  prompt_suffix = "<|end|>\n"
22
 
23
- params = og.GeneratorParams(model)
24
- params.set_search_options(max_length=4096)
25
-
26
  # Inference function
27
  def ask_phi(image, question):
28
  prompt = f"{user_prompt}<|image_1|>\n{question}{prompt_suffix}{assistant_prompt}"
@@ -30,6 +27,8 @@ def ask_phi(image, question):
30
  inputs = processor(prompt=prompt, images=images, return_tensors="pt")
31
 
32
  start_time = time.time()
 
 
33
  params.set_inputs(inputs)
34
  generator = og.Generator(model, params)
35
  print(f"Generator setup took {time.time() - start_time} seconds")
@@ -41,7 +40,6 @@ def ask_phi(image, question):
41
  new_token = generator.get_next_tokens()[0]
42
  response += tokenizer_stream.decode(new_token)
43
 
44
- del generator
45
  return response
46
 
47
  # Gradio Interface
 
20
  assistant_prompt = '<|assistant|>\n'
21
  prompt_suffix = "<|end|>\n"
22
 
 
 
 
23
  # Inference function
24
  def ask_phi(image, question):
25
  prompt = f"{user_prompt}<|image_1|>\n{question}{prompt_suffix}{assistant_prompt}"
 
27
  inputs = processor(prompt=prompt, images=images, return_tensors="pt")
28
 
29
  start_time = time.time()
30
+ params = og.GeneratorParams(model)
31
+ params.set_search_options(max_length=4096)
32
  params.set_inputs(inputs)
33
  generator = og.Generator(model, params)
34
  print(f"Generator setup took {time.time() - start_time} seconds")
 
40
  new_token = generator.get_next_tokens()[0]
41
  response += tokenizer_stream.decode(new_token)
42
 
 
43
  return response
44
 
45
  # Gradio Interface