Skip to content

Commit

Permalink
Merge pull request #4 from KonstantinKorotaev/PyTorchLightning-master
Browse files Browse the repository at this point in the history
Fix last DeepSource analysis issues
  • Loading branch information
KonstantinKorotaev authored Aug 23, 2021
2 parents 34e7a75 + 8ba9f4c commit c9af6f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions flash/core/data/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,19 +723,24 @@ def __init__(self):
self.classes = set()
self.data_types = set()
self.num_classes = 0
self._data_folder = ""
self._raw_data = {}
self.multi_label = False
self.split = 0.8

def load_data(self, data: Optional[Any] = None, dataset: Optional[Any] = None) -> Sequence[Mapping[str, Any]]:
"""Iterate through all tasks in exported data and construct train\test\val results."""
if data and isinstance(data, dict):
self._data_folder = data.get("data_folder")
with open(data.get("export_json")) as f:
self._raw_data = json.load(f)
self.multi_label = data.get("multi_label")
self.split = data.get("split")
self.multi_label = data.get("multi_label", False)
self.split = data.get("split", 0.8)
for task in self._raw_data:
for annotation in task["annotations"]:
# extracting data types from tasks
[self.data_types.add(key) for key in task.get("data")]
for key in task.get("data"):
self.data_types.add(key)
# Adding ground_truth annotation to separate dataset
result = annotation["result"]
for res in result:
Expand Down
4 changes: 1 addition & 3 deletions flash/text/classification/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import flash
from flash.core.data.auto_dataset import AutoDataset
from flash.core.data.data_module import DataModule
from flash.core.data.data_source import DataSource, DefaultDataSources, LabelsState
from flash.core.data.data_source import DataSource, DefaultDataSources, LabelsState, LabelStudioTextDataSource
from flash.core.data.process import Deserializer, Postprocess, Preprocess
from flash.core.utilities.imports import _TEXT_AVAILABLE, requires_extras

Expand All @@ -29,8 +29,6 @@
from transformers import AutoTokenizer, default_data_collator
from transformers.modeling_outputs import SequenceClassifierOutput

from flash.core.data.data_source import LabelStudioTextDataSource


class TextDeserializer(Deserializer):
@requires_extras("text")
Expand Down

0 comments on commit c9af6f6

Please sign in to comment.