Spaces:
Sleeping
Sleeping
mrbeliever
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -34,12 +34,25 @@ def generate_caption(
|
|
34 |
image: Image.Image,
|
35 |
params: dict[str, Any] = DEFAULT_PARAMS,
|
36 |
) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
inputs = model.build_conversation_input_ids(
|
38 |
tokenizer=tokenizer,
|
39 |
query=DEFAULT_QUERY,
|
40 |
history=[],
|
41 |
images=[image],
|
42 |
)
|
|
|
|
|
|
|
|
|
|
|
43 |
inputs = {
|
44 |
"input_ids": inputs["input_ids"].unsqueeze(0).to(device=DEVICE),
|
45 |
"token_type_ids": inputs["token_type_ids"].unsqueeze(0).to(device=DEVICE),
|
@@ -78,8 +91,8 @@ css = """
|
|
78 |
border-radius: 8px;
|
79 |
}
|
80 |
#run_button {
|
81 |
-
background-color: #
|
82 |
-
color:
|
83 |
border-radius: 10px;
|
84 |
padding: 10px;
|
85 |
cursor: pointer;
|
@@ -95,7 +108,7 @@ css = """
|
|
95 |
with gr.Blocks(css=css) as demo:
|
96 |
with gr.Column(elem_id="container"):
|
97 |
input_image = gr.Image(type="pil", elem_id="input_image")
|
98 |
-
run_button = gr.Button(value="Generate", elem_id="run_button")
|
99 |
output_caption = gr.Textbox(label="Generated Caption", show_copy_button=True, elem_id="output_caption")
|
100 |
|
101 |
run_button.click(
|
|
|
34 |
image: Image.Image,
|
35 |
params: dict[str, Any] = DEFAULT_PARAMS,
|
36 |
) -> str:
|
37 |
+
# Debugging: Check image size and format
|
38 |
+
print(f"Uploaded image format: {image.format}, size: {image.size}")
|
39 |
+
|
40 |
+
# Convert image to the expected format (if needed)
|
41 |
+
if image.mode != "RGB":
|
42 |
+
image = image.convert("RGB")
|
43 |
+
print(f"Image converted to RGB mode: {image.mode}")
|
44 |
+
|
45 |
inputs = model.build_conversation_input_ids(
|
46 |
tokenizer=tokenizer,
|
47 |
query=DEFAULT_QUERY,
|
48 |
history=[],
|
49 |
images=[image],
|
50 |
)
|
51 |
+
|
52 |
+
# Debugging: Check tensor shapes
|
53 |
+
print(f"Input IDs shape: {inputs['input_ids'].shape}")
|
54 |
+
print(f"Images tensor shape: {inputs['images'][0].shape}")
|
55 |
+
|
56 |
inputs = {
|
57 |
"input_ids": inputs["input_ids"].unsqueeze(0).to(device=DEVICE),
|
58 |
"token_type_ids": inputs["token_type_ids"].unsqueeze(0).to(device=DEVICE),
|
|
|
91 |
border-radius: 8px;
|
92 |
}
|
93 |
#run_button {
|
94 |
+
background-color: #000000; /* Dark button color */
|
95 |
+
color: white; /* White text */
|
96 |
border-radius: 10px;
|
97 |
padding: 10px;
|
98 |
cursor: pointer;
|
|
|
108 |
with gr.Blocks(css=css) as demo:
|
109 |
with gr.Column(elem_id="container"):
|
110 |
input_image = gr.Image(type="pil", elem_id="input_image")
|
111 |
+
run_button = gr.Button(value="Generate Caption", elem_id="run_button")
|
112 |
output_caption = gr.Textbox(label="Generated Caption", show_copy_button=True, elem_id="output_caption")
|
113 |
|
114 |
run_button.click(
|