2 Commits

Author SHA1 Message Date
3909d0df82 Add yaml format config file
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
2024-03-29 21:47:51 -07:00
d85d0aaf5d Add site config to store
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
2024-03-29 11:45:30 -07:00
92 changed files with 454 additions and 1104 deletions

View File

@@ -1,32 +0,0 @@
name: Build Dev PWA
run-name: ${{ gitea.actor }} is building new dev pwa version
on:
push:
branches:
- main
jobs:
Build-PWA:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install node modules
run: npm install
- name: Build pwa
run: npm run build
- name: Replace previous dev pwa
env:
DEV_HOST: ${{ secrets.DEV_HOST }}
DEV_KEY: ${{ secrets.DEV_KEY }}
DEV_FP: ${{ secrets.DEV_FINGERPRINT }}
run: |
echo "$DEV_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "$DEV_FP" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
ssh root@$DEV_HOST "rm -R /var/www/html/alvinn-dev/*"
echo "Old files removed"
scp -r ${{ gitea.workspace }}/www/* root@$DEV_HOST:/var/www/html/alvinn-dev
ssh root@$DEV_HOST "chown -R www-data:www-data /var/www/html/alvinn-dev/*"
echo "New files copied"

View File

@@ -1,6 +1,6 @@
# ALVINN # ALVINN
Anatomy Lab Visual Identification Neural Net (A.L.V.I.N.N.) is a f7 based app for using a computer vision neural net model to identify anatomical structures in photographic imagery. Anatomy Lab Visual Identification Neural Net (A.L.V.I.N.N) is a f7 based app for using a computer vision neural net model to identify anatomical structures in photographic imagery.
## Install ## Install
* **Android:** Download the latest Android apk in [packages](https://gitea.azgeorgis.net/Georgi_Lab/ALVINN_f7/packages) and open the downloaded file to install. * **Android:** Download the latest Android apk in [packages](https://gitea.azgeorgis.net/Georgi_Lab/ALVINN_f7/packages) and open the downloaded file to install.
@@ -9,26 +9,16 @@ Anatomy Lab Visual Identification Neural Net (A.L.V.I.N.N.) is a f7 based app fo
* **Run from source:** Clone this repository and in the root directory run `npm install` followed by `npm start`. For more information see [f7 info](f7_info.md). * **Run from source:** Clone this repository and in the root directory run `npm install` followed by `npm start`. For more information see [f7 info](f7_info.md).
## Quick Start ## Quick Start
1. Select the region of the body you want to identify structures from. The regions are: 1. From the main screen of the app, select the menu icon in the upper left corner and go to `Settings`.
* Thorax and back 1. Make sure that `Use external server` option is selected and fill in address and port parameters to connect to a back end serving the ALVINN models (Doods2 is the default backend).
* Abdomen and pelvis 1. Save the settings and return to the main screen.
* Limbs 1. Select the region of the body you want to identify structures from.
* Head and neck 1. In the region page, click on the camera icon to take a new picture or load a picture from storage. When the picture load, any identifiable structures will be listed as tags below the image.
1. Load an image in one of the following ways: 1. Click on each tag to see the structure highlighted in the image.
* Click on the camera icon to take a new picture.
* ALVINN will highlight areas with potential structures as you aim the camera.
* Press Capture to use the current camera view.
* Click on the image file icon to load a picture from the device storage.
* If demo mode is turned on, you can click on the marked image icon to load an ALVINN sample image.
1. When the picture is captured or loaded, any identifiable structures will be listed as tags below the image:
* Click on each tag to see the structure highlighted in the image or click on the image to see the tag for that structure (additional clicks to the same area will select overlapping structres).
* Tag color and proportion filled indicate ALVINN's level of confidence in the identification.
* An incorrect tag can be deleted by clicking on the tag's X button.
## Advanced Features ## Advanced Features
### Detection Parameters ### Detection Parameters
If there are potential structures that do not satisfy the current detection settings, a badge on the detection menu icon will indicate the number of un-displayed structures. After an image has been loaded and structure detection has been performed, the detection parameters can be adjusted using the third detection menu button (eye).
Clicking on the detection menu icon will open a menu of tools to adjust the detection settings.
This button will make three tools available: This button will make three tools available:
1. Confidence slider: You can use the slider to change the confidence threshold for identifying structures. 1. Confidence slider: You can use the slider to change the confidence threshold for identifying structures.
The default threshold is 50% confidence. The default threshold is 50% confidence.
@@ -39,34 +29,3 @@ The default threshold is 50% confidence.
If all of the detection tags that are currently visible have been viewed, then the final button (cloud upload) on the detection menu will be enabled. If all of the detection tags that are currently visible have been viewed, then the final button (cloud upload) on the detection menu will be enabled.
This button will cause the image and the verified structures to be uploaded to the ALVINN project servers where that data will be available for further training of the neural net. This button will cause the image and the verified structures to be uploaded to the ALVINN project servers where that data will be available for further training of the neural net.
If after the image has been uploaded, the available detection tags change, then the option to re-upload the image will be available if all the new tags have been viewed and verified. If after the image has been uploaded, the available detection tags change, then the option to re-upload the image will be available if all the new tags have been viewed and verified.
## Configuration
Configuring aspects of the hosted ALVINN PWA is done through the `conf.yaml` file in the `conf` folder.
### Site settings
The following site settings are avaible:
| name | description | values | default |
| --- | --- | --- | --- |
| `agreeExpire` | number of months before users are shown the site agreement dialog again<br />set to 0 to display dialog on every reload | integer >= 0 | 3 |
| `demo` | set to **true** to enable demo mode by default | boolean | false
| `regions` | array of regions names to enable | thorax, abdomen, limbs, head | [thorax, abdomen, limbs, head] |
| `useExternal` | detemines the ability to use an external detection server:<br />**none** - external server cannot be configured<br />**optional** - external server can be configured in the app's settings page<br />**list** - external server can be selected in the app's settings page but only the configured server(s) may be selected<br />**required** - external server settings from conf file will be used by default and disable server options in the settings page | none, optional, list, required | **optional** |
| `external` | properties of the external server(s) ALVINN may connect to<br />This setting must be a single element array if **useExternal** is set to **required**.<br />This setting must be an array of one or more elements if **useExternal** is set to **list** | external server settings array | []|
| `infoUrl` | root url for links to information about identified structures<br />Structure labels with spaces replaced by underscores will be appended to this value for full information links (*e.g.,* Abdominal_diapragm) | string | info link not shown |
### External server settings
ALVINN can use an external object detection server instead of the built in models; settings for that external server are configured here. These settings must be configured if **site - useExternal** is set to **list** or **required**.
| name | description | default |
| --- | --- | --- |
| `name` | identifier for external server | *none* |
| `address` | ip or url of external server | *none* |
| `port` | port to access on external server | 9001 |
The external server's response must be json with a `detections` key that contains an array of the detected structure labels, bounding box data, and confidence values.
```
{
"detections": [
{"top": 0.1, "left": 0.1, "bottom": 0.9, "right": 0.9, "label": "Aorta", "confidence": 90.0 }
...
],
}
```

View File

@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget id="edu.midwestern.alvinn" version="0.5.0-alpha" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android"> <widget id="edu.midwestern.alvinn" version="0.5.0-rc" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>ALVINN</name> <name>ALVINN</name>
<description>Anatomy Lab Visual Identification Neural Network.</description> <description>Anatomy Lab Visual Identification Neural Network.</description>
<author email="jgeorg@midwestern.edu" href="https://midwestern.edu"> <author email="jgeorg@midwestern.edu" href="https://midwestern.edu">

View File

@@ -1,7 +1,7 @@
{ {
"name": "edu.midwestern.alvinn", "name": "edu.midwestern.alvinn",
"displayName": "ALVINN", "displayName": "ALVINN",
"version": "0.5.0-alpha", "version": "0.5.0-rc",
"description": "Anatomy Lab Visual Identification Neural Network.", "description": "Anatomy Lab Visual Identification Neural Network.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@@ -1,7 +1,7 @@
{ {
"name": "alvinn", "name": "alvinn",
"private": true, "private": true,
"version": "0.5.0-alpha", "version": "0.5.0-rc",
"description": "ALVINN", "description": "ALVINN",
"repository": "", "repository": "",
"license": "UNLICENSED", "license": "UNLICENSED",
@@ -14,8 +14,7 @@
"cordova-ios": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && node ./build/build-cordova.js && cd cordova && cordova run ios", "cordova-ios": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && node ./build/build-cordova.js && cd cordova && cordova run ios",
"build-cordova-android": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && node ./build/build-cordova.js && cd cordova && cordova build android", "build-cordova-android": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && node ./build/build-cordova.js && cd cordova && cordova build android",
"cordova-android": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && node ./build/build-cordova.js && cd cordova && cordova run android", "cordova-android": "cross-env TARGET=cordova cross-env NODE_ENV=production vite build && node ./build/build-cordova.js && cd cordova && cordova run android",
"postinstall": "cpy --flat ./node_modules/framework7-icons/fonts/*.* ./src/fonts/", "postinstall": "cpy --flat ./node_modules/framework7-icons/fonts/*.* ./src/fonts/"
"preview": "vite preview"
}, },
"browserslist": [ "browserslist": [
"IOS >= 15", "IOS >= 15",

View File

@@ -1,16 +1,9 @@
demo: true site:
agreeExpire: 3 demo: true
regions: regions:
- thorax - thorax
- abdomen - abdomen
- limbs - limbs
- head
useExternal: none
external: external:
- name: Mserver address: "10.188.0.98"
address: "192.169.1.105" port: 9001
port: 9001
- name: Georgi lab server
address: "10.188.0.98"
port: 9001
infoUrl: http://anatlabwiki.midwestern.edu/vetlab/index.php/

View File

@@ -1,10 +1,11 @@
{ {
"version": "0.1.0-n4", "version": "0.0.0-n1",
"region": "Thorax", "region": "Coco",
"size": 640, "size": 640,
"epochs": 1000, "epochs": 1000,
"name": "nano4", "name": "coco128 test",
"yolo-version": "8.1.20 docker", "yolo-version": "8.1.20 docker",
"date": "2024-03-08", "date": "2024-03-12",
"export": "0.1.0-th" "export": "coco128.yaml"
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
description: Ultralytics best model trained on /data/ALVINN/Thorax/Thorax 0.1.0/thorax.yaml description: Ultralytics best model trained on /usr/src/ultralytics/ultralytics/cfg/datasets/coco128.yaml
author: Ultralytics author: Ultralytics
license: AGPL-3.0 https://ultralytics.com/license license: AGPL-3.0 https://ultralytics.com/license
date: '2024-03-08T20:14:34.118186' date: '2024-03-12T16:25:00.089873'
version: 8.1.20 version: 8.1.20
stride: 32 stride: 32
task: detect task: detect
@@ -10,44 +10,83 @@ imgsz:
- 640 - 640
- 640 - 640
names: names:
0: Abdominal diaphragm 0: person
1: Aorta 1: bicycle
2: Azygous vein 2: car
3: Brachiocephalic trunk 3: motorcycle
4: Caudal vena cava 4: airplane
5: Cranial vena cava 5: bus
6: Esophagus 6: train
7: External abdominal oblique 7: truck
8: Iliocostalis 8: boat
9: Latissimus dorsi 9: traffic light
10: Left atrium 10: fire hydrant
11: Left auricle 11: stop sign
12: Left lung 12: parking meter
13: Left subclavian artery 13: bench
14: Left ventricle 14: bird
15: Longissimus 15: cat
16: Pectoralis profundus 16: dog
17: Pectoralis superficialis 17: horse
18: Pericardium 18: sheep
19: Phrenic nerve 19: cow
20: Primary bronchus 20: elephant
21: Pulmonary artery 21: bear
22: Pulmonary trunk 22: zebra
23: Pulmonary vein 23: giraffe
24: Rectus abdominis 24: backpack
25: Rectus thoracis 25: umbrella
26: Recurrent laryngeal nerve 26: handbag
27: Rhomboideus 27: tie
28: Right atrium 28: suitcase
29: Right auricle 29: frisbee
30: Right lung 30: skis
31: Right ventricle 31: snowboard
32: Scalenus 32: sports ball
33: Serratus dorsalis caudalis 33: kite
34: Serratus dorsalis cranialis 34: baseball bat
35: Serratus ventralis 35: baseball glove
36: Spinalis 36: skateboard
37: Sympathetic chain 37: surfboard
38: Trachea 38: tennis racket
39: Trapezius 39: bottle
40: Vagus nerve 40: wine glass
41: cup
42: fork
43: knife
44: spoon
45: bowl
46: banana
47: apple
48: sandwich
49: orange
50: broccoli
51: carrot
52: hot dog
53: pizza
54: donut
55: cake
56: chair
57: couch
58: potted plant
59: bed
60: dining table
61: toilet
62: tv
63: laptop
64: mouse
65: remote
66: keyboard
67: cell phone
68: microwave
69: oven
70: toaster
71: sink
72: refrigerator
73: book
74: clock
75: vase
76: scissors
77: teddy bear
78: hair drier
79: toothbrush

File diff suppressed because one or more lines are too long

View File

@@ -1,43 +1,82 @@
[ [
"Abdominal diaphragm", "person",
"Aorta", "bicycle",
"Azygous vein", "car",
"Brachiocephalic trunk", "motorcycle",
"Caudal vena cava", "airplane",
"Cranial vena cava", "bus",
"Esophagus", "train",
"External abdominal oblique", "truck",
"Iliocostalis", "boat",
"Latissimus dorsi", "traffic light",
"Left atrium", "fire hydrant",
"Left auricle", "stop sign",
"Left lung", "parking meter",
"Left subclavian artery", "bench",
"Left ventricle", "bird",
"Longissimus", "cat",
"Pectoralis profundus", "dog",
"Pectoralis superficialis", "horse",
"Pericardium", "sheep",
"Phrenic nerve", "cow",
"Primary bronchus", "elephant",
"Pulmonary artery", "bear",
"Pulmonary trunk", "zebra",
"Pulmonary vein", "giraffe",
"Rectus abdominis", "backpack",
"Rectus thoracis", "umbrella",
"Recurrent laryngeal nerve", "handbag",
"Rhomboideus", "tie",
"Right atrium", "suitcase",
"Right auricle", "frisbee",
"Right lung", "skis",
"Right ventricle", "snowboard",
"Scalenus", "sports ball",
"Serratus dorsalis caudalis", "kite",
"Serratus dorsalis cranialis", "baseball bat",
"Serratus ventralis", "baseball glove",
"Spinalis", "skateboard",
"Sympathetic chain", "surfboard",
"Trachea", "tennis racket",
"Trapezius", "bottle",
"Vagus nerve" "wine glass",
"cup",
"fork",
"knife",
"spoon",
"bowl",
"banana",
"apple",
"sandwich",
"orange",
"broccoli",
"carrot",
"hot dog",
"pizza",
"donut",
"cake",
"chair",
"couch",
"potted plant",
"bed",
"dining table",
"toilet",
"tv",
"laptop",
"mouse",
"remote",
"keyboard",
"cell phone",
"microwave",
"oven",
"toaster",
"sink",
"refrigerator",
"book",
"clock",
"vase",
"scissors",
"teddy bear",
"hair drier",
"toothbrush"
] ]

View File

@@ -1,10 +1,11 @@
{ {
"version": "0.1.0-n4", "version": "0.0.0-n1",
"region": "Thorax", "region": "Coco",
"size": 640, "size": 640,
"epochs": 1000, "epochs": 1000,
"name": "nano4", "name": "coco128 test",
"yolo-version": "8.1.20 docker", "yolo-version": "8.1.20 docker",
"date": "2024-03-08", "date": "2024-03-12",
"export": "0.1.0-th" "export": "coco128.yaml"
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
description: Ultralytics best model trained on /data/ALVINN/Thorax/Thorax 0.1.0/thorax.yaml description: Ultralytics best model trained on /usr/src/ultralytics/ultralytics/cfg/datasets/coco128.yaml
author: Ultralytics author: Ultralytics
license: AGPL-3.0 https://ultralytics.com/license license: AGPL-3.0 https://ultralytics.com/license
date: '2024-03-08T20:14:34.118186' date: '2024-03-12T16:25:00.089873'
version: 8.1.20 version: 8.1.20
stride: 32 stride: 32
task: detect task: detect
@@ -10,44 +10,83 @@ imgsz:
- 640 - 640
- 640 - 640
names: names:
0: Abdominal diaphragm 0: person
1: Aorta 1: bicycle
2: Azygous vein 2: car
3: Brachiocephalic trunk 3: motorcycle
4: Caudal vena cava 4: airplane
5: Cranial vena cava 5: bus
6: Esophagus 6: train
7: External abdominal oblique 7: truck
8: Iliocostalis 8: boat
9: Latissimus dorsi 9: traffic light
10: Left atrium 10: fire hydrant
11: Left auricle 11: stop sign
12: Left lung 12: parking meter
13: Left subclavian artery 13: bench
14: Left ventricle 14: bird
15: Longissimus 15: cat
16: Pectoralis profundus 16: dog
17: Pectoralis superficialis 17: horse
18: Pericardium 18: sheep
19: Phrenic nerve 19: cow
20: Primary bronchus 20: elephant
21: Pulmonary artery 21: bear
22: Pulmonary trunk 22: zebra
23: Pulmonary vein 23: giraffe
24: Rectus abdominis 24: backpack
25: Rectus thoracis 25: umbrella
26: Recurrent laryngeal nerve 26: handbag
27: Rhomboideus 27: tie
28: Right atrium 28: suitcase
29: Right auricle 29: frisbee
30: Right lung 30: skis
31: Right ventricle 31: snowboard
32: Scalenus 32: sports ball
33: Serratus dorsalis caudalis 33: kite
34: Serratus dorsalis cranialis 34: baseball bat
35: Serratus ventralis 35: baseball glove
36: Spinalis 36: skateboard
37: Sympathetic chain 37: surfboard
38: Trachea 38: tennis racket
39: Trapezius 39: bottle
40: Vagus nerve 40: wine glass
41: cup
42: fork
43: knife
44: spoon
45: bowl
46: banana
47: apple
48: sandwich
49: orange
50: broccoli
51: carrot
52: hot dog
53: pizza
54: donut
55: cake
56: chair
57: couch
58: potted plant
59: bed
60: dining table
61: toilet
62: tv
63: laptop
64: mouse
65: remote
66: keyboard
67: cell phone
68: microwave
69: oven
70: toaster
71: sink
72: refrigerator
73: book
74: clock
75: vase
76: scissors
77: teddy bear
78: hair drier
79: toothbrush

File diff suppressed because one or more lines are too long

View File

@@ -1,10 +0,0 @@
{
"version": "0.1.0-n4",
"region": "Thorax",
"size": 640,
"epochs": 1000,
"name": "nano4",
"yolo-version": "8.1.20 docker",
"date": "2024-03-08",
"export": "0.1.0-th"
}

View File

@@ -1,53 +0,0 @@
description: Ultralytics best model trained on /data/ALVINN/Thorax/Thorax 0.1.0/thorax.yaml
author: Ultralytics
license: AGPL-3.0 https://ultralytics.com/license
date: '2024-03-08T20:14:34.118186'
version: 8.1.20
stride: 32
task: detect
batch: 1
imgsz:
- 640
- 640
names:
0: Abdominal diaphragm
1: Aorta
2: Azygous vein
3: Brachiocephalic trunk
4: Caudal vena cava
5: Cranial vena cava
6: Esophagus
7: External abdominal oblique
8: Iliocostalis
9: Latissimus dorsi
10: Left atrium
11: Left auricle
12: Left lung
13: Left subclavian artery
14: Left ventricle
15: Longissimus
16: Pectoralis profundus
17: Pectoralis superficialis
18: Pericardium
19: Phrenic nerve
20: Primary bronchus
21: Pulmonary artery
22: Pulmonary trunk
23: Pulmonary vein
24: Rectus abdominis
25: Rectus thoracis
26: Recurrent laryngeal nerve
27: Rhomboideus
28: Right atrium
29: Right auricle
30: Right lung
31: Right ventricle
32: Scalenus
33: Serratus dorsalis caudalis
34: Serratus dorsalis cranialis
35: Serratus ventralis
36: Spinalis
37: Sympathetic chain
38: Trachea
39: Trapezius
40: Vagus nerve

File diff suppressed because one or more lines are too long

View File

@@ -1,43 +0,0 @@
[
"Abdominal diaphragm",
"Aorta",
"Azygous vein",
"Brachiocephalic trunk",
"Caudal vena cava",
"Cranial vena cava",
"Esophagus",
"External abdominal oblique",
"Iliocostalis",
"Latissimus dorsi",
"Left atrium",
"Left auricle",
"Left lung",
"Left subclavian artery",
"Left ventricle",
"Longissimus",
"Pectoralis profundus",
"Pectoralis superficialis",
"Pericardium",
"Phrenic nerve",
"Primary bronchus",
"Pulmonary artery",
"Pulmonary trunk",
"Pulmonary vein",
"Rectus abdominis",
"Rectus thoracis",
"Recurrent laryngeal nerve",
"Rhomboideus",
"Right atrium",
"Right auricle",
"Right lung",
"Right ventricle",
"Scalenus",
"Serratus dorsalis caudalis",
"Serratus dorsalis cranialis",
"Serratus ventralis",
"Spinalis",
"Sympathetic chain",
"Trachea",
"Trapezius",
"Vagus nerve"
]

View File

@@ -1,12 +0,0 @@
{
"version": "0.3.1-s1",
"region": "Thorax",
"size": 960,
"epochs": 2000,
"epochsFinal:": 1656,
"name": "small1",
"yolo-version": "8.2.16 docker",
"date": "2024-06-05",
"export": "0.3.0-th",
"grayscale": true
}

View File

@@ -1,53 +0,0 @@
description: Ultralytics best model trained on /data/ALVINN/Thorax/Thorax 0.3.0/thorax_g.yaml
author: Ultralytics
license: AGPL-3.0 https://ultralytics.com/license
date: '2024-06-05T22:55:38.088791'
version: 8.1.20
stride: 32
task: detect
batch: 1
imgsz:
- 960
- 960
names:
0: Abdominal diaphragm
1: Aorta
2: Azygous vein
3: Brachiocephalic trunk
4: Caudal vena cava
5: Cranial vena cava
6: Esophagus
7: External abdominal oblique
8: Iliocostalis
9: Latissimus dorsi
10: Left atrium
11: Left auricle
12: Left lung
13: Left subclavian artery
14: Left ventricle
15: Longissimus
16: Pectoralis profundus
17: Pectoralis superficialis
18: Pericardium
19: Phrenic nerve
20: Primary bronchus
21: Pulmonary artery
22: Pulmonary trunk
23: Pulmonary vein
24: Rectus abdominis
25: Rectus thoracis
26: Recurrent laryngeal nerve
27: Rhomboideus
28: Right atrium
29: Right auricle
30: Right lung
31: Right ventricle
32: Scalenus
33: Serratus dorsalis caudalis
34: Serratus dorsalis cranialis
35: Serratus ventralis
36: Spinalis
37: Sympathetic chain
38: Trachea
39: Trapezius
40: Vagus nerve

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,10 @@
{ {
"version": "0.2.1-n3", "version": "0.1.0-n4",
"region": "Thorax", "region": "Thorax",
"size": 640, "size": 640,
"epochs": 1500, "epochs": 1000,
"name": "nano3", "name": "nano4",
"yolo-version": "8.2.16 docker", "yolo-version": "8.1.20 docker",
"date": "2024-06-17", "date": "2024-03-08",
"export": "0.2.1-th", "export": "0.1.0-th"
"grayscale": true,
"background": 35
} }

View File

@@ -1,9 +1,8 @@
description: Ultralytics best model trained on /data/ALVINN/Thorax 0.2.1/thorax_g.yaml description: Ultralytics best model trained on /data/ALVINN/Thorax/Thorax 0.1.0/thorax.yaml
author: Ultralytics author: Ultralytics
date: '2024-06-17T22:40:05.967309' license: AGPL-3.0 https://ultralytics.com/license
version: 8.2.16 date: '2024-03-08T20:14:34.118186'
license: AGPL-3.0 License (https://ultralytics.com/license) version: 8.1.20
docs: https://docs.ultralytics.com
stride: 32 stride: 32
task: detect task: detect
batch: 1 batch: 1

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,10 @@
{ {
"version": "0.2.1-s1", "version": "0.1.0-s1",
"region": "Thorax", "region": "Thorax",
"size": 1080, "size": 640,
"epochs": 1399, "epochs": 1000,
"name": "small1", "name": "small1",
"yolo-version": "8.2.16 docker", "yolo-version": "8.1.20 docker",
"date": "2024-06-18", "date": "2024-03-07",
"export": "0.2.1-th", "export": "0.1.0-th"
"grayscale": true,
"background": 35
} }

View File

@@ -1,15 +1,14 @@
description: Ultralytics best model trained on /data/ALVINN/Thorax 0.2.1/thorax_g.yaml description: Ultralytics best model trained on /data/ALVINN/Thorax/Thorax 0.1.0/thorax.yaml
author: Ultralytics author: Ultralytics
date: '2024-06-18T23:10:47.568324' license: AGPL-3.0 https://ultralytics.com/license
version: 8.2.16 date: '2024-03-07T16:03:03.296997'
license: AGPL-3.0 License (https://ultralytics.com/license) version: 8.1.20
docs: https://docs.ultralytics.com
stride: 32 stride: 32
task: detect task: detect
batch: 1 batch: 1
imgsz: imgsz:
- 1088 - 640
- 1088 - 640
names: names:
0: Abdominal diaphragm 0: Abdominal diaphragm
1: Aorta 1: Aorta

File diff suppressed because one or more lines are too long

View File

@@ -1,176 +0,0 @@
import * as tf from '@tensorflow/tfjs'
let model = null
onmessage = function (e) {
switch (e.data.call) {
case 'loadModel':
loadModel(e.data.weights,e.data.preload).then(() => {
postMessage({success: 'model'})
}).catch((err) => {
postMessage({error: true, message: err.message})
})
break
case 'localDetect':
localDetect(e.data.image).then((dets) => {
postMessage({success: 'detection', detections: dets})
}).catch((err) => {
//throw (err)
postMessage({error: true, message: err.message})
})
e.data.image.close()
break
case 'videoFrame':
videoFrame(e.data.image).then((frameDet) =>{
postMessage({succes: 'frame', coords: frameDet.cds, modelWidth: frameDet.mW, modelHeight: frameDet.mH})
}).catch((err) => {
postMessage({error: true, message: err.message})
})
e.data.image.close()
break
default:
console.log('Worker message incoming:')
console.log(e)
postMessage({result1: 'First result', result2: 'Second result'})
break
}
}
async function loadModel(weights, preload) {
if (model && model.modelURL == weights) {
return model
} else if (model) {
tf.dispose(model)
}
model = await tf.loadGraphModel(weights)
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3)
/*****************
* If preloading then run model
* once on fake data to preload
* weights for a faster response
*****************/
if (preload) {
const dummyT = tf.ones([1,modelWidth,modelHeight,3])
model.predict(dummyT)
}
return model
}
async function localDetect(imageData) {
console.time('sw: pre-process')
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3)
let gTense = null
const input = tf.tidy(() => {
gTense = tf.image.rgbToGrayscale(tf.image.resizeBilinear(tf.browser.fromPixels(imageData), [modelWidth, modelHeight])).div(255.0).expandDims(0)
return tf.concat([gTense,gTense,gTense],3)
})
tf.dispose(gTense)
console.timeEnd('sw: pre-process')
console.time('sw: run prediction')
const res = model.predict(input)
const tRes = tf.transpose(res,[0,2,1])
const rawRes = tRes.arraySync()[0]
console.timeEnd('sw: run prediction')
console.time('sw: post-process')
const outputSize = res.shape[1]
let rawBoxes = []
let rawScores = []
for (var i = 0; i < rawRes.length; i++) {
var getScores = rawRes[i].slice(4)
if (getScores.every( s => s < .05)) { continue }
var getBox = rawRes[i].slice(0,4)
var boxCalc = [
(getBox[0] - (getBox[2] / 2)) / modelWidth,
(getBox[1] - (getBox[3] / 2)) / modelHeight,
(getBox[0] + (getBox[2] / 2)) / modelWidth,
(getBox[1] + (getBox[3] / 2)) / modelHeight,
]
rawBoxes.push(boxCalc)
rawScores.push(getScores)
}
if (rawBoxes.length > 0) {
const tBoxes = tf.tensor2d(rawBoxes)
let tScores = null
let resBoxes = null
let validBoxes = []
let structureScores = null
let boxes_data = []
let scores_data = []
let classes_data = []
for (var c = 0; c < outputSize - 4; c++) {
structureScores = rawScores.map(x => x[c])
tScores = tf.tensor1d(structureScores)
resBoxes = await tf.image.nonMaxSuppressionAsync(tBoxes,tScores,10,0.5,.05)
validBoxes = resBoxes.dataSync()
tf.dispose(resBoxes)
if (validBoxes) {
boxes_data.push(...rawBoxes.filter( (_, idx) => validBoxes.includes(idx)))
var outputScores = structureScores.filter( (_, idx) => validBoxes.includes(idx))
scores_data.push(...outputScores)
classes_data.push(...outputScores.fill(c))
}
}
validBoxes = []
tf.dispose(tBoxes)
tf.dispose(tScores)
tf.dispose(tRes)
const valid_detections_data = classes_data.length
var output = {
detections: []
}
for (var i =0; i < valid_detections_data; i++) {
var [dLeft, dTop, dRight, dBottom] = boxes_data[i]
output.detections.push({
"top": dTop,
"left": dLeft,
"bottom": dBottom,
"right": dRight,
// "label": this.detectorLabels[classes_data[i]].name,
"label": classes_data[i],
"confidence": scores_data[i] * 100
})
}
}
tf.dispose(res)
tf.dispose(input)
console.timeEnd('sw: post-process')
return output || { detections: [] }
}
async function videoFrame (vidData) {
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3)
console.time('sw: frame-process')
let rawCoords = []
try {
const input = tf.tidy(() => {
return tf.image.resizeBilinear(tf.browser.fromPixels(vidData), [modelWidth, modelHeight]).div(255.0).expandDims(0)
})
const res = model.predict(input)
const rawRes = tf.transpose(res,[0,2,1]).arraySync()[0]
if (rawRes) {
for (var i = 0; i < rawRes.length; i++) {
let getScores = rawRes[i].slice(4)
if (getScores.some( s => s > .5)) {
let foundTarget = rawRes[i].slice(0,2)
foundTarget.push(Math.max(...getScores))
rawCoords.push(foundTarget)
}
}
}
tf.dispose(input)
tf.dispose(res)
tf.dispose(rawRes)
} catch (e) {
console.log(e)
}
console.timeEnd('sw: frame-process')
return {cds: rawCoords, mW: modelWidth, mH: modelHeight}
}

