Skip to content

Commit

Permalink
Merge branch 'main' into merging_trk
Browse files Browse the repository at this point in the history
  • Loading branch information
BarzaH committed Dec 12, 2024
2 parents 482ef38 + 7c0d925 commit 7181c48
Show file tree
Hide file tree
Showing 39 changed files with 178,675 additions and 75 deletions.
2 changes: 1 addition & 1 deletion DockerfileMED
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime
RUN export PYTHONPATH=. && export PATH=$PATH
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install ffmpeg libsm6 libxext6 curl iotop -y \
&& apt-get install ffmpeg libsm6 libxext6 curl iotop git -y \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
RUN pip3 install --upgrade pip pyopenssl cryptography
RUN /bin/bash -c 'curl -sSL https://install.python-poetry.org | python - --version 1.6.1'
Expand Down
2 changes: 1 addition & 1 deletion DockerfileNM
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime
RUN export PYTHONPATH=. && export PATH=$PATH
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install ffmpeg libsm6 libxext6 curl iotop -y \
&& apt-get install ffmpeg libsm6 libxext6 curl iotop git -y \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
RUN pip3 install --upgrade pip pyopenssl cryptography
RUN /bin/bash -c 'curl -sSL https://install.python-poetry.org | python - --version 1.6.1'
Expand Down
2 changes: 1 addition & 1 deletion DockerfilePROM
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime
RUN export PYTHONPATH=. && export PATH=$PATH
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install ffmpeg libsm6 libxext6 curl iotop -y \
&& apt-get install ffmpeg libsm6 libxext6 curl iotop git -y \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
RUN pip3 install --upgrade pip pyopenssl cryptography
RUN /bin/bash -c 'curl -sSL https://install.python-poetry.org | python - --version 1.6.1'
Expand Down
25 changes: 25 additions & 0 deletions config/datasets/detection/florence.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
task:
- image-detection

_target_: innofw.core.datamodules.lightning_datamodules.florence.FlorenceImageDataModuleAdapter
#_target_: innofw.core.datamodules.lightning_datamodules.florence.FlorenceJSONLDataModuleAdapter # for jsonl data

name: florence
description: Набор данных
markup_info: Набор данных содержит разметку bounding box легких и патологий.
date_time: 17.11.2024
num_workers: 8
size_to: 768

train:
source: "https://api.blackhole.ai.innopolis.university/public-datasets/florence/train.zip"
target: "./data/florence/train/"

test:
source: "https://api.blackhole.ai.innopolis.university/public-datasets/florence/test.zip"
target: "./data/florence/test/"

infer:
source: "https://api.blackhole.ai.innopolis.university/public-datasets/florence/infer.zip"
target: "./data/florence/infer"

30 changes: 30 additions & 0 deletions config/datasets/empty_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
task:
- НАЗВАНИЕ РЕШАЕМОЙ ЗАДАЧИ

name: ИМЯ ДАТАСЕТА
description: ОПИСАНИЕ
markup_info: ИНФОРМАЦИЯ ПО РАЗМЕТКЕ
date_time: ДАТА В ФОРМАТЕ 22.11.2222

_target_: ПУТЬ ДО КЛАССА ОТВЕЧАЮЩЕГО ЗА РАБОТУ С ДАТАСЕТОМ

train:
source: URL / ЛОКАЛЬНЫЙ ПУТЬ
target: ЛОКАЛЬНЫЙ ПУТЬ

test:
source: URL / ЛОКАЛЬНЫЙ ПУТЬ
target: ЛОКАЛЬНЫЙ ПУТЬ

infer:
source: URL / ЛОКАЛЬНЫЙ ПУТЬ
target: ЛОКАЛЬНЫЙ ПУТЬ

num_workers: КОЛВО ПОТОКОВ, ПРИМЕР - 2

val_size: ФРАКЦИЯ ОТ ТРЕНИРОВОЧНОЙ ВЫБОРКИ ДЛЯ ВАЛИДАЦИИ, ПРИМЕР - 0.2
channels_num: КОЛВО КАНАЛОВ В ИЗОБРАЖЕНИИ, ПРИМЕР - 3
image_size: РАЗМЕР ИЗОБРАЖЕНИЙ К ПОДАЧЕ В МОДЕЛЬ, ПРИМЕР - 800
num_classes: КОЛВО КЛАССОВ В ДАТАСЕТЕ, ПРИМЕР - 1
names:
- НАЗВАНИЕ КЛАССА 1
10 changes: 10 additions & 0 deletions config/experiments/detection/florence.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @package _global_
defaults:
- override /models: detection/florence
- override /datasets: detection/florence

project: "Florence"
task: "image-detection"
random_seed: 42
batch_size: 16
ckpt_path: "https://api.blackhole.ai.innopolis.university/pretrained/med/florence2_epoch_136.onnx"
8 changes: 8 additions & 0 deletions config/models/detection/florence.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Florence
description: model for detection lung deceases

