EC2 Default User commited on
Commit
269e36f
·
1 Parent(s): b76891e

Update: Model Zoo 3.0.0

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. dash_app.py +12 -28
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ templates/403.html
dash_app.py CHANGED
@@ -43,22 +43,6 @@ server = Flask(__name__)
43
  server.secret_key = os.urandom(24)
44
 
45
 
46
- ORIGINAL_HOST = "stmicroelectronics-stm32-modelzoo-app.hf.space"
47
-
48
- @server.before_request
49
- def block_original():
50
- """
51
- Blocks access to the original host.
52
- If the request is made to the original host, it aborts with a 403 error.
53
- """
54
- if request.host == ORIGINAL_HOST:
55
- abort(403, description= "❌ This application is exclusively accessible as a replicated Space")
56
-
57
- @server.errorhandler(403)
58
- def forbidden(e):
59
- return render_template("403.html", error=str(e)), 403
60
-
61
-
62
  @server.route('/')
63
  def welcome_page():
64
  """
@@ -94,13 +78,13 @@ external_stylesheets = [dbc.themes.LITERA]
94
  app = dash.Dash(__name__, server=server,external_stylesheets=external_stylesheets, url_base_pathname='/dash_app/', suppress_callback_exceptions=True)
95
 
96
  local_yamls = {
97
- 'image_classification': 'stm32ai-modelzoo-services/image_classification/src/user_config.yaml',
98
- 'human_activity_recognition': 'stm32ai-modelzoo-services/human_activity_recognition/src/user_config.yaml',
99
- 'hand_posture': 'stm32ai-modelzoo-services/hand_posture/src/user_config.yaml',
100
- 'object_detection': 'stm32ai-modelzoo-services/object_detection/src/user_config.yaml',
101
- 'audio_event_detection': 'stm32ai-modelzoo-services/audio_event_detection/src/user_config.yaml',
102
- 'pose_estimation': 'stm32ai-modelzoo-services/pose_estimation/src/user_config.yaml',
103
- 'semantic_segmentation': 'stm32ai-modelzoo-services/semantic_segmentation/src/user_config.yaml'
104
  }
105
 
106
  def banner():
@@ -1016,7 +1000,7 @@ def refresh_metrics(n_intervals, nb_clicks, selected_model, devcloud_username, d
1016
 
1017
  if button == 'process-button' and nb_clicks:
1018
  if devcloud_username and devcloud_password:
1019
- st_script = f"stm32ai-modelzoo-services/{selected_model}/src/stm32ai_main.py"
1020
  execute_async(st_script, devcloud_username, devcloud_password)
1021
  new_training = True
1022
  logs.append("Starting application ...")
@@ -1334,7 +1318,7 @@ def process_button_actions(submit_clicks, exec_nb_clicks, form_input_ids, form_i
1334
  raise PreventUpdate
1335
  elif triggered_button == 'process-button':
1336
  if exec_nb_clicks:
1337
- st_script = f"stm32ai-modelzoo-services/{selected_model}/src/stm32ai_main.py"
1338
  execute_async(st_script, devcloud_username, devcloud_password)
1339
  return "Application is running ..."
1340
  else:
@@ -1400,7 +1384,7 @@ def generate_download_link(n_clicks, selected_model):
1400
  raise PreventUpdate
1401
 
1402
 
1403
- output_directory = os.path.join(os.getcwd(), "./experiments_outputs")
1404
 
1405
  if not os.path.exists(output_directory ):
1406
  raise PreventUpdate
@@ -1437,13 +1421,13 @@ def download_file(subpath):
1437
  Route to download a file from the server.
1438
 
1439
  Parameters:
1440
- - subpath (str): The subpath of the file to be downloaded, relative to the './experiments_outputs' directory.
1441
 
1442
  Returns:
1443
  - Response: A Flask response object to send the file as an attachment if it exists.
1444
  - tuple: A tuple containing an error message and a 404 status code if the file is not found.
1445
  """
1446
- file_path = os.path.join(os.getcwd(), './experiments_outputs', subpath)
1447
  if os.path.exists(file_path):
1448
  return send_file(file_path, as_attachment=True)
1449
  else:
 
43
  server.secret_key = os.urandom(24)
44
 
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  @server.route('/')
47
  def welcome_page():
48
  """
 
78
  app = dash.Dash(__name__, server=server,external_stylesheets=external_stylesheets, url_base_pathname='/dash_app/', suppress_callback_exceptions=True)
79
 
80
  local_yamls = {
81
+ 'image_classification': 'stm32ai-modelzoo-services/image_classification/user_config.yaml',
82
+ 'human_activity_recognition': 'stm32ai-modelzoo-services/human_activity_recognition/user_config.yaml',
83
+ 'hand_posture': 'stm32ai-modelzoo-services/hand_posture/user_config.yaml',
84
+ 'object_detection': 'stm32ai-modelzoo-services/object_detection/user_config.yaml',
85
+ 'audio_event_detection': 'stm32ai-modelzoo-services/audio_event_detection/user_config.yaml',
86
+ 'pose_estimation': 'stm32ai-modelzoo-services/pose_estimation/user_config.yaml',
87
+ 'semantic_segmentation': 'stm32ai-modelzoo-services/semantic_segmentation/user_config.yaml'
88
  }
89
 
90
  def banner():
 
1000
 
1001
  if button == 'process-button' and nb_clicks:
1002
  if devcloud_username and devcloud_password:
1003
+ st_script = f"stm32ai-modelzoo-services/{selected_model}/stm32ai_main.py"
1004
  execute_async(st_script, devcloud_username, devcloud_password)
1005
  new_training = True
1006
  logs.append("Starting application ...")
 
1318
  raise PreventUpdate
1319
  elif triggered_button == 'process-button':
1320
  if exec_nb_clicks:
1321
+ st_script = f"stm32ai-modelzoo-services/{selected_model}/stm32ai_main.py"
1322
  execute_async(st_script, devcloud_username, devcloud_password)
1323
  return "Application is running ..."
1324
  else:
 
1384
  raise PreventUpdate
1385
 
1386
 
1387
+ output_directory = os.path.join(os.getcwd(), "src/experiments_outputs")
1388
 
1389
  if not os.path.exists(output_directory ):
1390
  raise PreventUpdate
 
1421
  Route to download a file from the server.
1422
 
1423
  Parameters:
1424
+ - subpath (str): The subpath of the file to be downloaded, relative to the 'src/experiments_outputs' directory.
1425
 
1426
  Returns:
1427
  - Response: A Flask response object to send the file as an attachment if it exists.
1428
  - tuple: A tuple containing an error message and a 404 status code if the file is not found.
1429
  """
1430
+ file_path = os.path.join(os.getcwd(), 'src/experiments_outputs', subpath)
1431
  if os.path.exists(file_path):
1432
  return send_file(file_path, as_attachment=True)
1433
  else: