jbprincipe1 commited on
Commit
5c7b51d
·
verified ·
1 Parent(s): 84ae698

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -21,7 +21,7 @@ assistant_prompt = '<|assistant|>\n'
21
  prompt_suffix = "<|end|>\n"
22
 
23
  # Inference function
24
- def ask_phi(image, question):
25
  start_time = time.time()
26
 
27
  prompt = f"{user_prompt}<|image_1|>\n{question}{prompt_suffix}{assistant_prompt}"
@@ -30,7 +30,7 @@ def ask_phi(image, question):
30
 
31
 
32
  params = og.GeneratorParams(model)
33
- params.set_search_options(max_length=16384)
34
  params.set_inputs(inputs)
35
  generator = og.Generator(model, params)
36
 
@@ -54,7 +54,8 @@ demo = gr.Interface(
54
  fn=ask_phi,
55
  inputs=[
56
  gr.Image(type="filepath", label="Upload Image"),
57
- gr.Textbox(label="Your Prompt")
 
58
  ],
59
  outputs=gr.Textbox(label="Phi-3.5 Response"),
60
  title="Phi-3.5 Vision Instruct (ONNX)",
 
21
  prompt_suffix = "<|end|>\n"
22
 
23
  # Inference function
24
+ def ask_phi(image, question, max_length):
25
  start_time = time.time()
26
 
27
  prompt = f"{user_prompt}<|image_1|>\n{question}{prompt_suffix}{assistant_prompt}"
 
30
 
31
 
32
  params = og.GeneratorParams(model)
33
+ params.set_search_options(max_length=max_length)
34
  params.set_inputs(inputs)
35
  generator = og.Generator(model, params)
36
 
 
54
  fn=ask_phi,
55
  inputs=[
56
  gr.Image(type="filepath", label="Upload Image"),
57
+ gr.Textbox(label="Your Prompt"),
58
+ gr.Slider(minimum=16, maximum=16384, step=16, value=4096, label="Tokens")
59
  ],
60
  outputs=gr.Textbox(label="Phi-3.5 Response"),
61
  title="Phi-3.5 Vision Instruct (ONNX)",