Spaces:
Runtime error
Runtime error
frances-dean
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
import matplotlib.pyplot as plt
|
4 |
from scipy.integrate import odeint
|
5 |
import torch
|
@@ -107,7 +107,7 @@ class Echo(torchvision.datasets.VisionDataset):
|
|
107 |
self.fnames, self.outcome = [], []
|
108 |
|
109 |
if self.split == "EXTERNAL_TEST":
|
110 |
-
|
111 |
else:
|
112 |
# Load video-level labels
|
113 |
with open(f"{self.root}FileList.csv") as f:
|
@@ -119,7 +119,7 @@ class Echo(torchvision.datasets.VisionDataset):
|
|
119 |
|
120 |
self.header = data.columns.tolist()
|
121 |
self.fnames = data["FileName"].tolist()
|
122 |
-
|
123 |
self.outcome = data.values.tolist()
|
124 |
|
125 |
# Check that files are present
|
@@ -162,11 +162,11 @@ class Echo(torchvision.datasets.VisionDataset):
|
|
162 |
def __getitem__(self, index):
|
163 |
# Find filename of video
|
164 |
if self.split == "EXTERNAL_TEST":
|
165 |
-
|
166 |
elif self.split == "CLINICAL_TEST":
|
167 |
-
|
168 |
else:
|
169 |
-
|
170 |
|
171 |
# Load video into np.array
|
172 |
video = echonet.utils.loadvideo(video).astype(np.float32)
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
import matplotlib.pyplot as plt
|
4 |
from scipy.integrate import odeint
|
5 |
import torch
|
|
|
107 |
self.fnames, self.outcome = [], []
|
108 |
|
109 |
if self.split == "EXTERNAL_TEST":
|
110 |
+
self.fnames = sorted(os.listdir(self.external_test_location))
|
111 |
else:
|
112 |
# Load video-level labels
|
113 |
with open(f"{self.root}FileList.csv") as f:
|
|
|
119 |
|
120 |
self.header = data.columns.tolist()
|
121 |
self.fnames = data["FileName"].tolist()
|
122 |
+
self.fnames = [fn + ".avi" for fn in self.fnames if os.path.splitext(fn)[1] == ""] # Assume avi if no suffix
|
123 |
self.outcome = data.values.tolist()
|
124 |
|
125 |
# Check that files are present
|
|
|
162 |
def __getitem__(self, index):
|
163 |
# Find filename of video
|
164 |
if self.split == "EXTERNAL_TEST":
|
165 |
+
video = os.path.join(self.external_test_location, self.fnames[index])
|
166 |
elif self.split == "CLINICAL_TEST":
|
167 |
+
video = os.path.join(self.root, "ProcessedStrainStudyA4c", self.fnames[index])
|
168 |
else:
|
169 |
+
video = os.path.join(self.root, "Videos", self.fnames[index])
|
170 |
|
171 |
# Load video into np.array
|
172 |
video = echonet.utils.loadvideo(video).astype(np.float32)
|