Skip to content

Commit

Permalink
Fix/solve sanic security issues (#109)
Browse files Browse the repository at this point in the history
* Solve sonic security issue

* Renaming function

* Update exporters

---------
  • Loading branch information
HonzaCuhel authored Oct 8, 2024
1 parent b6e79e1 commit a9d60c8
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 23 deletions.
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
import os
import aiofiles

Sanic.START_METHOD_SET = True
Sanic.start_method = "fork"
Config.KEEP_ALIVE = False
Config.RESPONSE_TIMEOUT = 1000
app = Sanic(__name__)
print(app.start_method, app.START_METHOD_SET)
app.config.static_path = (Path(__file__).parent / './client/build/static').resolve().absolute()
if not app.config.static_path.exists():
raise RuntimeError("Client was not built. Please run `npm install && npm run build` to build the client")
Expand All @@ -41,7 +44,7 @@ async def index(request):


@app.get("/progress/<key>")
async def index(request, key):
async def progress(request, key):
return response.json({"progress": conversions.get(key, "none")})


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sanic==21.12.1
sanic>=21.12.2
# torch==1.10.2
# torchvision==0.11.3
torch>=2.2.0
Expand Down
4 changes: 1 addition & 3 deletions yolo/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def export_blob(self):
shaves=self.n_shaves,
version="2022.1" if self.use_rvc2 else "2022.3_RVC3",
use_cache=False,
output_dir=self.conv_path.resolve(),
url="https://blobconverter.luxonis.com" if self.use_rvc2 else \
os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com")
output_dir=self.conv_path.resolve()
)

self.f_blob = blob_path
Expand Down
4 changes: 3 additions & 1 deletion yolov6r1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import os
import aiofiles

Sanic.START_METHOD_SET = True
Sanic.start_method = "fork"
Config.KEEP_ALIVE = False
Config.RESPONSE_TIMEOUT = 1000
app = Sanic(__name__)
Expand All @@ -29,7 +31,7 @@


@app.get("/yolov6r1/progress/<key>")
async def index(request, key):
async def progress(request, key):
return response.json({"progress": conversions.get(key, "none")})


Expand Down
2 changes: 1 addition & 1 deletion yolov6r1/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sanic==21.12.1
sanic>=21.12.2
torch>=2.2.0

torchvision>=0.11.3
Expand Down
4 changes: 1 addition & 3 deletions yolov6r1/yolo/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def export_blob(self):
shaves=self.n_shaves,
version="2022.1" if self.use_rvc2 else "2022.3_RVC3",
use_cache=False,
output_dir=self.conv_path.resolve(),
url="https://blobconverter.luxonis.com" if self.use_rvc2 else \
os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com")
output_dir=self.conv_path.resolve()
)
self.f_blob = blob_path

Expand Down
5 changes: 4 additions & 1 deletion yolov6r3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import os
import aiofiles


Sanic.START_METHOD_SET = True
Sanic.start_method = "fork"
Config.KEEP_ALIVE = False
Config.RESPONSE_TIMEOUT = 1000
app = Sanic(__name__)
Expand All @@ -30,7 +33,7 @@


@app.get("/yolov6r3/progress/<key>")
async def index(request, key):
async def progress(request, key):
return response.json({"progress": conversions.get(key, "none")})


Expand Down
2 changes: 1 addition & 1 deletion yolov6r3/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sanic==21.12.1
sanic>=21.12.2
torch>=2.2.0

torchvision>=0.11.3
Expand Down
4 changes: 1 addition & 3 deletions yolov6r3/yolo/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def export_blob(self):
shaves=self.n_shaves,
version="2022.1" if self.use_rvc2 else "2022.3_RVC3",
use_cache=False,
output_dir=self.conv_path.resolve(),
url="https://blobconverter.luxonis.com" if self.use_rvc2 else \
os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com")
output_dir=self.conv_path.resolve()
)
self.f_blob = blob_path

Expand Down
4 changes: 3 additions & 1 deletion yolov7/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import os
import aiofiles

Sanic.START_METHOD_SET = True
Sanic.start_method = "fork"
Config.KEEP_ALIVE = False
Config.RESPONSE_TIMEOUT = 1000
app = Sanic(__name__)
Expand All @@ -29,7 +31,7 @@


@app.get("/yolov7/progress/<key>")
async def index(request, key):
async def progress(request, key):
return response.json({"progress": conversions.get(key, "none")})


Expand Down
2 changes: 1 addition & 1 deletion yolov7/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sanic==21.12.1
sanic>=21.12.2
torch>=2.2.0

torchvision>=0.11.3
Expand Down
4 changes: 1 addition & 3 deletions yolov7/yolo/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ def export_blob(self):
shaves=self.n_shaves,
version="2022.1" if self.use_rvc2 else "2022.3_RVC3",
use_cache=False,
output_dir=self.conv_path.resolve(),
url="https://blobconverter.luxonis.com" if self.use_rvc2 else \
os.getenv("RVC3_BLOBCONVERTER", "https://blobconverter.luxonis.com")
output_dir=self.conv_path.resolve()
)
self.f_blob = blob_path

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# add these requirements in your app on top of the existing ones
pip==18.1
Flask==1.0.2
gunicorn==19.9.0
pip>=23.3
flask>=2.2.5
gunicorn>=22.0.0

0 comments on commit a9d60c8

Please sign in to comment.