tyrwh commited on
Commit
70d6e34
·
1 Parent(s): bbc26d3

Trying to enforce spawn method off multiprocessing

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -16,12 +16,15 @@ import pandas as pd
16
  from torch import cuda
17
  from flask import Flask, Response, render_template, request, jsonify, send_file, session
18
  from multiprocessing.pool import Pool
 
19
  from pathlib import Path
20
  from PIL import Image
21
  from datetime import datetime
22
  from werkzeug.utils import secure_filename
23
  from yolo_utils import detect_in_image
24
 
 
 
25
  app = Flask(__name__)
26
  app.secret_key = os.environ.get('FLASK_SECRET_KEY', str(uuid.uuid4())) # For session security
27
 
@@ -41,7 +44,10 @@ app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'tif', 'tiff'}
41
  # RESULTS_FOLDER.mkdir(parents=True, exist_ok=True)
42
  # ANNOT_FOLDER.mkdir(parents=True, exist_ok=True)
43
 
44
- async_results = {} # this has to be global I think
 
 
 
45
 
46
  @app.errorhandler(Exception)
47
  def handle_exception(e):
 
16
  from torch import cuda
17
  from flask import Flask, Response, render_template, request, jsonify, send_file, session
18
  from multiprocessing.pool import Pool
19
+ from multiprocessing import set_start_method
20
  from pathlib import Path
21
  from PIL import Image
22
  from datetime import datetime
23
  from werkzeug.utils import secure_filename
24
  from yolo_utils import detect_in_image
25
 
26
+ set_start_method('spawn')
27
+
28
  app = Flask(__name__)
29
  app.secret_key = os.environ.get('FLASK_SECRET_KEY', str(uuid.uuid4())) # For session security
30
 
 
44
  # RESULTS_FOLDER.mkdir(parents=True, exist_ok=True)
45
  # ANNOT_FOLDER.mkdir(parents=True, exist_ok=True)
46
 
47
+ # need a global dict to hold async results objects
48
+ # so you can check the progress of an abr
49
+ # maybe there's a better way around this?
50
+ async_results = {}
51
 
52
  @app.errorhandler(Exception)
53
  def handle_exception(e):