View File

@@ -33,7 +33,7 @@
ALVINN is for educational purposes only. It may not be used for medical diagnosis, intervention, or treatment. ALVINN is for educational purposes only. It may not be used for medical diagnosis, intervention, or treatment.
</h3> </h3>
<div style="display: flex; justify-content: space-around; flex-direction: row; align-items: center;"> <div style="display: flex; justify-content: space-around; flex-direction: row; align-items: center;">
<span v-if="!siteConf || !siteConf.agreeExpire == 0" style="height: min-content;"> <span style="height: min-content;">
<f7-checkbox v-model:checked="rememberAgreement"/> Don't show again <f7-checkbox v-model:checked="rememberAgreement"/> Don't show again
</span> </span>
<f7-button text="I agree" fill @click="setAgreement" /> <f7-button text="I agree" fill @click="setAgreement" />
@@ -68,53 +68,34 @@
rememberAgreement: false, rememberAgreement: false,
siteAgreement: false, siteAgreement: false,
dateAgreement: null, dateAgreement: null,
showDisclaimer: false, showDisclaimer: true,
alvinnVersion: store().getVersion, alvinnVersion: store().getVersion,
siteConf: {} siteConf: {}
} }
}, },
async created () { created () {
if (!window.cordova) { fetch(`${!!window.cordova ? 'https://localhost' : '.'}/conf/conf.yaml`)
const confText = await fetch('./conf/conf.yaml') .then((mod) => { return mod.text() })
.then((mod) => { return mod.text() }) .then((confText) => {
this.siteConf = YAML.parse(confText) this.siteConf = YAML.parse(confText)
} console.log(this.siteConf)
if (window.safari !== undefined) {store().safariDetected()} })
const loadSiteSettings = localStorage.getItem('siteSettings') var loadSiteSettings = localStorage.getItem('siteSettings')
if (loadSiteSettings) { if (loadSiteSettings) {
let loadedSettings = JSON.parse(loadSiteSettings) var loadedSettings = JSON.parse(loadSiteSettings)
this.siteAgreement = loadedSettings.siteAgreement this.siteAgreement = loadedSettings.siteAgreement
this.rememberAgreement = loadedSettings.rememberAgreement this.rememberAgreement = loadedSettings.rememberAgreement
this.dateAgreement = loadedSettings.dateAgreement && new Date(loadedSettings.dateAgreement) this.dateAgreement = loadedSettings.dateAgreement && new Date(loadedSettings.dateAgreement)
} }
const curDate = new Date () var curDate = new Date ()
const expireMonth = (this.dateAgreement?.getMonth() || 0) + (this.siteConf?.agreeExpire || 3) var agreeStillValid = this.dateAgreement && (curDate < this.dateAgreement.setMonth(this.dateAgreement.getMonth() + 3))
const agreeStillValid = this.dateAgreement && (curDate < this.dateAgreement.setMonth(expireMonth)) if (this.siteAgreement && this.rememberAgreement && agreeStillValid) {
if (this.siteAgreement && this.rememberAgreement && agreeStillValid && !this.siteConf?.agreeExpire == 0) { this.showDisclaimer = false
store().agree() store().agree()
} else {
this.showDisclaimer = true
} }
store().set('enabledRegions',this.siteConf?.regions) var loadServerSettings = localStorage.getItem('serverSettings')
store().set('siteDemo',this.siteConf?.demo) if (!loadServerSettings) {
store().set('infoUrl',this.siteConf?.infoUrl)
const loadServerSettings = localStorage.getItem('serverSettings')
if (this.siteConf?.useExternal) {
if (!['none','list','optional','required'].includes(this.siteConf.useExternal)) {
console.warn(`'${this.siteConf.useExternal}' is not a valid value for useExternal configuration: using 'optional'`)
} else {
store().set('useExternal',this.siteConf.useExternal)
if (this.siteConf.external) {
store().set('externalServerList',this.siteConf.external)
}
}
}
if (this.siteConf.useExternal == 'none') {
localStorage.setItem('serverSettings','{"use":false}')
} else if (!loadServerSettings && !this.siteConf.external) {
localStorage.setItem('serverSettings','{"use":false,"address":"10.188.0.98","port":"9001","previous":{"10.188.0.98":"9001"}}') localStorage.setItem('serverSettings','{"use":false,"address":"10.188.0.98","port":"9001","previous":{"10.188.0.98":"9001"}}')
} else if (this.siteConf.useExternal == 'required') {
localStorage.setItem('serverSettings',`{"use":true,"address":"${this.siteConf.external[0].address}","port":${this.siteConf.external[0].port}}`)
} }
}, },
methods: { methods: {
@@ -141,7 +122,7 @@
this.showDisclaimer = false this.showDisclaimer = false
}, },
() => { () => {
const toast = f7.toast.create({ var toast = f7.toast.create({
text: 'ERROR: No settings saved', text: 'ERROR: No settings saved',
closeTimeout: 2000 closeTimeout: 2000
}) })
@@ -153,11 +134,13 @@
setup() { setup() {
const device = getDevice(); const device = getDevice();
// Framework7 Parameters // Framework7 Parameters
const loadThemeSettings = localStorage.getItem('themeSettings') var loadThemeSettings = localStorage.getItem('themeSettings')
let themeSettings = {} if (loadThemeSettings) var themeSettings = JSON.parse(loadThemeSettings)
let darkTheme = 'auto' try {
if (loadThemeSettings) { themeSettings = JSON.parse(loadThemeSettings) } if (themeSettings.darkMode.toString()) var darkTheme = themeSettings.darkMode
if (themeSettings?.darkMode) darkTheme = themeSettings.darkMode } catch {
var darkTheme = 'auto'
}
const f7params = { const f7params = {
name: 'ALVINN', // App name name: 'ALVINN', // App name
theme: 'auto', // Automatic theme detection theme: 'auto', // Automatic theme detection

View File

@@ -1,25 +1,14 @@
<template> <template>
<svg width="100%" height="100%" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <svg width="100%" height="100%" version="1.1" viewBox="0 0 26.458333 26.458333" xmlns="http://www.w3.org/2000/svg">
<g v-if="iconSet == 1" stroke="none" :fill="fillColor" > <g stroke="none" :fill="fillColor" >
<path d="M22,8.25 20.75,7.5 20.25,6.5 19,6 V5 L18.25,6 16,7.75 13.5,8.75 H8.5 L7,9 6,9.75 5,11 L4.25,12.5 3.5,14 2.5,15 2,15.5 2.5,15.75 3.5,15.5 4.5,14.25 5.5,12.25 6.75,10.75 7,12 7.25,13.25 6.5,15.5 7,19 H8 V 18.5 L7.5,18.25 7.75,15.75 9.75,12.25 12,13 15.25,13.5 15.5,17.25 16,19 H17 V18.5 L16.5,18.25 V15.5 L17,13 17.75,10.75 19,8.75 H20 L21.25,9 Z" style="opacity: .4;"/> <path d="m25.402178 7.8631343c-0.487907-0.3670601-0.811572-0.7261214-1.573424-1.106523-0.006122-0.1598737 0.053853-0.2411643-0.072374-0.5438299-0.239221-0.3572156-1.352454-0.987126-2.19723-0.8590224-1.567124 0.9252583-1.879175 1.9380345-3.311246 2.9148849-0.987966 0.103956-2.015535 0.3206455-3.091153 0.6741123-10.556415-1.8721062-8.2481554 5.9196998-14.460584 1.7189868 0 0-0.24989902 0.06545-0.28777276 0.170279-0.0360567 0.0998 0.10708587 0.299783 0.10708587 0.299783 2.0948939 1.933517 4.742145 1.74421 6.6624536-0.07316 0.096935 0.768305 0.3887649 1.92789 0.8180324 3.363404-0.035692 1.245357-1.2923422 2.350278-1.3169003 2.801484-0.013354 0.24535 0.5120291 3.6149 0.7015429 3.650219l0.7793046 0.145235c0.8989154 0.167526 0.7195768-0.420583 0.3224789-0.780361-0.2085791-0.188976-0.3404558-0.252396-0.3637846-0.441707-0.3810495-3.092169 2.1284358-4.423261 2.4023638-6.742929 2.453391 0.120243 3.974486 1.282365 6.721539 1.403033 0.136906 1.035362-0.177341 4.099457-0.120257 4.484465 0.04824 0.325337 0.511082 0.918401 0.497537 1.876854-3e-3 0.211416 0.410117 0.159484 0.619918 0.185743 0.799059 0.09999 1.033405-0.329373 0.42557-0.75884-0.132327-0.0935-0.456134-0.264276-0.476806-0.424973-0.251045-1.951541 1.103782-4.917365 1.103782-4.917365 0.355435-0.554509 0.707693-1.135262 1.002776-2.188396 0.160636-0.543413 0.157772-1.012576 0.119972-1.465872 1.541867-1.5721797 1.123352-2.3466703 2.548492-2.7336036 0.65786 0.059985 1.147615 0.1738285 1.444935 0.3493259 0.420933-0.188852 0.760222-0.5096057 0.993749-1.001227z" style="opacity: .25;"/>
<path v-if="region == 0" d="M16,7.75 13.5,8.75 12,13 15.25,13.5 17,13 17.75,10.75 Z" fill-rule="evenodd" :fill="fillColor" /> <path v-if="region == 0" d="m 18.247904,8.2686439 c -0.987966,0.103956 -3.091153,0.6741123 -3.091153,0.6741123 -1.652395,2.7995828 -2.226698,3.8098238 -2.580037,4.4476078 0,0 2.617397,0.984666 4.665796,1.066659 -0.003,0.01385 2.049744,0.445884 2.049744,0.445884 0,0 0.707693,-1.135262 1.002776,-2.188396 0.160636,-0.543413 0.157772,-1.012576 0.119972,-1.465872 -0.291029,-0.377705 -1.38593,-1.9038754 -2.167098,-2.9799951 z" fill-rule="evenodd" :fill="fillColor" />
<path v-else-if="region ==1" d="M13.5,8.75 H8.5 L7,9 6,9.75 5,11 4.25,12.5 3.5,14 2.5,15 2,15.5 2.5,15.75 3.5,15.5 4.5,14.25 5.5,12.25 6.75,10.75 7,12 9.75,12.25 12,13 Z" :fill="fillColor" fill-rule="evenodd"/> <path v-else-if="region ==1" d="m15.156751 8.9427562c-10.556415-1.8721062-8.2481554 5.9196998-14.460584 1.7189868 0 0-0.24989902 0.06545-0.28777276 0.170279-0.0360567 0.0998 0.10708587 0.299783 0.10708587 0.299783 2.0948939 1.933517 4.742145 1.74421 6.6624536-0.07316 0.048468 0.384152 0.1456587 0.866125 0.2843915 1.431499 0.7210773 0.130029 2.5390772 0.501293 3.0586462 0.563846 0.613348 0.03006 1.528237 0.20676 2.05877 0.334503 0.563462-1.044613 0.536275-0.982536 2.57701-4.4457368z" :fill="fillColor" fill-rule="evenodd"/>
<path v-else-if="region == 2" d="M15,8.5 C14,8.5 13.25,9.25 13.25,10.25 C13.25,10.75 13.5,11.25 13.75,11.5 L15.25,13.5 15.5,17.25 16,19 H17 V18.5 L16.5,18.25 V15.5 L17,13 17.75,10.75 16.25,9 C16,8.75 15.5,8.5 15,8.5 Z M8.5,9 C7.5,9 6.75,9.75 6.75,10.75 L7,12 7.25,13.25 6.5,15.5 7,19 H8 V18.5 L7.5,18.25 7.75,15.75 9.75,12.25 10.25,10.75 C10.25,9.75 9.5,9 8.5,9 Z" :fill="fillColor" fill-rule="evenodd"/> <g v-else-if="region == 2" :fill="fillColor" fill-rule="evenodd">
<path v-else-if="region == 3" d="M22,8.25 20.75,7.5 20.25,6.5 19,6 V5 L18.25,6 16,7.75 17.75,10.75 19,8.75 H20 L21.25,9 Z" :fill="fillColor" fill-rule="evenodd"/> <path d="m17.24251 14.457023c0.136906 1.035362-0.177341 4.099457-0.120257 4.484465 0.04824 0.325337 0.511082 0.918401 0.497537 1.876854-3e-3 0.211416 0.410117 0.159484 0.619918 0.185743 0.799059 0.09999 1.033405-0.329373 0.42557-0.75884-0.132327-0.0935-0.456134-0.264276-0.476806-0.424973-0.251045-1.951541 1.103782-4.917365 1.103782-4.917365 0.355435-0.554509 0.707693-1.135262 1.002776-2.188396 0.160636-0.543413 0.157772-1.012576 0.119972-1.465872-3.100189-4.8581326-4.866767-0.394712-3.172492 3.208384z" />
</g> <path d="m7.1779333 11.058645c0.096935 0.768305 0.3887649 1.92789 0.8180324 3.363404-0.035692 1.245357-1.2923422 2.350278-1.3169003 2.801484-0.013354 0.24535 0.5120291 3.6149 0.7015429 3.650219l0.7793046 0.145235c0.8989154 0.167526 0.7195768-0.420583 0.3224789-0.780361-0.2085791-0.188976-0.3404558-0.252396-0.3637846-0.441707-0.3810495-3.092169 2.1284358-4.423261 2.4023638-6.742929 2.1562-5.4517681-2.8350883-3.4878487-3.3430377-1.995345z" />
<g v-else-if="iconSet == 2" stroke="none" :fill="fillColor" > </g>
<path d="M22,9.5 20.5,8.5 19.75,7.25 18.25,6.75 V 5 L 17,6.75 15,8.25 12,9.5 H 5.75 L 2.75,10 2,12 2.5,15.75 3.25,16 4,19 H 5.5 V 18.25 L 5,18 5.25,16.25 6,15.25 H 10 L 13.75,16 14.75,19 H 16.25 V 18.25 L 15.75,18 V 16 L 17,15.25 17.5,12 18.25,10.25 H 19.5 L 21,10.5 Z" style="opacity: .4;"/> <path v-else-if="region == 3" d="m25.402178 7.8631343c-0.487907-0.3670601-0.811572-0.7261214-1.573424-1.106523-0.006122-0.1598737 0.053853-0.2411643-0.072374-0.5438299-0.239221-0.3572156-1.352454-0.987126-2.19723-0.8590224-1.567124 0.9252583-1.879175 1.9380345-3.311246 2.9148849 0.566485 0.8398567 1.254642 1.7575311 2.167098 2.9799951 1.541867-1.5721797 1.123352-2.3466703 2.548492-2.7336036 0.65786 0.059985 1.147615 0.1738285 1.444935 0.3493259 0.420933-0.188852 0.760222-0.5096057 0.993749-1.001227z" :fill="fillColor" fill-rule="evenodd"/>
<path v-if="region == 0" d="M12,9.5 H 11 L 10,15.25 13.75,16 H 15.75 L 17,15.25 17.5,12 Z" fill-rule="evenodd" :fill="fillColor" />
<path v-else-if="region ==1" d="M 11,9.5 H 5.75 L 2.75,10 2,12 2.5,15.75 3.25,16 6,15.25 H 10 Z" :fill="fillColor" fill-rule="evenodd"/>
<path v-else-if="region == 2" d="M11.25,10.25 C 10.25,11.25 10.25,12.75 11.25,13.75 L 13.75,16 14.75,19 H 16.25 V 18.25 L 15.75,18 V 16 L 16,12 14.75,10.25 C 13.75,9.25 12.25,9.25 11.25,10.25 Z M 3,11 2,12 2.5,15.75 3.25,16 4,19 H 5.5 V 18.25 L 5,18 5.25,16.25 6,15.25 6.5,14.5 C 7.5,13.5 7.5,12 6.5,11 C 5.5,10 4,10 3,11 Z" :fill="fillColor" fill-rule="evenodd"/>
<path v-else-if="region == 3" d="M 22,9.5 20.5,8.5 19.75,7.25 18.25,6.75 V 5 L 17,6.75 15,8.25 12,9.5 17.5,12 18.25,10.25 H 19.5 L 21,10.5 Z" :fill="fillColor" fill-rule="evenodd"/>
</g>
<g v-else-if="iconSet == 3" stroke="none" :fill="fillColor" >
<path d="M22,6.25 L21,6 V5 L19.5,4.5 V3 L18.25,4.5 16,6.5 12.5,8 6,8.25 4,8.5 2.5,9.75 2,10.5 2.75,10.75 3.5,10.25 V11 L4,12.5 4.25,14 3.25,16.5 4,21 H5.25 V20.25 L4.75,20 5,16.75 7.75,13 10.5,14.5 15,15.25 15.25,18.75 16,21 H17.25 V20.25 L16.75,20 V16.5 L17.75,13.75 18.5,10.5 19.5,8.25 H20.5 L21.5,8.75 22,7.75 Z" style="opacity: .4;"/>
<path v-if="region == 0" d="M16,6.5 L12.5,8 10.5,14.5 15,15.25 17.75,13.75 18.5,10.5 Z" fill-rule="evenodd" :fill="fillColor" />
<path v-else-if="region ==1" d="M12.5,8 L6,8.25 4,8.5 2.5,9.75 2,10.5 2.75,10.75 3.5,10.25 V11 L4,12.5 7.75,13 10.5,14.5 Z" :fill="fillColor" fill-rule="evenodd"/>
<path v-else-if="region == 2" d="M12.75,8.25 C11.75,9.25 11.75,10.75 12.75,11.75 L15,15.25 15.25,18.75 16,21 H17.25 V20.25 L16.75,20 V16.5 L17.75,13.75 18.5,10.5 16.25,8.25 C15.25,7.25 13.75,7.25 12.75,8.25 Z M6,8.5 C4.75,8.5 3.5,9.75 3.5,11 L4,12.5 4.25,14 3.25,16.5 4,21 H5.25 V20.25 L4.75,20 5,16.75 7.75,13 8.5,11 C8.5,9.75 7.25,8.5 6,8.5 Z" :fill="fillColor" fill-rule="evenodd"/>
<path v-else-if="region == 3" d="M22,6.25 L21,6 V5 L19.5,4.5 V3 L18.25,4.5 L16,6.5 18.5,10.5 19.5,8.25 H20.5 L21.5,8.75 22,7.75 Z" :fill="fillColor" fill-rule="evenodd"/>
</g> </g>
</svg> </svg>
</template> </template>
@@ -37,13 +26,6 @@
fillColor: { fillColor: {
type: String, type: String,
default: "var(--avn-theme-color)" default: "var(--avn-theme-color)"
},
iconSet: {
type: Number,
default: 1,
validator(value) {
return value >= 1 && value <= 3
}
} }
} }
} }

View File

@@ -16,7 +16,6 @@
<path v-else-if="icon == 'limbs'" d="M540-440q17 0 28.5-11.5T580-480q0-7-1.5-12.5T574-503q11-4 18.5-14t7.5-23q0-17-11.5-28.5T560-580q-13 0-23 7t-14 19l-146-70q2-4 2.5-8t.5-8q0-17-11.5-28.5T340-680q-17 0-28.5 11.5T300-640q0 6 2 11.5t5 10.5q-11 4-19 14t-8 24q0 17 11.5 28.5T320-540q14 0 24-7.5t14-19.5l146 70-4 17q0 17 11.5 28.5T540-440ZM394-80q-16-47-24-92.5t-10-86q-2-40.5-.5-74.5t4.5-58q-1 0 0 0-22-5-50.5-12.5t-61-20.5Q220-437 186-455.5T119-500l50-70q39 35 81.5 55.5t78.5 32q36 11.5 60 15l24 3.5q18 1 28.5 15t7.5 32l-4.5 33.5q-4.5 33.5-5 83.5t7.5 109q8 59 33 111h-86Zm366 0h-80v-423q0-48-25.5-87T586-649L313-772l49-67 257 117q64 29 102.5 88T760-503v423Zm-280 0q-25-52-33-111t-7.5-109q.5-50 5-83.5L449-417q3-18-7.5-32T413-464l-24-3.5q-24-3.5-60-15t-78.5-32Q208-535 169-570q39 35 81.5 55.5t78.5 32q36 11.5 60 15l24 3.5q18 1 28.5 15t7.5 32l-4.5 33.5q-4.5 33.5-5 83.5t7.5 109q8 59 33 111Z"/> <path v-else-if="icon == 'limbs'" d="M540-440q17 0 28.5-11.5T580-480q0-7-1.5-12.5T574-503q11-4 18.5-14t7.5-23q0-17-11.5-28.5T560-580q-13 0-23 7t-14 19l-146-70q2-4 2.5-8t.5-8q0-17-11.5-28.5T340-680q-17 0-28.5 11.5T300-640q0 6 2 11.5t5 10.5q-11 4-19 14t-8 24q0 17 11.5 28.5T320-540q14 0 24-7.5t14-19.5l146 70-4 17q0 17 11.5 28.5T540-440ZM394-80q-16-47-24-92.5t-10-86q-2-40.5-.5-74.5t4.5-58q-1 0 0 0-22-5-50.5-12.5t-61-20.5Q220-437 186-455.5T119-500l50-70q39 35 81.5 55.5t78.5 32q36 11.5 60 15l24 3.5q18 1 28.5 15t7.5 32l-4.5 33.5q-4.5 33.5-5 83.5t7.5 109q8 59 33 111h-86Zm366 0h-80v-423q0-48-25.5-87T586-649L313-772l49-67 257 117q64 29 102.5 88T760-503v423Zm-280 0q-25-52-33-111t-7.5-109q.5-50 5-83.5L449-417q3-18-7.5-32T413-464l-24-3.5q-24-3.5-60-15t-78.5-32Q208-535 169-570q39 35 81.5 55.5t78.5 32q36 11.5 60 15l24 3.5q18 1 28.5 15t7.5 32l-4.5 33.5q-4.5 33.5-5 83.5t7.5 109q8 59 33 111Z"/>
<path v-else-if="icon == 'head'" d="M194-80v-395h80v315h280v-193l105-105q29-29 45-65t16-77q0-40-16.5-76T659-741l-25-26-127 127H347l-43 43-57-56 67-67h160l160-160 82 82q40 40 62 90.5T800-600q0 57-22 107.5T716-402l-82 82v240H194Zm197-187L183-475q-11-11-17-26t-6-31q0-16 6-30.5t17-25.5l84-85 124 123q28 28 43.5 64.5T450-409q0 40-15 76.5T391-267Z"/> <path v-else-if="icon == 'head'" d="M194-80v-395h80v315h280v-193l105-105q29-29 45-65t16-77q0-40-16.5-76T659-741l-25-26-127 127H347l-43 43-57-56 67-67h160l160-160 82 82q40 40 62 90.5T800-600q0 57-22 107.5T716-402l-82 82v240H194Zm197-187L183-475q-11-11-17-26t-6-31q0-16 6-30.5t17-25.5l84-85 124 123q28 28 43.5 64.5T450-409q0 40-15 76.5T391-267Z"/>
<path v-else-if="icon == 'photo_sample'" d="M240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h480q33 0 56.5 23.5T800-800v640q0 33-23.5 56.5T720-80H240Zm0-80h480v-640h-80v280l-100-60-100 60v-280H240v640Zm40-80h400L545-420 440-280l-65-87-95 127Zm-40 80v-640 640Zm200-360 100-60 100 60-100-60-100 60Z"/> <path v-else-if="icon == 'photo_sample'" d="M240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h480q33 0 56.5 23.5T800-800v640q0 33-23.5 56.5T720-80H240Zm0-80h480v-640h-80v280l-100-60-100 60v-280H240v640Zm40-80h400L545-420 440-280l-65-87-95 127Zm-40 80v-640 640Zm200-360 100-60 100 60-100-60-100 60Z"/>
<path v-else-if="icon == 'reset_slide'" d="M520-330v-60h160v60H520Zm60 210v-50h-60v-60h60v-50h60v160h-60Zm100-50v-60h160v60H680Zm40-110v-160h60v50h60v60h-60v50h-60Zm111-280h-83q-26-88-99-144t-169-56q-117 0-198.5 81.5T200-480q0 72 32.5 132t87.5 98v-110h80v240H160v-80h94q-62-50-98-122.5T120-480q0-75 28.5-140.5t77-114q48.5-48.5 114-77T480-840q129 0 226.5 79.5T831-560Z"/>
</svg> </svg>
</template> </template>
@@ -43,8 +42,7 @@
'abdomen', 'abdomen',
'limbs', 'limbs',
'head', 'head',
'photo_sample', 'photo_sample'
'reset_slide'
] ]
return iconList.includes(value) return iconList.includes(value)
} }

