breadlicker45 commited on
Commit
c51582e
·
verified ·
1 Parent(s): 0ce1028

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -55,7 +55,7 @@ def process_image_and_text(image_pil, num_beams, temperature, seed):
55
  torch.manual_seed(seed) # Set random seed for reproducibility
56
 
57
  with torch.inference_mode():
58
- generation = model.generate(**model_inputs, max_new_tokens=200, do_sample=False, num_beams=num_beams, temperature=temperature)
59
  generation = generation[0][input_len:]
60
  decoded = processor.decode(generation, skip_special_tokens=True)
61
 
@@ -70,8 +70,8 @@ if __name__ == "__main__":
70
  fn=process_image_and_text,
71
  inputs=[
72
  gr.Image(type="pil", label="Upload an image"),
73
- gr.Slider(minimum=1, maximum=10, step=1, value=1, label="Number of Beams"),
74
- gr.Slider(minimum=0.1, maximum=2.0, step=0.1, value=1.0, label="Temperature"),
75
  gr.Number(label="Random Seed", value=0, precision=0),
76
  ],
77
  outputs=gr.Textbox(label="Generated Text"),
 
55
  torch.manual_seed(seed) # Set random seed for reproducibility
56
 
57
  with torch.inference_mode():
58
+ generation = model.generate(**model_inputs, max_new_tokens=200, do_sample=True, num_beams=num_beams, temperature=temperature)
59
  generation = generation[0][input_len:]
60
  decoded = processor.decode(generation, skip_special_tokens=True)
61
 
 
70
  fn=process_image_and_text,
71
  inputs=[
72
  gr.Image(type="pil", label="Upload an image"),
73
+ gr.Slider(minimum=1, maximum=10, step=1, value=10, label="Number of Beams"),
74
+ gr.Slider(minimum=0.1, maximum=2.0, step=0.1, value=1.5, label="Temperature"),
75
  gr.Number(label="Random Seed", value=0, precision=0),
76
  ],
77
  outputs=gr.Textbox(label="Generated Text"),