Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import torch
|
|
8 |
import numpy as np
|
9 |
import spaces
|
10 |
import subprocess
|
|
|
11 |
|
12 |
# Ensure flash-attn is installed correctly
|
13 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
@@ -78,13 +79,14 @@ def plot_image_with_bboxes(image_np, bboxes, labels=None):
|
|
78 |
plt.axis('off')
|
79 |
|
80 |
# Save the plot to a BytesIO object
|
81 |
-
from io import BytesIO
|
82 |
buf = BytesIO()
|
83 |
plt.savefig(buf, format='png')
|
84 |
plt.close()
|
85 |
buf.seek(0)
|
86 |
|
87 |
-
|
|
|
|
|
88 |
|
89 |
# Gradio function to process uploaded images
|
90 |
@spaces.GPU
|
|
|
8 |
import numpy as np
|
9 |
import spaces
|
10 |
import subprocess
|
11 |
+
from io import BytesIO
|
12 |
|
13 |
# Ensure flash-attn is installed correctly
|
14 |
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
|
|
79 |
plt.axis('off')
|
80 |
|
81 |
# Save the plot to a BytesIO object
|
|
|
82 |
buf = BytesIO()
|
83 |
plt.savefig(buf, format='png')
|
84 |
plt.close()
|
85 |
buf.seek(0)
|
86 |
|
87 |
+
# Convert the BytesIO buffer to PIL Image
|
88 |
+
pil_image = Image.open(buf)
|
89 |
+
return pil_image
|
90 |
|
91 |
# Gradio function to process uploaded images
|
92 |
@spaces.GPU
|