_target_: innofw.core.models.torch.architectures.detection.Florence
tokenizer_save_path: "innofw/core/integrations/florence/tokenizer/"
device: "cpu"
task_prompt: "<CAPTION_TO_PHRASE_GROUNDING>"
text_input: "cardiomegaly"
13 changes: 9 additions & 4 deletions dui/assets/dui.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let tooltipDict = {
"devices": "Номера видеокарт, которые можно использовать",
"device": "Номера видеокарт, которые можно использовать(YOLO)",
"learning_rate": "Скорость обучения модели",
"stop_param": "Количество эпох, для которых допустимо отсутсвие прогресса, при превышении происходит остановка обучения",

"models": "Расширение или изменение параметров модели",
"datasets": "Расширение или изменение параметров наборов данных",
Expand All @@ -36,6 +37,7 @@ let tooltipDict = {
"override /initializations": "Переопределение вложенного конфигурационного файла параметров инициализации весов моделей",
"override /metrics": "Переопределение вложенного конфигурационного файла параметров метрик",
"override /wandb": "Переопределение вложенного конфигурационного файла параметров интерфейса для оценки эксперимента Weights and biases",
"override /clear_ml": "Переопределение вложенного конфигурационного файла параметров интерфейса для оценки эксперимента ClearML, варианты: disabled, enabled, test_queue",
"override /trainers": "",

};
Expand Down Expand Up @@ -233,8 +235,11 @@ function addParameterRow(button){
if (button.parentNode.parentNode.className === "child row"){
button.parentNode.parentNode.className = "parent row"
let valuefield_col = button.parentNode.parentNode.getElementsByClassName("valuefield_col")[0];
valuefield_col.remove();

try{
valuefield_col.remove();
} catch (error) {
console.log(error);
}
let uniterRow = document.createElement("div");
uniterRow.className="uniter row";
uniterRow.appendChild(button.parentNode.parentNode.cloneNode(true));
Expand Down Expand Up @@ -504,7 +509,7 @@ function createModalContentFromConfigDict(config, level = 0){
uniter.className="uniter row"
let parent = document.createElement("div");
parent.className="parent row";
parent.style.marginLeft = 30*level +'px' // convert p to number and add 10
parent.style.marginLeft = 100*level +'px' // convert p to number and add 10

let createButtonDiv = buildCreationButton();

Expand All @@ -531,7 +536,7 @@ function createModalContentFromConfigDict(config, level = 0){
{
let row = document.createElement("div");
row.className="child row"
row.style.marginLeft = 30*level +'px' // convert p to number and add 10
row.style.marginLeft = 100*level +'px' // convert p to number and add 10


let createButtonDiv = buildCreationButton();
Expand Down
23 changes: 15 additions & 8 deletions dui/pages/config_getting.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ def get_config():
request_body += ".yaml" if not request_body.endswith(".yaml") else ""
exp_path = configs_path / request_body
data = ""

if exp_path.exists():
with open(exp_path, "r") as yamlfile:
try:
data = yaml.load(yamlfile, Loader=yaml.FullLoader)

if data:
data = simplify_dict(data)
except yaml.YAMLError as exc:
print("ERROR:", exc)
pass
elif not exp_path.exists() and "datasets" in request_body:
exp_path = configs_path / "datasets" / "empty_template.yaml"

with open(exp_path, "r") as yamlfile:
try:
data = yaml.load(yamlfile, Loader=yaml.FullLoader)

if data:
data = simplify_dict(data)
except yaml.YAMLError as exc:
print("ERROR:", exc)


return json.dumps({'success': True, 'configuration_parameters': data}), 200, {'ContentType':'application/json'}


Expand Down
7 changes: 7 additions & 0 deletions examples/infer_florence.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data_path=$1

if [ -z "$data_path" ]; then
python infer.py experiments=detection/florence
else
python infer.py experiments=detection/florence datasets.infer.source="$data_path"
fi
1 change: 1 addition & 0 deletions innofw/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Frameworks(Enum):
ultralytics = "ultralytics"
mmdetection = "mmdetection"
none = "none"
florence = "florence"

PathLike = TypeVar(
"PathLike", str, Path
Expand Down
3 changes: 2 additions & 1 deletion innofw/core/datamodules/lightning_datamodules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from .qsar_dm import QsarSelfiesDataModule
from .semantic_segmentation.hdf5 import HDF5LightningDataModule
from .drugprot import DrugprotDataModule
from .anomaly_detection_images import ImageAnomaliesLightningDataModule
from .anomaly_detection_images import ImageAnomaliesLightningDataModule
from .florence import FlorenceJSONLDataModuleAdapter, FlorenceImageDataModuleAdapter
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def save_preds(self, out_batches, stage: Stages, dst_path: pathlib.Path):
pred = pred.astype(np.uint8)
filename = out_file_path / f"out_{n}.png"
n += 1
cv2.imwrite(filename, pred)
cv2.imwrite(str(filename), pred)
mask_vis = np.zeros_like(img)
mask_vis[1, :, :] = pred / 255
img_with_mask = (img * 255 * 0.75 + mask_vis * 255 * 0.25).astype(np.uint8).transpose((1, 2, 0))
Expand Down
4 changes: 4 additions & 0 deletions innofw/core/datamodules/lightning_datamodules/florence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from innofw.core.integrations.florence.florence_datamodule import (
FlorenceImageDataModuleAdapter,
FlorenceJSONLDataModuleAdapter,
)
51 changes: 0 additions & 51 deletions innofw/core/datasets/rasterio.py

This file was deleted.

Empty file.
Loading

0 comments on commit 7181c48

Please sign in to comment.