Spaces:
Sleeping
Sleeping
martinsinnona
commited on
Commit
·
4fd791e
1
Parent(s):
e8ba5e8
app.py
CHANGED
|
@@ -3,7 +3,8 @@ from transformers import AutoProcessor, Pix2StructForConditionalGeneration
|
|
| 3 |
import torch
|
| 4 |
from PIL import Image
|
| 5 |
import json
|
| 6 |
-
import vl_convert as vlc
|
|
|
|
| 7 |
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
|
@@ -33,7 +34,7 @@ def draw_vega(vega, scale=3):
|
|
| 33 |
spec = json.dumps(vega, indent=4)
|
| 34 |
png_data = vlc.vegalite_to_png(vl_spec=spec, scale=scale)
|
| 35 |
|
| 36 |
-
return Image.open(png_data)
|
| 37 |
|
| 38 |
def string_to_vega(string):
|
| 39 |
|
|
@@ -62,4 +63,4 @@ iface = gr.Interface(
|
|
| 62 |
|
| 63 |
# Launch the interface
|
| 64 |
if __name__ == "__main__":
|
| 65 |
-
iface.launch()
|
|
|
|
| 3 |
import torch
|
| 4 |
from PIL import Image
|
| 5 |
import json
|
| 6 |
+
import vl_convert as vlc
|
| 7 |
+
from io import BytesIO
|
| 8 |
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
|
|
|
|
| 34 |
spec = json.dumps(vega, indent=4)
|
| 35 |
png_data = vlc.vegalite_to_png(vl_spec=spec, scale=scale)
|
| 36 |
|
| 37 |
+
return Image.open(BytesIO(png_data))
|
| 38 |
|
| 39 |
def string_to_vega(string):
|
| 40 |
|
|
|
|
| 63 |
|
| 64 |
# Launch the interface
|
| 65 |
if __name__ == "__main__":
|
| 66 |
+
iface.launch(share=True)
|