Spaces:
Sleeping
Sleeping
martinsinnona
commited on
Commit
•
db924e3
1
Parent(s):
3c28bcd
app.py
CHANGED
@@ -17,11 +17,9 @@ model.eval()
|
|
17 |
|
18 |
def generate(image):
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
generated_caption = "{'mark': 'bar', 'encoding': {'x': {'field': '', 'type': 'ordinal'}, 'y': {'field': '', 'type': 'quantitative'}}, 'data': {'values': [{'x': 0, 'y': 5.6}, {'x': 1, 'y': 6.7}, {'x': 2, 'y': 5.0}, {'x': 3, 'y': 18.7}]}}"
|
25 |
|
26 |
# Generate the Vega image
|
27 |
vega = string_to_vega(generated_caption)
|
|
|
17 |
|
18 |
def generate(image):
|
19 |
|
20 |
+
inputs = processor(images=image, return_tensors="pt", max_patches=1024).to(device)
|
21 |
+
generated_ids = model.generate(flattened_patches=inputs.flattened_patches, attention_mask=inputs.attention_mask, max_length=600)
|
22 |
+
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
|
|
|
23 |
|
24 |
# Generate the Vega image
|
25 |
vega = string_to_vega(generated_caption)
|