View File

@@ -43,12 +43,6 @@
background: var(--chip-media-gradient) !important; background: var(--chip-media-gradient) !important;
} }
.chip-label {
pointer-events: none;
user-select: none;
-webkit-user-select: none;
}
.chip-results { .chip-results {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
@@ -89,26 +83,6 @@
display: none; display: none;
} }
.level-slide-marker {
border: var(--avn-slide-marker-border);
position: absolute;
top: 0%;
height: 100%;
left: var(--avn-slide-marker-position);
}
.range-bar {
background: var(--avn-theme-color);
}
.range-bar-active {
background: rgba(255,255,255,.8);
}
.dark .range-bar-active {
background: rgba(0,0,0,.8);
}
.image-menu { .image-menu {
grid-area: menu-view; grid-area: menu-view;
margin: 5px; margin: 5px;
@@ -147,14 +121,6 @@
align-self: center; align-self: center;
} }
.structure-info {
position: absolute;
z-index: 3;
color: rgb(15, 32, 108);
background: yellow;
border-radius: 100%;
}
/*Additional styles for small format landscape orientation*/ /*Additional styles for small format landscape orientation*/
@media (max-height: 450px) and (orientation: landscape) { @media (max-height: 450px) and (orientation: landscape) {
.detect-grid { .detect-grid {
@@ -190,12 +156,6 @@
display: block; display: block;
} }
.level-slide-marker {
top: calc(100% - var(--avn-slide-marker-position));
height: auto;
width: 100%;
left: 0%;
}
.image-container { .image-container {
flex-direction: column; flex-direction: column;

View File

@@ -2,63 +2,24 @@ import { reactive, computed } from 'vue';
const state = reactive({ const state = reactive({
disclaimerAgreement: false, disclaimerAgreement: false,
enabledRegions: ['thorax','abdomen','limbs','head'], enabledRegions: ['thorax','abdomen','limbs'],
regionIconSet: Math.floor(Math.random() * 3) + 1, version: '0.5.0-rc',
version: '0.5.0-alpha', siteConfig: {}
fullscreen: false,
useExternal: 'optional',
siteDemo: false,
externalServerList: [],
infoUrl: false,
safariBrowser: false
}) })
const set = (config, confObj) => { const setConfig = (confObj) => {
if (confObj === undefined) { return } state.siteConfig = confObj
state[config] = confObj
} }
const agree = () => { const agree = () => {
state.disclaimerAgreement = true state.disclaimerAgreement = true
} }
const safariDetected = () => {
state.safariBrowser = true
}
const getServerList = () => {
if (state.useExternal == 'required') {
return state.externalServerList[0]
} else {
return state.externalServerList
}
}
const toggleFullscreen = () => {
if (document.fullscreenElement) {
document.exitFullscreen().then( () => {
state.fullscreen = false
})
} else {
app.requestFullscreen().then( () => {
state.fullscreen = true
})
}
}
export default () => ({ export default () => ({
isAgreed: computed(() => state.disclaimerAgreement), isAgreed: computed(() => state.disclaimerAgreement),
isFullscreen: computed(() => state.fullscreen),
demoMode: computed(() => state.siteDemo),
externalType: computed(() => state.useExternal),
getRegions: computed(() => state.enabledRegions), getRegions: computed(() => state.enabledRegions),
getVersion: computed(() => state.version), getVersion: computed(() => state.version),
getIconSet: computed(() => state.regionIconSet), getConfig: computed(() => state.siteConfig),
getInfoUrl: computed(() => state.infoUrl), setConfig,
isSafari: computed(() => state.safariBrowser), agree
set,
agree,
safariDetected,
getServerList,
toggleFullscreen
}) })

View File

@@ -1,5 +1,3 @@
import { f7 } from 'framework7-vue'
export default { export default {
methods: { methods: {
async openCamera(imContain) { async openCamera(imContain) {
@@ -27,67 +25,17 @@ export default {
}, },
closeCamera () { closeCamera () {
this.cameraStream.getTracks().forEach( t => t.stop()) this.cameraStream.getTracks().forEach( t => t.stop())
this.cameraStream = null
this.videoAvailable = false this.videoAvailable = false
}, },
captureVidFrame() { captureVidFrame() {
const vidViewer = this.$refs.vid_viewer const vidViewer = this.$refs.vid_viewer
vidViewer.pause() vidViewer.pause()
let tempCVS = document.createElement('canvas') let tempCVS = document.createElement('canvas')
tempCVS.id = 'temp-video-canvas'
tempCVS.height = vidViewer.videoHeight || parseInt(vidViewer.style.height) tempCVS.height = vidViewer.videoHeight || parseInt(vidViewer.style.height)
tempCVS.width = vidViewer.videoWidth || parseInt(vidViewer.style.width) tempCVS.width = vidViewer.videoWidth || parseInt(vidViewer.style.width)
const tempCtx = tempCVS.getContext('2d') const tempCtx = tempCVS.getContext('2d')
tempCtx.drawImage(vidViewer, 0, 0) tempCtx.drawImage(vidViewer, 0, 0)
this.getImage(tempCVS.toDataURL()) this.getImage(tempCVS.toDataURL())
},
async videoFrameDetectWorker (vidData) {
const startDetection = () => {
createImageBitmap(vidData).then(imVideoFrame => {
this.vidWorker.postMessage({call: 'videoFrame', image: imVideoFrame}, [imVideoFrame])
})
}
vidData.addEventListener('resize',startDetection,{once: true})
this.vidWorker.onmessage = (eVid) => {
if (eVid.data.error) {
console.log(eVid.data.message)
f7.dialog.alert(`ALVINN AI model error: ${eVid.data.message}`)
} else if (this.videoAvailable) {
createImageBitmap(vidData).then(imVideoFrame => {
this.vidWorker.postMessage({call: 'videoFrame', image: imVideoFrame}, [imVideoFrame])
})
if (eVid.data.coords) {
imageCtx.clearRect(0,0,imCanvas.width,imCanvas.height)
for (var coord of eVid.data.coords) {
let pointX = (imCanvas.width - imgWidth) / 2 + (coord[0] / eVid.data.modelWidth) * imgWidth - 10
let pointY = (imCanvas.height - imgHeight) / 2 + (coord[1] / eVid.data.modelHeight) * imgHeight - 10
console.debug(`cx: ${pointX}, cy: ${pointY}`)
imageCtx.globalAlpha = coord[2]
imageCtx.drawImage(target, pointX, pointY, 20, 20)
}
}
}
}
const imCanvas = this.$refs.image_cvs
const imageCtx = imCanvas.getContext("2d")
const target = this.$refs.target_image
var imgWidth
var imgHeight
f7.utils.nextFrame(() => {
imCanvas.width = imCanvas.clientWidth
imCanvas.height = imCanvas.clientHeight
imageCtx.clearRect(0,0,imCanvas.width,imCanvas.height)
const imgAspect = vidData.width / vidData.height
const rendAspect = imCanvas.width / imCanvas.height
if (imgAspect >= rendAspect) {
imgWidth = imCanvas.width
imgHeight = imCanvas.width / imgAspect
} else {
imgWidth = imCanvas.height * imgAspect
imgHeight = imCanvas.height
}
})
} }
} }
} }

View File

@@ -10,26 +10,16 @@
</f7-navbar> </f7-navbar>
<f7-block class="detect-grid"> <f7-block class="detect-grid">
<div class="image-container" ref="image_container"> <div class="image-container" ref="image_container">
<SvgIcon v-if="!imageView.src && !videoAvailable" :icon="f7route.params.region" fill-color="var(--avn-theme-color)"/> <SvgIcon v-if="!imageView && !videoAvailable" :icon="f7route.params.region" fill-color="var(--avn-theme-color)" @click="selectImage" />
<div class="vid-container" :style="`display: ${videoAvailable ? 'block' : 'none'}; position: absolute; width: 100%; height: 100%;`"> <div class="vid-container" :style="`display: ${videoAvailable ? 'block' : 'none'}; position: absolute; width: 100%; height: 100%;`">
<video id="vid-view" ref="vid_viewer" :srcObject="cameraStream" :autoPlay="true" style="width: 100%; height: 100%"></video> <video id="vid-view" ref="vid_viewer" :srcObject="cameraStream" :autoPlay="true" style="width: 100%; height: 100%"></video>
<f7-button @click="captureVidFrame()" style="position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); z-index: 3;" fill large>Capture</f7-button> <f7-button @click="captureVidFrame()" style="position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); z-index: 3;" fill large>Capture</f7-button>
</div> </div>
<canvas id="im-draw" ref="image_cvs" @click="structureClick" :style="`display: ${(imageLoaded || videoAvailable) ? 'block' : 'none'}; flex: 1 1 0%; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; background-size: contain; background-position: center; background-repeat: no-repeat; z-index: 2;`" /> <canvas id="im-draw" ref="image_cvs" @click="structureClick" :style="`display: ${(imageLoaded || videoAvailable) ? 'block' : 'none'}; flex: 1 1 0%; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; background-size: contain; background-position: center; background-repeat: no-repeat; z-index: 2;`" />
<f7-link v-if="getInfoUrl && (selectedChip > -1)"
:style="`left: ${infoLinkPos.x}px; top: ${infoLinkPos.y}px; transform: translate(calc(-50% - ${infoLinkPos.adj}px),calc(-50% - ${infoLinkPos.adj}px));`"
class="structure-info"
:icon-only="true"
icon-f7="info"
target="_blank"
:external="true"
:href="infoLinkTarget"
/>
</div> </div>
<div class="chip-results" style="grid-area: result-view; flex: 0 0 auto; align-self: center; max-height: 450px;"> <div class="chip-results" style="grid-area: result-view; flex: 0 0 auto; align-self: center;">
<f7-chip v-for="result in showResults.filter( r => { return r.aboveThreshold && r.isSearched && !r.isDeleted })" <f7-chip v-for="result in showResults.filter( r => { return r.aboveThreshold && r.isSearched && !r.isDeleted })"
:class="(result.resultIndex == selectedChip) ? 'selected-chip' : ''" :class="(result.resultIndex == selectedChip) ? 'selected-chip' : ''"
:id="(result.resultIndex == selectedChip) ? 'selected_chip' : ''"
:text="result.label" :text="result.label"
media=" " media=" "
:tooltip="result.confidence.toFixed(1)" :tooltip="result.confidence.toFixed(1)"
@@ -42,17 +32,8 @@
<f7-progressbar v-if="(detecting || modelLoading)" style="width: 100%;" :infinite="true" /> <f7-progressbar v-if="(detecting || modelLoading)" style="width: 100%;" :infinite="true" />
</div> </div>
<div v-if="showDetectSettings" class="detect-inputs" style="grid-area: detect-settings;"> <div v-if="showDetectSettings" class="detect-inputs" style="grid-area: detect-settings;">
<f7-button @click="this.detectorLevel > 0 ? this.detectorLevel = 0 : this.detectorLevel = 50" style="flex: 0 1 20%"> <f7-range class="level-slide-horz" :min="0" :max="100" :step="1" @range:change="onLevelChange" v-model:value="detectorLevel" type="range" style="flex: 1 1 100%"/>
<SvgIcon :icon="this.detectorLevel > 0 ? 'visibility' : 'reset_slide'"/> <f7-range class="level-slide-vert" vertical :min="0" :max="100" :step="1" @range:change="onLevelChange" v-model:value="detectorLevel" type="range" style="flex: 1 1 100%"/>
</f7-button>
<div style="position: relative; flex: 1 1 100%">
<f7-range class="level-slide-horz" :min="0" :max="100" :step="1" @range:change="onLevelChange" v-model:value="detectorLevel" type="range"/>
<f7-range class="level-slide-vert" vertical :min="0" :max="100" :step="1" @range:change="onLevelChange" v-model:value="detectorLevel" type="range"/>
<div v-for="result in showResults.filter( r => { return r.isSearched && !r.isDeleted })"
class="level-slide-marker"
:style="`--avn-slide-marker-border: solid hsla(${result.confidence * 1.2}deg, 100%, 50%, .33) 1px; --avn-slide-marker-position: ${result.confidence.toFixed(1)}%`"
></div>
</div>
<f7-button @click="() => detectPanel = !detectPanel" :panel-open="!detectPanel && `#${detectorName}-settings`" :panel-close="detectPanel && `#${detectorName}-settings`" style="flex: 0 1 20%"> <f7-button @click="() => detectPanel = !detectPanel" :panel-open="!detectPanel && `#${detectorName}-settings`" :panel-close="detectPanel && `#${detectorName}-settings`" style="flex: 0 1 20%">
<SvgIcon icon="check_list"/> <SvgIcon icon="check_list"/>
</f7-button> </f7-button>
@@ -62,7 +43,7 @@
</div> </div>
<f7-segmented class="image-menu" raised> <f7-segmented class="image-menu" raised>
<f7-button popover-open="#region-popover"> <f7-button popover-open="#region-popover">
<RegionIcon :region="activeRegion" :iconSet="getIconSet" /> <RegionIcon :region="activeRegion" />
</f7-button> </f7-button>
<f7-button v-if="!videoAvailable" :class="(!modelLoading) ? '' : 'disabled'" popover-open="#capture-popover"> <f7-button v-if="!videoAvailable" :class="(!modelLoading) ? '' : 'disabled'" popover-open="#capture-popover">
<SvgIcon icon="camera_add"/> <SvgIcon icon="camera_add"/>
@@ -96,16 +77,16 @@
<f7-popover id="region-popover" class="popover-button-menu"> <f7-popover id="region-popover" class="popover-button-menu">
<f7-segmented raised class="segment-button-menu"> <f7-segmented raised class="segment-button-menu">
<f7-button :class="(getRegions.includes('thorax')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/thorax/" popover-close="#region-popover"> <f7-button :class="(getRegions.includes('thorax')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/thorax/" popover-close="#region-popover">
<RegionIcon :region="0" :iconSet="getIconSet" /> <RegionIcon :region="0" />
</f7-button> </f7-button>
<f7-button :class="(getRegions.includes('abdomen')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/abdomen/" popover-close="#region-popover"> <f7-button :class="(getRegions.includes('abdomen')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/abdomen/" popover-close="#region-popover">
<RegionIcon :region="1" :iconSet="getIconSet" /> <RegionIcon :region="1" />
</f7-button> </f7-button>
<f7-button :class="(getRegions.includes('limbs')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/limbs/" popover-close="#region-popover"> <f7-button :class="(getRegions.includes('limbs')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/limbs/" popover-close="#region-popover">
<RegionIcon :region="2" :iconSet="getIconSet" /> <RegionIcon :region="2" />
</f7-button> </f7-button>
<f7-button :class="(getRegions.includes('head')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/head/" popover-close="#region-popover"> <f7-button :class="(getRegions.includes('head')) ? '' : ' disabled'" style="height: auto; width: auto;" href="/detect/head/" popover-close="#region-popover">
<RegionIcon :region="3" :iconSet="getIconSet" /> <RegionIcon :region="3" />
</f7-button> </f7-button>
</f7-segmented> </f7-segmented>
</f7-popover> </f7-popover>
@@ -118,7 +99,7 @@
<f7-button style="height: auto; width: auto;" popover-close="#capture-popover" @click="selectImage('file')"> <f7-button style="height: auto; width: auto;" popover-close="#capture-popover" @click="selectImage('file')">
<SvgIcon icon="photo_library" /> <SvgIcon icon="photo_library" />
</f7-button> </f7-button>
<f7-button v-if="demoEnabled" style="height: auto; width: auto;" popover-close="#capture-popover" @click="selectImage('sample')"> <f7-button v-if="otherSettings.demo" style="height: auto; width: auto;" popover-close="#capture-popover" @click="selectImage('sample')">
<SvgIcon icon="photo_sample"/> <SvgIcon icon="photo_sample"/>
</f7-button> </f7-button>
</f7-segmented> </f7-segmented>
@@ -140,8 +121,6 @@
import detectionMixin from './detection-mixin' import detectionMixin from './detection-mixin'
import cameraMixin from './camera-mixin' import cameraMixin from './camera-mixin'
import detectionWorker from '@/assets/detect-worker.js?worker&inline'
export default { export default {
mixins: [submitMixin, detectionMixin, cameraMixin], mixins: [submitMixin, detectionMixin, cameraMixin],
props: { props: {
@@ -159,7 +138,7 @@
activeRegion: 4, activeRegion: 4,
classesList: [], classesList: [],
imageLoaded: false, imageLoaded: false,
imageView: new Image(), imageView: null,
imageLoadMode: "environment", imageLoadMode: "environment",
detecting: false, detecting: false,
detectPanel: false, detectPanel: false,
@@ -170,6 +149,7 @@
serverSettings: {}, serverSettings: {},
otherSettings: {}, otherSettings: {},
isCordova: !!window.cordova, isCordova: !!window.cordova,
isFullscreen: false,
uploadUid: null, uploadUid: null,
uploadDirty: false, uploadDirty: false,
modelLocation: '', modelLocation: '',
@@ -178,10 +158,7 @@
reloadModel: false, reloadModel: false,
videoDeviceAvailable: false, videoDeviceAvailable: false,
videoAvailable: false, videoAvailable: false,
cameraStream: null, cameraStream: null
infoLinkPos: {},
detectWorker: null,
vidWorker: null
} }
}, },
setup() { setup() {
@@ -190,6 +167,7 @@
created () { created () {
let loadOtherSettings = localStorage.getItem('otherSettings') let loadOtherSettings = localStorage.getItem('otherSettings')
if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings) if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings)
let modelRoot = this.isCordova ? 'https://localhost' : '.'
this.detectorName = this.f7route.params.region this.detectorName = this.f7route.params.region
switch (this.detectorName) { switch (this.detectorName) {
case 'thorax': case 'thorax':
@@ -205,9 +183,9 @@
this.activeRegion = 3 this.activeRegion = 3
break; break;
} }
this.modelLocation = URL.parse(`../models/${this.detectorName}${this.otherSettings.mini ? '-mini' : ''}/model.json`,import.meta.url).href this.modelLocation = `${modelRoot}/models/${this.detectorName}${this.otherSettings.mini ? '-mini' : ''}/model.json`
this.miniLocation = URL.parse(`../models/${this.detectorName}-mini/model.json`,import.meta.url).href this.miniLocation = `${modelRoot}/models/${this.detectorName}-mini/model.json`
fetch(URL.parse(`../models/${this.detectorName}/classes.json`,import.meta.url).href) fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/${this.detectorName}/classes.json`)
.then((mod) => { return mod.json() }) .then((mod) => { return mod.json() })
.then((classes) => { .then((classes) => {
this.classesList = classes this.classesList = classes
@@ -217,43 +195,20 @@
if (loadServerSettings) this.serverSettings = JSON.parse(loadServerSettings) if (loadServerSettings) this.serverSettings = JSON.parse(loadServerSettings)
}, },
mounted () { mounted () {
this.detectWorker = new detectionWorker()
this.detectWorker.onmessage = (eMount) => {
self = this
if (eMount.data.error) {
console.log(eMount.data.message)
f7.dialog.alert(`ALVINN AI model error: ${eMount.data.message}`)
}
self.modelLoading = false
}
this.vidWorker = new detectionWorker()
this.vidWorker.onmessage = (eMount) => {
self = this
if (eMount.data.error) {
console.log(eMount.data.message)
f7.dialog.alert(`ALVINN AI nano model error: ${eMount.data.message}`)
}
}
if (this.serverSettings && this.serverSettings.use) { if (this.serverSettings && this.serverSettings.use) {
this.getRemoteLabels() this.getRemoteLabels()
this.modelLoading = false this.modelLoading = false
} else { } else {
this.modelLoading = true this.modelLoading = true
if (this.isSafari) { this.loadModel(this.modelLocation, true).then(() => {
this.loadModel(this.modelLocation, true).then(() => { this.modelLoading = false
this.modelLoading = false }).catch((e) => {
}).catch((e) => { console.log(e.message)
console.log(e.message) f7.dialog.alert(`ALVINN AI model error: ${e.message}`)
f7.dialog.alert(`ALVINN AI model error: ${e.message}`) this.modelLoading = false
this.modelLoading = false })
})
} else {
this.detectWorker.postMessage({call: 'loadModel', weights: this.modelLocation, preload: true})
this.vidWorker.postMessage({call: 'loadModel', weights: this.miniLocation, preload: true})
}
} }
window.onresize = (e) => { if (this.$refs.image_cvs) this.selectChip('redraw') } window.onresize = (e) => { this.selectChip('redraw') }
}, },
computed: { computed: {
message () { message () {
@@ -297,14 +252,6 @@
} else { } else {
return false return false
} }
},
demoEnabled () {
return this.otherSettings.demo || this.demoMode
},
infoLinkTarget () {
if (!this.getInfoUrl) return ''
let structure = this.showResults.find( r => r.resultIndex == this.selectedChip)
return structure ? this.getInfoUrl + structure.label.replaceAll(' ','_') : ''
} }
}, },
methods: { methods: {
@@ -313,50 +260,12 @@
return `--chip-media-gradient: conic-gradient(from ${270 - (confFactor * 360 / 2)}deg, hsl(${confFactor * 120}deg, 100%, 50%) ${confFactor}turn, hsl(${confFactor * 120}deg, 50%, 66%) ${confFactor}turn)` return `--chip-media-gradient: conic-gradient(from ${270 - (confFactor * 360 / 2)}deg, hsl(${confFactor * 120}deg, 100%, 50%) ${confFactor}turn, hsl(${confFactor * 120}deg, 50%, 66%) ${confFactor}turn)`
}, },
async setData () { async setData () {
this.detectWorker.onmessage = (eDetect) => { if (this.reloadModel) {
self = this
if (eDetect.data.error) {
self.detecting = false
self.resultData = {}
loadFailure()
f7.dialog.alert(`ALVINN structure finding error: ${eDetect.data.message}`)
} else if (eDetect.data.success == 'detection') {
self.detecting = false
self.resultData = eDetect.data.detections
if (self.resultData) {
self.resultData.detections.map(d => {d.label = self.detectorLabels[d.label].name})
}
self.uploadDirty = true
} else if (eDetect.data.success == 'model') {
self.reloadModel = false
loadSuccess()
}
}
let loadSuccess = null
let loadFailure = null
let modelReloading = null
if (this.isSafari && this.reloadModel) {
await this.loadModel(this.modelLocation) await this.loadModel(this.modelLocation)
this.reloadModel = false this.reloadModel = false
} else {
modelReloading = new Promise((res, rej) => {
loadSuccess = res
loadFailure = rej
if (this.reloadModel) {
this.detectWorker.postMessage({call: 'loadModel', weights: this.modelLocation})
} else {
loadSuccess()
}
})
} }
if (this.serverSettings && this.serverSettings.use) { if (this.serverSettings && this.serverSettings.use) {
this.remoteDetect() this.remoteDetect()
} else if (!this.isSafari) {
Promise.all([modelReloading,createImageBitmap(this.imageView)]).then(res => {
this.detectWorker.postMessage({call: 'localDetect', image: res[1]}, [res[1]])
})
} else { } else {
this.localDetect(this.imageView).then(dets => { this.localDetect(this.imageView).then(dets => {
this.detecting = false this.detecting = false
@@ -383,22 +292,19 @@
navigator.camera.getPicture(this.getImage, this.onFail, { quality: 50, destinationType: Camera.DestinationType.DATA_URL, correctOrientation: true }); navigator.camera.getPicture(this.getImage, this.onFail, { quality: 50, destinationType: Camera.DestinationType.DATA_URL, correctOrientation: true });
return return
} }
if (mode == "camera" && !this.otherSettings.disableVideo) { if (mode == "camera") {
this.videoAvailable = await this.openCamera(this.$refs.image_container) this.videoAvailable = await this.openCamera(this.$refs.image_container)
if (this.videoAvailable) { if (this.videoAvailable) {
this.selectedChip = -1
this.imageLoaded = false this.imageLoaded = false
this.imageView.src = null this.imageView = null
this.$refs.image_cvs.style['background-image'] = 'none' this.$refs.image_cvs.style['background-image'] = 'none'
this.resultData = {} this.resultData = {}
var trackDetails = this.cameraStream.getVideoTracks()[0].getSettings() var trackDetails = this.cameraStream.getVideoTracks()[0].getSettings()
var vidElement = this.$refs.vid_viewer var vidElement = this.$refs.vid_viewer
vidElement.width = trackDetails.width vidElement.width = trackDetails.width
vidElement.height = trackDetails.height vidElement.height = trackDetails.height
if (this.isSafari) { if (!this.otherSettings.disableVideo) {
this.videoFrameDetect(vidElement) this.videoFrameDetect(vidElement)
} else {
this.videoFrameDetectWorker(vidElement)
} }
return return
} }
@@ -436,22 +342,13 @@
const boxCoords = this.box2cvs(this.resultData.detections[iChip])[0] const boxCoords = this.box2cvs(this.resultData.detections[iChip])[0]
let boxLeft = boxCoords.cvsLeft var boxLeft = boxCoords.cvsLeft
let boxTop = boxCoords.cvsTop var boxTop = boxCoords.cvsTop
let boxWidth = boxCoords.cvsRight - boxCoords.cvsLeft var boxWidth = boxCoords.cvsRight - boxCoords.cvsLeft
let boxHeight = boxCoords.cvsBottom - boxCoords.cvsTop var boxHeight = boxCoords.cvsBottom - boxCoords.cvsTop
this.infoLinkPos.x = boxCoords.cvsLeft imageCtx.strokeRect(boxLeft,boxTop,boxWidth,boxHeight)
this.infoLinkPos.y = boxCoords.cvsTop
let boxMin = Math.min(boxHeight, boxWidth)
this.infoLinkPos.adj = (boxMin >= 50) ? 0 : Math.min(10, 50 - boxMin)
imageCtx.strokeRect(boxLeft, boxTop, boxWidth, boxHeight)
this.selectedChip = iChip this.selectedChip = iChip
this.resultData.detections[iChip].beenViewed = true this.resultData.detections[iChip].beenViewed = true
this.$nextTick( () => {
document.getElementById('selected_chip').scrollIntoView({behavior: 'smooth', block: 'nearest'})
})
}, },
deleteChip ( iChip ) { deleteChip ( iChip ) {
f7.dialog.confirm(`${this.resultData.detections[iChip].label} is identified with ${this.resultData.detections[iChip].confidence.toFixed(1)}% confidence. Are you sure you want to delete it?`, () => { f7.dialog.confirm(`${this.resultData.detections[iChip].label} is identified with ${this.resultData.detections[iChip].confidence.toFixed(1)}% confidence. Are you sure you want to delete it?`, () => {
@@ -467,7 +364,6 @@
imCanvas.width = imCanvas.clientWidth imCanvas.width = imCanvas.clientWidth
imCanvas.height = imCanvas.clientHeight imCanvas.height = imCanvas.clientHeight
imageCtx.clearRect(0,0,imCanvas.width,imCanvas.height) imageCtx.clearRect(0,0,imCanvas.width,imCanvas.height)
imageCtx.globalAlpha = 1
imageCtx.strokeStyle = 'yellow' imageCtx.strokeStyle = 'yellow'
imageCtx.lineWidth = 3 imageCtx.lineWidth = 3
return [imCanvas, imageCtx] return [imCanvas, imageCtx]
@@ -483,11 +379,11 @@
this.detecting = true this.detecting = true
resolve('data:image/jpg;base64,' + searchImage) resolve('data:image/jpg;base64,' + searchImage)
} }
const reader = new FileReader() var reader = new FileReader()
reader.addEventListener("load", () => { reader.addEventListener("load", () => {
this.detecting = true this.detecting = true
resolve(reader.result) resolve(reader.result)
},{once: true}) })
if (this.imageLoadMode == 'sample') { if (this.imageLoadMode == 'sample') {
fetch(`${this.isCordova ? 'https://localhost' : '.'}/samples/${this.detectorName}-${searchImage}.jpeg`).then( resp => { fetch(`${this.isCordova ? 'https://localhost' : '.'}/samples/${this.detectorName}-${searchImage}.jpeg`).then( resp => {
return resp.blob() return resp.blob()
@@ -507,14 +403,19 @@
this.imageLoaded = true this.imageLoaded = true
this.resultData = {} this.resultData = {}
this.selectedChip = -1 this.selectedChip = -1
this.imageView = new Image()
this.imageView.src = imgData this.imageView.src = imgData
return(this.imageView.decode()) return(this.imageView.decode())
}).then( () => { }).then( () => {
const [imCanvas, _] = this.resetView() const [imCanvas, _] = this.resetView()
imCanvas.style['background-image'] = `url(${this.imageView.src})` imCanvas.style['background-image'] = `url(${this.imageView.src})`
f7.utils.nextFrame(() => { /******
* setTimeout is not a good solution, but it's the only way
* I can find to not cut off drawing of the canvas background
******/
setTimeout(() => {
this.setData() this.setData()
}) }, 1)
}).catch((e) => { }).catch((e) => {
console.log(e.message) console.log(e.message)
f7.dialog.alert(`Error loading image: ${e.message}`) f7.dialog.alert(`Error loading image: ${e.message}`)
@@ -567,6 +468,17 @@
} }
}) })
return cvsCoords return cvsCoords
},
toggleFullscreen() {
if (document.fullscreenElement) {
document.exitFullscreen().then( () => {
this.isFullscreen = false
})
} else {
app.requestFullscreen().then( () => {
this.isFullscreen = true
})
}
} }
} }
} }

View File

@@ -1,7 +1,7 @@
import * as tf from '@tensorflow/tfjs' import * as tf from '@tensorflow/tfjs'
import { f7 } from 'framework7-vue' import { f7 } from 'framework7-vue'
let model = null var model = null
export default { export default {
methods: { methods: {
@@ -9,7 +9,7 @@ export default {
if (model && model.modelURL == weights) { if (model && model.modelURL == weights) {
return model return model
} else if (model) { } else if (model) {
tf.dispose(model) model.dispose()
} }
model = await tf.loadGraphModel(weights) model = await tf.loadGraphModel(weights)
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3) const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3)
@@ -25,23 +25,19 @@ export default {
return model return model
}, },
async localDetect(imageData) { async localDetect(imageData) {
console.time('mx: pre-process') console.time('pre-process')
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3) const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3)
let gTense = null
const input = tf.tidy(() => { const input = tf.tidy(() => {
gTense = tf.image.rgbToGrayscale(tf.image.resizeBilinear(tf.browser.fromPixels(imageData), [modelWidth, modelHeight])).div(255.0).expandDims(0) return tf.image.resizeBilinear(tf.browser.fromPixels(imageData), [modelWidth, modelHeight]).div(255.0).expandDims(0)
return tf.concat([gTense,gTense,gTense],3)
}) })
tf.dispose(gTense) console.timeEnd('pre-process')
console.timeEnd('mx: pre-process')
console.time('mx: run prediction') console.time('run prediction')
const res = model.predict(input) const res = model.predict(input)
const tRes = tf.transpose(res,[0,2,1]) const rawRes = tf.transpose(res,[0,2,1]).arraySync()[0]
const rawRes = tRes.arraySync()[0] console.timeEnd('run prediction')
console.timeEnd('mx: run prediction')
console.time('mx: post-process') console.time('post-process')
const outputSize = res.shape[1] const outputSize = res.shape[1]
let rawBoxes = [] let rawBoxes = []
let rawScores = [] let rawScores = []
@@ -63,8 +59,6 @@ export default {
if (rawBoxes.length > 0) { if (rawBoxes.length > 0) {
const tBoxes = tf.tensor2d(rawBoxes) const tBoxes = tf.tensor2d(rawBoxes)
let tScores = null let tScores = null
let resBoxes = null
let validBoxes = []
let structureScores = null let structureScores = null
let boxes_data = [] let boxes_data = []
let scores_data = [] let scores_data = []
@@ -72,9 +66,8 @@ export default {
for (var c = 0; c < outputSize - 4; c++) { for (var c = 0; c < outputSize - 4; c++) {
structureScores = rawScores.map(x => x[c]) structureScores = rawScores.map(x => x[c])
tScores = tf.tensor1d(structureScores) tScores = tf.tensor1d(structureScores)
resBoxes = await tf.image.nonMaxSuppressionAsync(tBoxes,tScores,10,0.5,.05) var validBoxes = await tf.image.nonMaxSuppressionAsync(tBoxes,tScores,10,0.5,.05)
validBoxes = resBoxes.dataSync() validBoxes = validBoxes.dataSync()
tf.dispose(resBoxes)
if (validBoxes) { if (validBoxes) {
boxes_data.push(...rawBoxes.filter( (_, idx) => validBoxes.includes(idx))) boxes_data.push(...rawBoxes.filter( (_, idx) => validBoxes.includes(idx)))
var outputScores = structureScores.filter( (_, idx) => validBoxes.includes(idx)) var outputScores = structureScores.filter( (_, idx) => validBoxes.includes(idx))
@@ -83,10 +76,8 @@ export default {
} }
} }
validBoxes = []
tf.dispose(tBoxes) tf.dispose(tBoxes)
tf.dispose(tScores) tf.dispose(tScores)
tf.dispose(tRes)
const valid_detections_data = classes_data.length const valid_detections_data = classes_data.length
var output = { var output = {
detections: [] detections: []
@@ -105,7 +96,7 @@ export default {
} }
tf.dispose(res) tf.dispose(res)
tf.dispose(input) tf.dispose(input)
console.timeEnd('mx: post-process') console.timeEnd('post-process')
return output || { detections: [] } return output || { detections: [] }
}, },
@@ -194,7 +185,7 @@ export default {
imgHeight = imCanvas.height imgHeight = imCanvas.height
} }
while (this.videoAvailable) { while (this.videoAvailable) {
console.time('mx: frame-process') console.time('frame-process')
try { try {
const input = tf.tidy(() => { const input = tf.tidy(() => {
return tf.image.resizeBilinear(tf.browser.fromPixels(vidData), [modelWidth, modelHeight]).div(255.0).expandDims(0) return tf.image.resizeBilinear(tf.browser.fromPixels(vidData), [modelWidth, modelHeight]).div(255.0).expandDims(0)
@@ -205,11 +196,9 @@ export default {
let rawCoords = [] let rawCoords = []
if (rawRes) { if (rawRes) {
for (var i = 0; i < rawRes.length; i++) { for (var i = 0; i < rawRes.length; i++) {
let getScores = rawRes[i].slice(4) var getScores = rawRes[i].slice(4)
if (getScores.some( s => s > .5)) { if (getScores.some( s => s > .5)) {
let foundTarget = rawRes[i].slice(0,2) rawCoords.push(rawRes[i].slice(0,2))
foundTarget.push(Math.max(...getScores))
rawCoords.push(foundTarget)
} }
} }
@@ -218,17 +207,13 @@ export default {
console.log(`x: ${coord[0]}, y: ${coord[1]}`) console.log(`x: ${coord[0]}, y: ${coord[1]}`)
let pointX = (imCanvas.width - imgWidth) / 2 + (coord[0] / modelWidth) * imgWidth -5 let pointX = (imCanvas.width - imgWidth) / 2 + (coord[0] / modelWidth) * imgWidth -5
let pointY = (imCanvas.height - imgHeight) / 2 + (coord[1] / modelHeight) * imgHeight -5 let pointY = (imCanvas.height - imgHeight) / 2 + (coord[1] / modelHeight) * imgHeight -5
imageCtx.globalAlpha = coord[2]
imageCtx.drawImage(target, pointX, pointY, 20, 20) imageCtx.drawImage(target, pointX, pointY, 20, 20)
} }
} }
tf.dispose(input)
tf.dispose(res)
tf.dispose(rawRes)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
console.timeEnd('mx: frame-process') console.timeEnd('frame-process')
await tf.nextFrame(); await tf.nextFrame();
} }
} }

View File

@@ -4,14 +4,7 @@
<f7-block> <f7-block>
<h2>Quick Start</h2> <h2>Quick Start</h2>
<ol> <ol>
<li>Select the region of the body you want to identify structures from. The regions are: <li>Select the region of the body you want to identify structures from.</li>
<ul>
<li><RegionIcon :region="0" class="list-region"/>Thorax and back</li>
<li><RegionIcon :region="1" class="list-region"/>Abdomen and pelvis</li>
<li><RegionIcon :region="2" class="list-region"/>Limbs</li>
<li><RegionIcon :region="3" class="list-region"/>Head and neck</li>
</ul>
</li>
<li>Load an image: <li>Load an image:
<ul> <ul>
<li>Click on the camera icon <SvgIcon icon="photo_camera" class="list-svg"/> to take a new picture. <li>Click on the camera icon <SvgIcon icon="photo_camera" class="list-svg"/> to take a new picture.
@@ -25,32 +18,29 @@
</ul> </ul>
</li> </li>
<li>When the picture is captured or loaded, any identifiable structures will be listed as tags below the image: <li>When the picture is captured or loaded, any identifiable structures will be listed as tags below the image:
<f7-chip text="Structure name" media=" " class="demo-chip" deleteable/> <f7-chip text="Structure name" media=" " class="demo-chip"/>
<ul> <ul>
<li>Click on each tag to see the structure highlighted in the image or click on the image to see the tag for that structure (additional clicks to the same area will select overlapping structres).</li> <li>Click on each tag to see the structure highlighted in the image.</li>
<li>Tag color and proportion filled indicate ALVINN's level of confidence in the identification.</li> <li>Tag color and proportion filled indicate ALVINN's level of confidence in the identification.</li>
<li>An incorrect tag can be deleted by clicking on the tag's <f7-icon icon="chip-delete" style="margin-right: 1px;"></f7-icon> button.</li> <li>If there are potential structures that do not satisfy the current detection threshold, a badge on the detection menu icon <SvgIcon icon="visibility" class="list-svg"/> will indicate the number of un-displayed structures.</li>
</ul> </ul>
</li> </li>
</ol> </ol>
<h2>Advanced Features</h2> <h2>Advanced Features</h2>
<h3>Detection Parameters</h3> <h3>Detection Parameters</h3>
<p> <p>
If there are potential structures that do not satisfy the current detection settings, a badge on the detection menu icon <SvgIcon icon="visibility" class="list-svg"/> will indicate the number of un-displayed structures. After an image has been loaded and structure detection has been performed, the detection parameters can be adjusted using the detection menu icon <SvgIcon icon="visibility" class="list-svg"/>.
Clicking on the detection menu icon will open a menu of tools to adjust the detection settings.
This button will make three tools available: This button will make three tools available:
</p> </p>
<ol> <ol>
<li>Confidence filter <SvgIcon icon="visibility" class="list-svg"/> or <SvgIcon icon="reset_slide" class="list-svg"/>: You can press this button to show all structures or return the confidence slider to the default value (50%).</li> <li>Confidence slider: You can use the slider to change the confidence threshold for identifying structures. The default threshold is 50% confidence.</li>
<li>Confidence slider: You can use the slider to change the confidence threshold for identifying structures.</li> <li>Refresh detections <SvgIcon icon="refresh_search" class="list-svg"/>: If there has been a permanent change to the structures detections, such as deleting a tag, the detection list can be reset to its original state.</li>
<li>Refresh detections <SvgIcon icon="refresh_search" class="list-svg"/>: If there has been a permanent change to the structure detection list, such as deleting a tag, the detection list can be reset to its original state.</li>
<li>Structure list <SvgIcon icon="check_list" class="list-svg"/>: you can view a list of all the structures available for detection in that region and select/deselect individual structures for detection.</li> <li>Structure list <SvgIcon icon="check_list" class="list-svg"/>: you can view a list of all the structures available for detection in that region and select/deselect individual structures for detection.</li>
</ol> </ol>
<h3>Submitting Images</h3> <h3>Submitting Images</h3>
<p> <p>
If all of the detection tags that are currently visible have been clicked on and viewed, then the cloud upload button <SvgIcon icon="cloud_upload" class="list-svg"/> on the detection menu will be enabled. If all of the detection tags that are currently visible have been viewed, then the cloud upload button <SvgIcon icon="cloud_upload" class="list-svg"/> on the detection menu will be enabled.
This button will cause the image and the verified structures to be uploaded to the ALVINN project servers where that data will become available for further training of the neural net. This button will cause the image and the verified structures to be uploaded to the ALVINN project servers where that data will be available for further training of the neural net. If after the image has been uploaded, the available detection tags change, then the option to re-upload the image will be available if all the new tags have been viewed and verified.
If after the image has been uploaded, the available detection tags are changed via deletion or the detection settings options, then the option to re-upload the image will be available if all the new tags have been viewed and verified.
</p> </p>
</f7-block> </f7-block>
</f7-page> </f7-page>
@@ -67,13 +57,6 @@
top: .5em; top: .5em;
} }
.list-region {
width: 3em;
position:relative;
top: 1em;
margin-right: .5em;
}
.cap-button { .cap-button {
background-color: var(--f7-theme-color); background-color: var(--f7-theme-color);
color: white; color: white;
@@ -97,12 +80,10 @@
<script> <script>
import SvgIcon from '../components/svg-icon.vue' import SvgIcon from '../components/svg-icon.vue'
import RegionIcon from '../components/region-icon.vue'
export default { export default {
components: { components: {
SvgIcon, SvgIcon
RegionIcon
} }
} }
</script> </script>

View File

@@ -6,10 +6,6 @@
<f7-link icon-ios="f7:bars" icon-md="f7:bars" panel-open="left"></f7-link> <f7-link icon-ios="f7:bars" icon-md="f7:bars" panel-open="left"></f7-link>
</f7-nav-left> </f7-nav-left>
<f7-nav-title sliding>A.L.V.I.N.N.</f7-nav-title> <f7-nav-title sliding>A.L.V.I.N.N.</f7-nav-title>
<f7-nav-right>
<f7-link v-if="!isCordova" :icon-only="true" tooltip="Fullscreen" :icon-f7="isFullscreen ? 'viewfinder_circle_fill' : 'viewfinder'" @click="toggleFullscreen"></f7-link>
<f7-link :icon-only="true" tooltip="ALVINN help" icon-f7="question_circle_fill" href="/help/"></f7-link>
</f7-nav-right>
</f7-navbar> </f7-navbar>
<!-- Page content--> <!-- Page content-->
<div style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content min-content 1fr; align-content: stretch; gap: 15px; min-height: 0px; max-height: calc(100vh - (var(--f7-navbar-height) + var(--f7-safe-area-top))); height: calc(100vh - (var(--f7-navbar-height) + var(--f7-safe-area-top)));"> <div style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content min-content 1fr; align-content: stretch; gap: 15px; min-height: 0px; max-height: calc(100vh - (var(--f7-navbar-height) + var(--f7-safe-area-top))); height: calc(100vh - (var(--f7-navbar-height) + var(--f7-safe-area-top)));">
@@ -24,16 +20,16 @@
<p style="text-align: center; margin: 0;">Select a region to begin.</p> <p style="text-align: center; margin: 0;">Select a region to begin.</p>
<div class="region-grid"> <div class="region-grid">
<f7-button :class="`region-button thorax${isAgreed && getRegions.includes('thorax') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('thorax') && '/detect/thorax/'"> <f7-button :class="`region-button thorax${isAgreed && getRegions.includes('thorax') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('thorax') && '/detect/thorax/'">
<RegionIcon class="region-image" :region="0" :iconSet="getIconSet" /> <RegionIcon class="region-image" :region="0" />
</f7-button> </f7-button>
<f7-button :class="`region-button abdomen${isAgreed && getRegions.includes('abdomen') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('abdomen') && '/detect/abdomen/'"> <f7-button :class="`region-button abdomen${isAgreed && getRegions.includes('abdomen') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('abdomen') && '/detect/abdomen/'">
<RegionIcon class="region-image" :region="1" :iconSet="getIconSet" /> <RegionIcon class="region-image" :region="1" />
</f7-button> </f7-button>
<f7-button :class="`region-button limbs${isAgreed && getRegions.includes('limbs') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('limbs') && '/detect/limbs/'"> <f7-button :class="`region-button limbs${isAgreed && getRegions.includes('limbs') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('limbs') && '/detect/limbs/'">
<RegionIcon class="region-image" :region="2" :iconSet="getIconSet" /> <RegionIcon class="region-image" :region="2" />
</f7-button> </f7-button>
<f7-button :class="`region-button headneck${isAgreed && getRegions.includes('head') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('head') && '/detect/head/'"> <f7-button :class="`region-button headneck${isAgreed && getRegions.includes('head') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('head') && '/detect/head/'">
<RegionIcon class="region-image" :region="3" :iconSet="getIconSet" /> <RegionIcon class="region-image" :region="3" />
</f7-button> </f7-button>
</div> </div>
</div> </div>
@@ -97,8 +93,7 @@
</style> </style>
<script> <script>
import { touchstart } from 'dom7' import RegionIcon from '../components/region-icon.vue'
import RegionIcon from '../components/region-icon.vue'
import store from '../js/store' import store from '../js/store'
import { f7 } from 'framework7-vue' import { f7 } from 'framework7-vue'
@@ -108,7 +103,6 @@ import RegionIcon from '../components/region-icon.vue'
}, },
data () { data () {
return { return {
isCordova: !!window.cordova,
alphaCheck: false alphaCheck: false
} }
}, },

View File

@@ -31,22 +31,19 @@
<span style="margin-left: 16px;">Disable video estimates<f7-icon size="16" style="padding-left: 5px;" f7="question_diamond_fill" tooltip="faster: recommended for slower devices" /></span> <span style="margin-left: 16px;">Disable video estimates<f7-icon size="16" style="padding-left: 5px;" f7="question_diamond_fill" tooltip="faster: recommended for slower devices" /></span>
<f7-toggle v-model:checked="otherSettings.disableVideo" style="margin-right: 16px;" /> <f7-toggle v-model:checked="otherSettings.disableVideo" style="margin-right: 16px;" />
</div> </div>
<div v-if="serverToggle"> <div style="display:flex; justify-content:space-between; width: 100%">
<div style="display:flex; justify-content:space-between; width: 100%"> <span style="margin-left: 16px;">Use external server</span>
<span style="margin-left: 16px;">Use external server</span> <f7-toggle v-model:checked="serverSettings.use" style="margin-right: 16px;" @change="setDirty()" />
<f7-toggle v-model:checked="serverSettings.use" style="margin-right: 16px;" @change="setDirty()" />
</div>
<f7-list >
<f7-list-input :disabled="!serverSettings.use || serverList" v-model:value="serverSettings.address" label="Server address" type="text" placeholder="127.0.0.1" />
<f7-list-input :disabled="!serverSettings.use || serverList" v-model:value="serverSettings.port" label="Server port" type="text" placeholder="9001" />
</f7-list>
<span>Other servers</span>
<f7-list :dividers="true" :outline="true" :strong="true" :inset="true" style="width: calc(100% - 32px); margin-top: 0;">
<f7-list-item v-for="(addObj) in externalIp" :disabled="!serverSettings.use" :title="addObj.name" @click="setServerProps(addObj.address, addObj.port)"></f7-list-item>
<f7-list-item v-if="!serverList" v-for="(port, add) in otherIp" :disabled="!serverSettings.use" :title="add" @click="setServerProps(add, port)">{{ port }}</f7-list-item>
<f7-list-item v-if="Object.keys(otherIp).length == 0 && externalIp.length == 0" title="No previous server settings"></f7-list-item>
</f7-list>
</div> </div>
<f7-list>
<f7-list-input :disabled="!serverSettings.use" v-model:value="serverSettings.address" label="Server address" type="text" placeholder="127.0.0.1" />
<f7-list-input :disabled="!serverSettings.use" v-model:value="serverSettings.port" label="Server port" type="text" placeholder="9001" />
</f7-list>
<span>Other servers</span>
<f7-list :dividers="true" :outline="true" :strong="true" :inset="true" style="width: calc(100% - 32px); margin-top: 0;">
<f7-list-item v-for="(port, add) in otherIp" :disabled="!serverSettings.use" :title="add" @click="setServerProps(add, port)">{{ port }}</f7-list-item>
<f7-list-item v-if="Object.keys(otherIp).length == 0" title="No previous server settings"></f7-list-item>
</f7-list>
</div> </div>
<f7-button fill @click="saveAllSettings">SAVE</f7-button> <f7-button fill @click="saveAllSettings">SAVE</f7-button>
</div> </div>
@@ -64,7 +61,6 @@
<script> <script>
import { f7 } from 'framework7-vue' import { f7 } from 'framework7-vue'
import store from '../js/store'
export default { export default {
data () { data () {
@@ -76,8 +72,8 @@
}, },
serverSettings: { serverSettings: {
use: false, use: false,
address: '127.0.0.1', address: '10.170.64.22',
port: '9000', port: '9001',
previous: {} previous: {}
}, },
themeSettings: { themeSettings: {
@@ -85,9 +81,6 @@
} }
} }
}, },
setup() {
return store()
},
computed: { computed: {
otherIp () { otherIp () {
let filteredIps = {} let filteredIps = {}
@@ -97,15 +90,6 @@
} }
} }
return filteredIps return filteredIps
},
serverToggle () {
return ['optional','list'].includes(this.externalType)
},
serverList () {
return this.externalType == 'list'
},
externalIp () {
return this.getServerList()
} }
}, },
created () { created () {
@@ -122,7 +106,7 @@
let saveSetting = new Promise( let saveSetting = new Promise(
(saved,failed) => { (saved,failed) => {
try { try {
if (this.serverSettings.use && !this.externalIp.some( (srv) => srv.address == this.serverSettings.address)) { if (this.serverSettings.use) {
this.serverSettings.previous[this.serverSettings.address] = this.serverSettings.port this.serverSettings.previous[this.serverSettings.address] = this.serverSettings.port
} }
localStorage.setItem('serverSettings',JSON.stringify(this.serverSettings)) localStorage.setItem('serverSettings',JSON.stringify(this.serverSettings))
@@ -167,8 +151,7 @@
}, },
toggleSettingsView () { toggleSettingsView () {
this.showAdvanced = !this.showAdvanced this.showAdvanced = !this.showAdvanced
//this.$refs.advancedSettings.style.maxHeight = `${this.showAdvanced ? this.$refs.advancedSettings.scrollHeight : 0}px` this.$refs.advancedSettings.style.maxHeight = `${this.showAdvanced ? this.$refs.advancedSettings.scrollHeight : 0}px`
this.$refs.advancedSettings.style.maxHeight = this.showAdvanced ? '100%' : '0px'
}, },
confirmBack () { confirmBack () {
if (this.isDirty) { if (this.isDirty) {

View File

@@ -8,7 +8,6 @@
<f7-block-title medium>Details</f7-block-title> <f7-block-title medium>Details</f7-block-title>
<f7-list> <f7-list>
<f7-list-item title="Version" :after="alvinnVersion"></f7-list-item> <f7-list-item title="Version" :after="alvinnVersion"></f7-list-item>
<f7-list-item v-if="isSafari" title="Safari" after="Workers disabled"></f7-list-item>
</f7-list> </f7-list>
<f7-block-title medium>Models</f7-block-title> <f7-block-title medium>Models</f7-block-title>
<f7-list style="width: 100%;"> <f7-list style="width: 100%;">
@@ -16,10 +15,8 @@
<f7-list-item title="Thorax-m" :after="miniThoraxDetails.version"></f7-list-item> <f7-list-item title="Thorax-m" :after="miniThoraxDetails.version"></f7-list-item>
<f7-list-item :class="otherSettings.mini ? 'unused-model' : ''" title="Abdomen/Pelvis" :after="abdomenDetails.version"></f7-list-item> <f7-list-item :class="otherSettings.mini ? 'unused-model' : ''" title="Abdomen/Pelvis" :after="abdomenDetails.version"></f7-list-item>
<f7-list-item title="Abd/Pel-m" :after="miniAbdomenDetails.version"></f7-list-item> <f7-list-item title="Abd/Pel-m" :after="miniAbdomenDetails.version"></f7-list-item>
<f7-list-item :class="otherSettings.mini ? 'unused-model' : ''" title="Limbs" :after="limbsDetails.version"></f7-list-item> <f7-list-item title="Limbs" :after="limbsDetails.version"></f7-list-item>
<f7-list-item title="Limbs-m" :after="miniLimbsDetails.version"></f7-list-item> <f7-list-item title="Head/Neck" :after="headneckDetails.version"></f7-list-item>
<f7-list-item :class="otherSettings.mini ? 'unused-model' : ''" title="Head/Neck" :after="headneckDetails.version"></f7-list-item>
<f7-list-item title="Head-m" :after="miniHeadneckDetails.version"></f7-list-item>
</f7-list> </f7-list>
</div> </div>
</f7-block> </f7-block>
@@ -45,15 +42,10 @@
miniThoraxDetails: {}, miniThoraxDetails: {},
abdomenDetails: {}, abdomenDetails: {},
miniAbdomenDetails: {}, miniAbdomenDetails: {},
//limbsDetails: { "version": "N/A" }, limbsDetails: { "version": "N/A" },
//headneckDetails: { "version": "N/A" }, headneckDetails: { "version": "N/A" },
limbsDetails: {},
miniLimbsDetails: {},
headneckDetails: {},
miniHeadneckDetails: {},
alvinnVersion: store().getVersion, alvinnVersion: store().getVersion,
isCordova: !!window.cordova, isCordova: !!window.cordova,
isSafari: store().isSafari,
otherSettings: {} otherSettings: {}
} }
}, },
@@ -75,18 +67,6 @@
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen-mini/descript.json`) fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen-mini/descript.json`)
.then((mod) => { return mod.json() }) .then((mod) => { return mod.json() })
.then((desc) => { this.miniAbdomenDetails = desc }) .then((desc) => { this.miniAbdomenDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/limbs/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.limbsDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/limbs-mini/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.miniLimbsDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/head/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.headneckDetails = desc })
fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/head-mini/descript.json`)
.then((mod) => { return mod.json() })
.then((desc) => { this.miniHeadneckDetails = desc })
}, },
methods: { methods: {
} }