Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add future annotations and ruff flag #43

Merged
merged 13 commits into from
Mar 6, 2024
1 change: 1 addition & 0 deletions datadreamer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import annotations
2 changes: 2 additions & 0 deletions datadreamer/dataset_annotation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .image_annotator import BaseAnnotator, TaskList
from .owlv2_annotator import OWLv2Annotator

Expand Down
2 changes: 2 additions & 0 deletions datadreamer/dataset_annotation/image_annotator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import enum
from abc import ABC, abstractmethod

Expand Down
2 changes: 2 additions & 0 deletions datadreamer/dataset_annotation/owlv2_annotator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Tuple

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/dataset_annotation/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from torchvision import transforms


Expand Down
2 changes: 2 additions & 0 deletions datadreamer/image_generation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .sdxl_image_generator import StableDiffusionImageGenerator
from .sdxl_lightning_image_generator import StableDiffusionLightningImageGenerator
from .sdxl_turbo_image_generator import StableDiffusionTurboImageGenerator
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/image_generation/clip_image_tester.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List

import torch
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/image_generation/image_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import random
from abc import abstractmethod
from typing import List, Optional, Union
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/image_generation/sdxl_image_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Optional

import torch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Optional

import torch
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/image_generation/sdxl_turbo_image_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Optional

import torch
Expand Down
1 change: 1 addition & 0 deletions datadreamer/pipelines/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import annotations
2 changes: 2 additions & 0 deletions datadreamer/pipelines/generate_dataset_from_scratch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import json
import os
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/prompt_generation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .lm_prompt_generator import LMPromptGenerator
from .lm_synonym_generator import LMSynonymGenerator
from .simple_prompt_generator import SimplePromptGenerator
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/prompt_generation/lm_prompt_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import random
import re
from typing import List, Literal, Optional
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/prompt_generation/lm_synonym_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
from typing import List, Optional

Expand Down
2 changes: 2 additions & 0 deletions datadreamer/prompt_generation/prompt_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import random
from abc import ABC, abstractmethod
Expand Down
2 changes: 2 additions & 0 deletions datadreamer/prompt_generation/simple_prompt_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import random
from typing import List

Expand Down
6 changes: 6 additions & 0 deletions datadreamer/prompt_generation/synonym_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
from abc import ABC, abstractmethod
from typing import List, Optional
Expand All @@ -15,6 +17,10 @@ class SynonymGenerator(ABC):
device (str): Device to run the prompt generator on ('cuda' for GPU, 'cpu' for CPU).

Methods:
_init_lang_model(): Initializes the language model and tokenizer.
_generate_synonyms(prompt_text): Generates synonyms based on a given prompt text.
_extract_synonyms(text): Extracts synonyms from a text containing synonyms.
_create_prompt_text(word): Creates a prompt text for generating synonyms for a given word.
generate_synonyms_for_list(words): Generates synonyms for a list of words and returns them in a dictionary.
generate_synonyms(word): Generates synonyms for a single word and returns them in a list.
save_synonyms(synonyms, save_path): Saves the generated synonyms to a JSON file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
from typing import List, Literal, Optional

Expand Down
2 changes: 2 additions & 0 deletions datadreamer/prompt_generation/wordnet_synonym_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import List, Optional

import nltk
Expand Down
1 change: 1 addition & 0 deletions datadreamer/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import annotations
2 changes: 2 additions & 0 deletions datadreamer/utils/convert_dataset_to_yolo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import json
import os
Expand Down
1 change: 1 addition & 0 deletions datadreamer/utils/nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding:utf-8 -*-
# The code is based on
# https://github.com/ultralytics/yolov5/blob/master/utils/general.py
from __future__ import annotations

import os
import time
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ target-version = "py38"

[tool.ruff.lint]
ignore = ["F403", "B028", "B905", "D1"]
select = ["E4", "E7", "E9", "F", "W", "B", "I"]
select = ["E4", "E7", "E9", "F", "W", "B", "I", "FA"]

[tool.ruff.pydocstyle]
convention = "google"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ opencv-python>=4.7.0
accelerate>=0.25.0
scipy>=1.10.0
bitsandbytes>=0.42.0
nltk>=3.8.1
nltk>=3.8.1
2 changes: 2 additions & 0 deletions tests/integration/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import subprocess

Expand Down
2 changes: 2 additions & 0 deletions tests/unittests/test_annotators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import psutil
import pytest
Expand Down
2 changes: 2 additions & 0 deletions tests/unittests/test_image_generation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Type, Union

import psutil
Expand Down
2 changes: 2 additions & 0 deletions tests/unittests/test_prompt_generation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import psutil
import pytest
import torch
Expand Down
Loading