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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -52,13 +52,14 @@ def describe_image(image_array):
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)
@@ -74,8 +75,8 @@ iface = gr.Interface(
74
  fn=describe_image,
75
  inputs=gr.Image(),
76
  outputs=[gr.Textbox(label="Description"), gr.JSON(label="Embeddings")],
77
- title="Image Description with Qwen Model",
78
- description="Upload an image to get a detailed description using the Qwen2-VL-7B-Instruct model."
79
  )
80
 
81
  # Launch the app
 
52
  inputs = processor(text=prompt, images=[image], return_tensors="pt")
53
 
54
  # Inference: Generation of the output
55
+ with torch.no_grad():
56
+ generated_ids = model.generate(
57
+ **inputs,
58
+ max_new_tokens=500,
59
+ num_beams=1, # Disable beam search
60
+ do_sample=False, # Disable sampling
61
+ temperature=1.0 # Set temperature to 1.0
62
+ )
63
  output_ids = [
64
  generated_ids[len(input_ids) :]
65
  for input_ids, generated_ids in zip(inputs.input_ids, generated_ids)
 
75
  fn=describe_image,
76
  inputs=gr.Image(),
77
  outputs=[gr.Textbox(label="Description"), gr.JSON(label="Embeddings")],
78
+ title="Image Description with SmolVLM Model",
79
+ description="Upload an image to get a detailed description using the SmolVLM-500M-Instruct model."
80
  )
81
 
82
  # Launch the app