Spaces:
Sleeping
Sleeping
Commit ·
b7e9616
1
Parent(s): a860353
main.py
CHANGED
|
@@ -75,16 +75,17 @@ async def root():
|
|
| 75 |
|
| 76 |
@app.post("/segmentation")
|
| 77 |
async def segmentation(file: UploadFile = File(...)):
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
contents = await file.read()
|
| 81 |
image = Image.open(BytesIO(contents))
|
| 82 |
open_cv_image = np.array(image)
|
| 83 |
open_cv_image = cv2.resize(open_cv_image, (160, 544))
|
| 84 |
print(type(image_dataset))
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
dataset = CustomDataset(
|
| 88 |
dataloader = DataLoader(dataset, batch_size=16, shuffle=False, num_workers=0)
|
| 89 |
|
| 90 |
try:
|
|
|
|
| 75 |
|
| 76 |
@app.post("/segmentation")
|
| 77 |
async def segmentation(file: UploadFile = File(...)):
|
| 78 |
+
image_dataset = []
|
| 79 |
+
for file in os.listdir("./images"):
|
| 80 |
+
image_dataset.append(cv2.resize(cv2.imread('./images/' + file), (160, 544)))
|
| 81 |
contents = await file.read()
|
| 82 |
image = Image.open(BytesIO(contents))
|
| 83 |
open_cv_image = np.array(image)
|
| 84 |
open_cv_image = cv2.resize(open_cv_image, (160, 544))
|
| 85 |
print(type(image_dataset))
|
| 86 |
+
image_dataset.insert(0, open_cv_image)
|
| 87 |
+
image_dataset = np.transpose(image_dataset, (0, 3, 1, 2))
|
| 88 |
+
dataset = CustomDataset(image_dataset)
|
| 89 |
dataloader = DataLoader(dataset, batch_size=16, shuffle=False, num_workers=0)
|
| 90 |
|
| 91 |
try:
|