Geraldine commited on
Commit
67f296e
·
verified ·
1 Parent(s): c8ce5f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -13,8 +13,9 @@ import os, stat, io
13
  # Load the model in half-precision on the available device(s)
14
  model = AutoModelForVision2Seq.from_pretrained(
15
  "./SmolVLM-500M-Instruct",
16
- torch_dtype=torch.bfloat16,
17
- _attn_implementation="eager"
 
18
  )
19
  processor = AutoProcessor.from_pretrained("./SmolVLM-500M-Instruct")
20
 
@@ -51,7 +52,13 @@ def describe_image(image_array):
51
  inputs = processor(text=prompt, images=[image], return_tensors="pt")
52
 
53
  # Inference: Generation of the output
54
- generated_ids = model.generate(**inputs, max_new_tokens=500)
 
 
 
 
 
 
55
  output_ids = [
56
  generated_ids[len(input_ids) :]
57
  for input_ids, generated_ids in zip(inputs.input_ids, generated_ids)
 
13
  # Load the model in half-precision on the available device(s)
14
  model = AutoModelForVision2Seq.from_pretrained(
15
  "./SmolVLM-500M-Instruct",
16
+ torch_dtype=torch.float32,
17
+ #_attn_implementation="eager",
18
+ device_map="cpu"
19
  )
20
  processor = AutoProcessor.from_pretrained("./SmolVLM-500M-Instruct")
21
 
 
52
  inputs = processor(text=prompt, images=[image], return_tensors="pt")
53
 
54
  # Inference: Generation of the output
55
+ generated_ids = model.generate(
56
+ **inputs,
57
+ max_new_tokens=500,
58
+ num_beams=1, # Disable beam search
59
+ do_sample=False, # Disable sampling
60
+ temperature=1.0 # Set temperature to 1.0
61
+ )
62
  output_ids = [
63
  generated_ids[len(input_ids) :]
64
  for input_ids, generated_ids in zip(inputs.input_ids, generated_ids)