bndl commited on
Commit
8aaaedc
·
1 Parent(s): 8da763b

Create gradio_launch_main.py

Browse files
Files changed (1) hide show
  1. gradio_launch_main.py +41 -0
gradio_launch_main.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ from template_gradio_interface import initialize_config, call_predict, create_gradio_interface
3
+
4
+
5
+ if __name__ == "__main__":
6
+ parser = argparse.ArgumentParser(description="App parameters")
7
+ parser.add_argument(
8
+ "-c",
9
+ "--config_path",
10
+ type=str,
11
+ help="The path to the app config file",
12
+ default="config_prediction_alloys.yaml",
13
+ required=False,
14
+ )
15
+
16
+ args = parser.parse_args()
17
+
18
+ print(f"Loading config from file {args.config_path}")
19
+
20
+ # Get the configuration parameters
21
+ config, cols_order, osium_theme, css_styling, example_inputs = initialize_config(args.config_path)
22
+ print("Config initilized successfully")
23
+
24
+ # Create the predict function
25
+ predict_fn = call_predict(config["inference"], cols_order)
26
+ print("Predict function successfully created")
27
+
28
+ demo = create_gradio_interface(
29
+ config["input_order"],
30
+ config["input_mapping"],
31
+ config["output_order"],
32
+ config["output_mapping"],
33
+ example_inputs,
34
+ config["interface_parameters"]["additional_markdown"],
35
+ config["interface_parameters"]["size"],
36
+ osium_theme,
37
+ css_styling,
38
+ predict_fn,
39
+ inverse_design=config["inference"]["inverse_design"],
40
+ )
41
+ demo.launch(server_port=config["webapp"]["server_port"])