Skip to content

Commit

Permalink
Fix seed detector processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChromaticPanic committed Nov 19, 2024
1 parent e6f3fff commit 619a23f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {}
},
// uncomment the next line for LAN model access
// "runArgs": ["--network=host"],

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand All @@ -15,7 +17,7 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r requirements.txt && pip install --upgrade pydantic",
"postCreateCommand": "pip3 install --user -r requirements.txt", // && pip install --upgrade pydantic",

// Configure tool-specific properties.
"customizations": {
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
*.pyc
.vscode/settings.json
output.*

bin/
lib64/
lib64
**/*pyvenv.cfg
share/
lib/
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class MaxContentLengthWarning(APIWarnings):
CACHE = {"seeds": None, "endpoints": None, "pipelines": {}, "validators": []}

cors_settings = {
"allow_origin": [URL_LOCAL] if ENVIRONMENT == "local" else [URL_PROD],
"allow_origin": [URL_PROD, URL_LOCAL],
"allow_methods": ["GET", "POST", "OPTIONS"],
"allow_credentials": True,
"max_age": 86400
Expand Down
2 changes: 2 additions & 0 deletions model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
request_function = {
"swinv1-base-dataaugv2-1": request_inference_from_swin,
"seed-detector-1": request_inference_from_seed_detector,
"swinv1-base-dataaugv2-2": request_inference_from_swin,
"seed-detector-rcnn-1": request_inference_from_seed_detector,
"test": request_inference_from_test,
"m-14of15seeds-6seedsmag": request_inference_from_nachet_6seeds
}
5 changes: 3 additions & 2 deletions model/seed_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ async def request_inference_from_seed_detector(model: namedtuple, previous_resul
}

body = str.encode(json.dumps(data))
req = Request(model.endpoint, body, headers)
req = Request(model.endpoint, body, headers, method="POST")
# req = Request("http://192.168.x.x:12380/score", body, headers, method="POST")
response = urlopen(req)

result = response.read()
result_object = json.loads(result.decode("utf8"))
result_object = [json.loads(result.decode("utf8"))]
print(json.dumps(result_object[0].get("boxes"), indent=4)) #TODO Transform into logging

return {
Expand Down
3 changes: 2 additions & 1 deletion model/swin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ async def request_inference_from_swin(model: namedtuple, previous_result: 'list[
model.deployment_platform: model.name
}
body = img
req = Request(model.endpoint, body, headers)
req = Request(model.endpoint, body, headers, method="POST")
# req = Request("http://192.168.x.x:12390/score", body, headers, method="POST")
response = urlopen(req)
result = response.read()
results.append(json.loads(result.decode("utf8")))
Expand Down
12 changes: 7 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
numpy
nachet-datastore @git+https://github.com/ai-cfia/[email protected]
numpy==1.26.4
azure-storage-blob
azure-identity
quart
flask==3.0.3
quart==0.19.6
quart-cors
python-dotenv
hypercorn
Pillow
Pillow==10.3.0
cryptography
pyyaml
pydantic
pydantic==2.7.1
pydantic-core==2.18.2
python-magic
PyJWT
nachet-datastore @git+https://github.com/ai-cfia/[email protected]

0 comments on commit 619a23f

Please sign in to comment.