warshanks commited on
Commit
6ae9a7b
·
verified ·
1 Parent(s): 9d2aff9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -19,6 +19,8 @@ processor = AutoProcessor.from_pretrained(model_id)
19
  model = AutoModelForImageTextToText.from_pretrained(
20
  model_id, device_map="auto", torch_dtype=torch.bfloat16
21
  )
 
 
22
 
23
  MAX_NUM_IMAGES = int(os.getenv("MAX_NUM_IMAGES", "5"))
24
 
@@ -188,6 +190,7 @@ def run(message: dict, history: list[dict], system_prompt: str = "", max_new_tok
188
  inputs,
189
  max_new_tokens=max_new_tokens,
190
  streamer=streamer,
 
191
  temperature=1.0,
192
  top_p=0.95,
193
  top_k=64,
@@ -217,7 +220,7 @@ demo = gr.ChatInterface(
217
  gr.Textbox(label="System Prompt", value="You are a helpful medical expert."),
218
  gr.Slider(label="Max New Tokens", minimum=100, maximum=8192, step=10, value=2048),
219
  ],
220
- stop_btn=False,
221
  title="MedGemma 4B IT",
222
  description=DESCRIPTION,
223
  run_examples_on_click=False,
 
19
  model = AutoModelForImageTextToText.from_pretrained(
20
  model_id, device_map="auto", torch_dtype=torch.bfloat16
21
  )
22
+ # Update the model's generation config to enable sampling by default
23
+ model.generation_config.do_sample = True
24
 
25
  MAX_NUM_IMAGES = int(os.getenv("MAX_NUM_IMAGES", "5"))
26
 
 
190
  inputs,
191
  max_new_tokens=max_new_tokens,
192
  streamer=streamer,
193
+ do_sample=True,
194
  temperature=1.0,
195
  top_p=0.95,
196
  top_k=64,
 
220
  gr.Textbox(label="System Prompt", value="You are a helpful medical expert."),
221
  gr.Slider(label="Max New Tokens", minimum=100, maximum=8192, step=10, value=2048),
222
  ],
223
+ stop_btn=True,
224
  title="MedGemma 4B IT",
225
  description=DESCRIPTION,
226
  run_examples_on_click=False,