Spaces:
Runtime error
Runtime error
Commit
·
ea60882
1
Parent(s):
4ac4e3b
use .csv file for input
Browse files
app.py
CHANGED
@@ -16,15 +16,8 @@ model = from_pretrained_keras(
|
|
16 |
|
17 |
# Examples
|
18 |
samples = []
|
19 |
-
input_images = glob.glob("asset/source/*.
|
20 |
-
examples = [
|
21 |
-
[
|
22 |
-
im,
|
23 |
-
f"asset/ground_truth/{im.split('/')[-1].split('.')[0]}.png",
|
24 |
-
f"asset/source/{im.split('/')[-1].split('.')[0]}.csv",
|
25 |
-
]
|
26 |
-
for im in input_images
|
27 |
-
]
|
28 |
LABELS = ["wing", "body", "tail", "engine"]
|
29 |
COLORS = ["blue", "green", "red", "pink"]
|
30 |
|
@@ -53,20 +46,18 @@ def visualize_data(point_cloud, labels, output_path=None):
|
|
53 |
|
54 |
|
55 |
def inference(
|
56 |
-
|
57 |
-
truth_path,
|
58 |
-
file_obj,
|
59 |
output_path="asset/output",
|
60 |
cpu=False,
|
61 |
):
|
62 |
|
63 |
-
csv_path =
|
64 |
im_name = csv_path.split("/")[-1].split(".")[0]
|
65 |
|
66 |
if os.path.exists(csv_path):
|
67 |
df = pd.read_csv(csv_path, index_col=None)
|
68 |
inputs = df[["x", "y", "z"]].values
|
69 |
-
y_test = df.iloc[:, 3:].values
|
70 |
else:
|
71 |
warnings.warn(f"{csv_path} not found for {im_path}")
|
72 |
return
|
@@ -82,8 +73,6 @@ article = "<div style='text-align: center;'><a href='https://nouamanetazi.me/' t
|
|
82 |
iface = gr.Interface(
|
83 |
inference, # main function
|
84 |
inputs=[
|
85 |
-
gr.inputs.Image(label="Image", type="filepath"),
|
86 |
-
gr.inputs.Image(label="Ground Truth", type="filepath"),
|
87 |
"file",
|
88 |
],
|
89 |
outputs=[
|
|
|
16 |
|
17 |
# Examples
|
18 |
samples = []
|
19 |
+
input_images = glob.glob("asset/source/*.csv")
|
20 |
+
examples = [[im] for im in input_images]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
LABELS = ["wing", "body", "tail", "engine"]
|
22 |
COLORS = ["blue", "green", "red", "pink"]
|
23 |
|
|
|
46 |
|
47 |
|
48 |
def inference(
|
49 |
+
csv_file,
|
|
|
|
|
50 |
output_path="asset/output",
|
51 |
cpu=False,
|
52 |
):
|
53 |
|
54 |
+
csv_path = csv_file.name
|
55 |
im_name = csv_path.split("/")[-1].split(".")[0]
|
56 |
|
57 |
if os.path.exists(csv_path):
|
58 |
df = pd.read_csv(csv_path, index_col=None)
|
59 |
inputs = df[["x", "y", "z"]].values
|
60 |
+
y_test = df.iloc[:, 3:].values # TODO: show ground truth image if y_test is not None
|
61 |
else:
|
62 |
warnings.warn(f"{csv_path} not found for {im_path}")
|
63 |
return
|
|
|
73 |
iface = gr.Interface(
|
74 |
inference, # main function
|
75 |
inputs=[
|
|
|
|
|
76 |
"file",
|
77 |
],
|
78 |
outputs=[
|