Sa-m commited on
Commit
5ef388b
·
1 Parent(s): 8000502

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -56,9 +56,18 @@ app = Flask(__name__)
56
 
57
  @app.route('/')
58
  def index():
59
- return '<iframe frameBorder="0" height="100%" src="{}/?__dark-theme={}" width="100%"></iframe>'.format(
60
- os.getenv('INACCEL_URL'),request.args.get('__dark-theme', 'false'))
 
 
 
 
 
 
 
 
61
 
62
 
63
  if __name__ == '__main__':
 
64
  app.run(host='0.0.0.0', port=7860)
 
56
 
57
  @app.route('/')
58
  def index():
59
+ '''return '<iframe frameBorder="0" height="100%" src="{}/?__dark-theme={}" width="100%"></iframe>'.format(
60
+ os.getenv('INACCEL_URL'),request.args.get('__dark-theme', 'false'))'''
61
+ if request.files.get("image"):
62
+ image_file = request.files["image"]
63
+ image_bytes = image_file.read()
64
+
65
+ img = Image.open(io.BytesIO(image_bytes))
66
+
67
+ results = model(img, size=640) # reduce size=320 for faster inference
68
+ return results.pandas().xyxy[0].to_json(orient="records")
69
 
70
 
71
  if __name__ == '__main__':
72
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='best2.pt', force_reload=True) # force_reload to recache
73
  app.run(host='0.0.0.0', port=7860)