Spaces:
Runtime error
Runtime error
JustSkyDev commited on
Commit ·
b1e7a24
1
Parent(s): fa33891
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,11 @@ import io
|
|
| 7 |
import base64
|
| 8 |
import os
|
| 9 |
|
| 10 |
-
os.
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
class SegmentationBody(BaseModel):
|
| 14 |
baseImage: str
|
|
@@ -26,7 +29,7 @@ def process_image(input_image):
|
|
| 26 |
def root_path():
|
| 27 |
return { "log": "Lol" }
|
| 28 |
|
| 29 |
-
@app.post("/api/segment
|
| 30 |
def api_segment(data: SegmentationBody):
|
| 31 |
# Convert base64 string to PIL Image
|
| 32 |
input_image = Image.open(io.BytesIO(base64.b64decode(data.baseImage)))
|
|
|
|
| 7 |
import base64
|
| 8 |
import os
|
| 9 |
|
| 10 |
+
if not os.path.exists('/.cache'):
|
| 11 |
+
try:
|
| 12 |
+
os.makedirs('/.cache')
|
| 13 |
+
except PermissionError:
|
| 14 |
+
print("Unable to create /.cache directory due to insufficient permissions.")
|
| 15 |
|
| 16 |
class SegmentationBody(BaseModel):
|
| 17 |
baseImage: str
|
|
|
|
| 29 |
def root_path():
|
| 30 |
return { "log": "Lol" }
|
| 31 |
|
| 32 |
+
@app.post("/api/segment")
|
| 33 |
def api_segment(data: SegmentationBody):
|
| 34 |
# Convert base64 string to PIL Image
|
| 35 |
input_image = Image.open(io.BytesIO(base64.b64decode(data.baseImage)))
|