苏泓源 commited on
Commit
9036b2e
·
1 Parent(s): ef007f9
Files changed (3) hide show
  1. __pycache__/model.cpython-39.pyc +0 -0
  2. app.py +55 -16
  3. push.sh +3 -0
__pycache__/model.cpython-39.pyc ADDED
Binary file (1.01 kB). View file
 
app.py CHANGED
@@ -8,22 +8,61 @@ model = Net(100, 50, 10)
8
  model.load_state_dict(torch.load('model.pth'))
9
  model.eval()
10
 
11
- def infer(file_obj):
12
- results = ""
13
- for file in file_obj:
14
- data = np.load(file.name)
15
- output = model(torch.from_numpy(data).float()).detach().numpy()
16
- results += np.array_str(output) + "\n"
17
- return results
18
-
19
- with gr.Blocks("Test") as demo:
20
- gr.Markdown("## Test")
21
- output = gr.Textbox(label="Output")
22
- data = gr.UploadButton(
23
- label="Upload a .npy",
24
- file_count="multiple",
25
- file_types=[".npy"])
26
- data.upload(fn=infer, inputs=data, outputs=output)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  if __name__ == "__main__":
29
  demo.launch()
 
8
  model.load_state_dict(torch.load('model.pth'))
9
  model.eval()
10
 
11
+
12
+
13
+ import plotly.graph_objects as go
14
+
15
+ def demo_plot(city, facility):
16
+ fig = go.Figure()
17
+ fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4, 5],
18
+ y=[1, 3, 2, 3, 1, 4],
19
+ mode='lines+markers',
20
+ name='City'))
21
+ fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4, 5],
22
+ y=[2, 5, 3, 1, 4, 2],
23
+ mode='lines+markers',
24
+ name='Facility'))
25
+ fig.update_layout(title='City and Facility',
26
+ xaxis_title='X',
27
+ yaxis_title='Y')
28
+ return fig
29
+
30
+
31
+ # def infer(file_obj):
32
+ # results = ""
33
+ # for file in file_obj:
34
+ # data = np.load(file.name)
35
+ # output = model(torch.from_numpy(data).float()).detach().numpy()
36
+ # results += np.array_str(output) + "\n"
37
+ # return results
38
+
39
+
40
+
41
+
42
+ # with gr.Blocks("Test") as demo:
43
+ # gr.Markdown("## Test")
44
+ # output = gr.Textbox(label="Output")
45
+ # data = gr.UploadButton(
46
+ # label="Upload a .npy",
47
+ # file_count="multiple",
48
+ # file_types=[".npy"])
49
+ # data.upload(fn=infer, inputs=data, outputs=output)
50
+
51
+
52
+
53
+ with gr.Blocks() as demo:
54
+ with gr.Column():
55
+ # with gr.Row():
56
+ # min_price = gr.Number(value=250, label="Minimum Price")
57
+ # max_price = gr.Number(value=1000, label="Maximum Price")
58
+ city = gr.CheckboxGroup(choices=["New York", "Boston", "Los Angeles", "Chicago"], value=["New York"], label="Select City:")
59
+ facility = gr.CheckboxGroup(choices=["School", "Hospital", "Park"], value=["Hospital"], label="Select Facility:")
60
+ btn = gr.Button(value="Generate")
61
+ map = gr.Plot()
62
+ demo.load(demo_plot, [city, facility], map)
63
+ btn.click(demo_plot, [city, facility], map)
64
+ # demo.load(filter_map, [min_price, max_price, boroughs], map)
65
+ # btn.click(filter_map, [min_price, max_price, boroughs], map)
66
 
67
  if __name__ == "__main__":
68
  demo.launch()
push.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ git add .
2
+ git commit -m "update"
3
+ git push