Spaces:
Runtime error
Runtime error
苏泓源
commited on
Commit
·
62202b1
1
Parent(s):
70f0045
update
Browse files
app.py
CHANGED
@@ -4,9 +4,9 @@ import torch
|
|
4 |
from model import Net
|
5 |
|
6 |
|
7 |
-
model = Net(100, 50, 10)
|
8 |
-
model.load_state_dict(torch.load('model.pth'))
|
9 |
-
model.eval()
|
10 |
|
11 |
|
12 |
|
@@ -33,41 +33,41 @@ def demo_plot(city, facility):
|
|
33 |
|
34 |
|
35 |
|
36 |
-
def infer(file_obj):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
-
with gr.Blocks("TTest") as demo:
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
#
|
61 |
-
#
|
62 |
-
#
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
demo.launch()
|
|
|
4 |
from model import Net
|
5 |
|
6 |
|
7 |
+
# model = Net(100, 50, 10)
|
8 |
+
# model.load_state_dict(torch.load('model.pth'))
|
9 |
+
# model.eval()
|
10 |
|
11 |
|
12 |
|
|
|
33 |
|
34 |
|
35 |
|
36 |
+
# def infer(file_obj):
|
37 |
+
# results = ""
|
38 |
+
# for file in file_obj:
|
39 |
+
# data = np.load(file.name)
|
40 |
+
# output = model(torch.from_numpy(data).float()).detach().numpy()
|
41 |
+
# results += np.array_str(output) + "\n"
|
42 |
+
# return results
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
+
# with gr.Blocks("TTest") as demo:
|
48 |
+
# gr.Markdown("## TTest")
|
49 |
+
# output = gr.Textbox(label="Output")
|
50 |
+
# data = gr.UploadButton(
|
51 |
+
# label="Upload a .npy",
|
52 |
+
# file_count="multiple",
|
53 |
+
# file_types=[".npy"])
|
54 |
+
# data.upload(fn=infer, inputs=data, outputs=output)
|
55 |
|
56 |
|
57 |
|
58 |
+
with gr.Blocks() as demo:
|
59 |
+
with gr.Column():
|
60 |
+
# with gr.Row():
|
61 |
+
# min_price = gr.Number(value=250, label="Minimum Price")
|
62 |
+
# max_price = gr.Number(value=1000, label="Maximum Price")
|
63 |
+
city = gr.CheckboxGroup(choices=["New York", "Boston", "Los Angeles", "Chicago"], value=["New York"], label="Select City:")
|
64 |
+
facility = gr.CheckboxGroup(choices=["School", "Hospital", "Park"], value=["Hospital"], label="Select Facility:")
|
65 |
+
btn = gr.Button(value="Generate")
|
66 |
+
map = gr.Plot()
|
67 |
+
demo.load(demo_plot, [city, facility], map)
|
68 |
+
btn.click(demo_plot, [city, facility], map)
|
69 |
+
demo.load(filter_map, [min_price, max_price, boroughs], map)
|
70 |
+
btn.click(filter_map, [min_price, max_price, boroughs], map)
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
demo.launch()
|