Update app.py
Browse files
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 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
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
|
78 |
-
description="Upload an image to get a detailed description using the
|
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
|